Correctly apply linear filter to drawBitmap(Rect, Rect)
Change-Id: I1049282e1996b1020c92cb7bec46e9f28e94e967
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index e67abbd..ed2fa3c 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1489,13 +1489,19 @@
const float x = (int) floorf(dstLeft + mSnapshot->transform->getTranslateX() + 0.5f);
const float y = (int) floorf(dstTop + mSnapshot->transform->getTranslateY() + 0.5f);
- texture->setFilter(GL_NEAREST, GL_NEAREST, true);
+ GLenum filter = GL_NEAREST;
+ if (u1 > 0.0f || u2 < 1.0f || v1 > 0.0f || v2 < 1.0f) {
+ filter = GL_LINEAR;
+ }
+ texture->setFilter(filter, filter, true);
+
drawTextureMesh(x, y, x + (dstRight - dstLeft), y + (dstBottom - dstTop),
texture->id, alpha / 255.0f, mode, texture->blend,
&mMeshVertices[0].position[0], &mMeshVertices[0].texture[0],
GL_TRIANGLE_STRIP, gMeshCount, false, true);
} else {
texture->setFilter(GL_LINEAR, GL_LINEAR, true);
+
drawTextureMesh(dstLeft, dstTop, dstRight, dstBottom, texture->id, alpha / 255.0f,
mode, texture->blend, &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0],
GL_TRIANGLE_STRIP, gMeshCount);
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 1a60dca..06382f2 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -144,8 +144,11 @@
// Uniforms
bindTexture(texture, mWrapS, mWrapT);
- GLenum filter = textureTransform.isPureTranslate() ? GL_NEAREST : GL_LINEAR;
- texture->setFilter(filter, filter);
+ // Assume linear here; we should really check the transform in
+ // ::updateTransforms() but we don't have the texture object
+ // available at that point. The optimization is not worth the
+ // effort for now.
+ texture->setFilter(GL_LINEAR, GL_LINEAR);
glUniform1i(program->getUniform("bitmapSampler"), textureSlot);
glUniformMatrix4fv(program->getUniform("textureTransform"), 1,