Loading libs/hwui/Layer.h +4 −4 Original line number Diff line number Diff line Loading @@ -147,12 +147,12 @@ struct Layer { this->renderTarget = renderTarget; } void setWrap(GLenum wrapS, GLenum wrapT, bool bindTexture = false, bool force = false) { texture.setWrap(wrapS, wrapT, bindTexture, force, renderTarget); void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) { texture.setWrap(wrap, bindTexture, force, renderTarget); } void setFilter(GLenum min, GLenum mag, bool bindTexture = false, bool force = false) { texture.setFilter(min, mag,bindTexture, force, renderTarget); void setFilter(GLenum filter, bool bindTexture = false, bool force = false) { texture.setFilter(filter, bindTexture, force, renderTarget); } inline bool isCacheable() { Loading libs/hwui/LayerRenderer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -294,8 +294,8 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he if (renderTarget != layer->getRenderTarget()) { layer->setRenderTarget(renderTarget); layer->bindTexture(); layer->setFilter(GL_NEAREST, GL_NEAREST, false, true); layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false, true); layer->setFilter(GL_NEAREST, false, true); layer->setWrap(GL_CLAMP_TO_EDGE, false, true); } } } Loading libs/hwui/OpenGLRenderer.cpp +26 −22 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ namespace uirenderer { // TODO: This should be set in properties #define ALPHA_THRESHOLD (0x7f / PANEL_BIT_DEPTH) #define FILTER(paint) (paint && paint->isFilterBitmap() ? GL_LINEAR : GL_NEAREST) /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -665,10 +667,10 @@ void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelView(x, y, x + rect.getWidth(), y + rect.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelView(rect.left, rect.top, rect.right, rect.bottom); } setupDrawTextureTransformUniforms(layer->getTexTransform()); Loading Loading @@ -702,9 +704,9 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); } layer->setFilter(GL_NEAREST, GL_NEAREST, true); layer->setFilter(GL_NEAREST, true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR, true); layer->setFilter(GL_LINEAR, true); } drawTextureMesh(x, y, x + rect.getWidth(), y + rect.getHeight(), Loading Loading @@ -760,10 +762,10 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) { const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelViewTranslate(x, y, x + rect.getWidth(), y + rect.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom); } setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]); Loading Loading @@ -1320,6 +1322,8 @@ void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, Sk y = (int) floorf(top + mSnapshot->transform->getTranslateY() + 0.5f); ignoreTransform = true; filter = GL_NEAREST; } else { filter = FILTER(paint); } setupDraw(); Loading @@ -1334,8 +1338,8 @@ void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, Sk setupDrawModelView(x, y, x + texture->width, y + texture->height, ignoreTransform); setupDrawTexture(texture->id); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture->setFilter(filter, filter); texture->setWrap(GL_CLAMP_TO_EDGE); texture->setFilter(filter); setupDrawPureColorUniforms(); setupDrawColorFilterUniforms(); Loading Loading @@ -1401,8 +1405,8 @@ void OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHei if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); texture->setFilter(FILTER(paint), true); int alpha; SkXfermode::Mode mode; Loading Loading @@ -1485,7 +1489,6 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, Texture* texture = mCaches.textureCache.get(bitmap); if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); const float width = texture->width; const float height = texture->height; Loading @@ -1502,6 +1505,8 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); texture->setWrap(GL_CLAMP_TO_EDGE, true); if (mSnapshot->transform->isPureTranslate()) { const float x = (int) floorf(dstLeft + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(dstTop + mSnapshot->transform->getTranslateY() + 0.5f); Loading @@ -1509,17 +1514,16 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, GLenum filter = GL_NEAREST; // Enable linear filtering if the source rectangle is scaled if (srcRight - srcLeft != dstRight - dstLeft || srcBottom - srcTop != dstBottom - dstTop) { filter = GL_LINEAR; filter = FILTER(paint); } texture->setFilter(filter, filter, true); texture->setFilter(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); texture->setFilter(FILTER(paint), 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); Loading @@ -1539,8 +1543,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int Texture* texture = mCaches.textureCache.get(bitmap); if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, true); int alpha; SkXfermode::Mode mode; Loading Loading @@ -2250,11 +2254,11 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) { x = (int) floorf(x + mSnapshot->transform->getTranslateX() + 0.5f); y = (int) floorf(y + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelViewTranslate(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelViewTranslate(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight()); } Loading Loading @@ -2447,18 +2451,18 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); if (mSnapshot->transform->isPureTranslate()) { const float x = (int) floorf(left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(top + mSnapshot->transform->getTranslateY() + 0.5f); texture->setFilter(GL_NEAREST, GL_NEAREST, true); texture->setFilter(GL_NEAREST, true); drawTextureMesh(x, y, x + texture->width, y + texture->height, texture->id, alpha / 255.0f, mode, texture->blend, (GLvoid*) NULL, (GLvoid*) gMeshTextureOffset, GL_TRIANGLE_STRIP, gMeshCount, false, true); } else { texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setFilter(FILTER(paint), true); drawTextureMesh(left, top, right, bottom, texture->id, alpha / 255.0f, mode, texture->blend, (GLvoid*) NULL, (GLvoid*) gMeshTextureOffset, GL_TRIANGLE_STRIP, gMeshCount); Loading libs/hwui/ShapeCache.h +2 −2 Original line number Diff line number Diff line Loading @@ -584,8 +584,8 @@ void ShapeCache<Entry>::generateTexture(SkBitmap& bitmap, Texture* texture) { glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.getPixels()); texture->setFilter(GL_LINEAR, GL_LINEAR); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture->setFilter(GL_LINEAR); texture->setWrap(GL_CLAMP_TO_EDGE); } }; // namespace uirenderer Loading libs/hwui/SkiaShader.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ void SkiaShader::setupProgram(Program* program, const mat4& modelView, const Sna void SkiaShader::bindTexture(Texture* texture, GLenum wrapS, GLenum wrapT) { glBindTexture(GL_TEXTURE_2D, texture->id); texture->setWrap(wrapS, wrapT); texture->setWrapST(wrapS, wrapT); } void SkiaShader::computeScreenSpaceMatrix(mat4& screenSpace, const mat4& modelView) { Loading Loading @@ -148,7 +148,7 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView, // ::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); texture->setFilter(GL_LINEAR); glUniform1i(program->getUniform("bitmapSampler"), textureSlot); glUniformMatrix4fv(program->getUniform("textureTransform"), 1, Loading Loading
libs/hwui/Layer.h +4 −4 Original line number Diff line number Diff line Loading @@ -147,12 +147,12 @@ struct Layer { this->renderTarget = renderTarget; } void setWrap(GLenum wrapS, GLenum wrapT, bool bindTexture = false, bool force = false) { texture.setWrap(wrapS, wrapT, bindTexture, force, renderTarget); void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) { texture.setWrap(wrap, bindTexture, force, renderTarget); } void setFilter(GLenum min, GLenum mag, bool bindTexture = false, bool force = false) { texture.setFilter(min, mag,bindTexture, force, renderTarget); void setFilter(GLenum filter, bool bindTexture = false, bool force = false) { texture.setFilter(filter, bindTexture, force, renderTarget); } inline bool isCacheable() { Loading
libs/hwui/LayerRenderer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -294,8 +294,8 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he if (renderTarget != layer->getRenderTarget()) { layer->setRenderTarget(renderTarget); layer->bindTexture(); layer->setFilter(GL_NEAREST, GL_NEAREST, false, true); layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false, true); layer->setFilter(GL_NEAREST, false, true); layer->setWrap(GL_CLAMP_TO_EDGE, false, true); } } } Loading
libs/hwui/OpenGLRenderer.cpp +26 −22 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ namespace uirenderer { // TODO: This should be set in properties #define ALPHA_THRESHOLD (0x7f / PANEL_BIT_DEPTH) #define FILTER(paint) (paint && paint->isFilterBitmap() ? GL_LINEAR : GL_NEAREST) /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -665,10 +667,10 @@ void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelView(x, y, x + rect.getWidth(), y + rect.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelView(rect.left, rect.top, rect.right, rect.bottom); } setupDrawTextureTransformUniforms(layer->getTexTransform()); Loading Loading @@ -702,9 +704,9 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); } layer->setFilter(GL_NEAREST, GL_NEAREST, true); layer->setFilter(GL_NEAREST, true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR, true); layer->setFilter(GL_LINEAR, true); } drawTextureMesh(x, y, x + rect.getWidth(), y + rect.getHeight(), Loading Loading @@ -760,10 +762,10 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) { const float x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelViewTranslate(x, y, x + rect.getWidth(), y + rect.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom); } setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]); Loading Loading @@ -1320,6 +1322,8 @@ void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, Sk y = (int) floorf(top + mSnapshot->transform->getTranslateY() + 0.5f); ignoreTransform = true; filter = GL_NEAREST; } else { filter = FILTER(paint); } setupDraw(); Loading @@ -1334,8 +1338,8 @@ void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, Sk setupDrawModelView(x, y, x + texture->width, y + texture->height, ignoreTransform); setupDrawTexture(texture->id); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture->setFilter(filter, filter); texture->setWrap(GL_CLAMP_TO_EDGE); texture->setFilter(filter); setupDrawPureColorUniforms(); setupDrawColorFilterUniforms(); Loading Loading @@ -1401,8 +1405,8 @@ void OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHei if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); texture->setFilter(FILTER(paint), true); int alpha; SkXfermode::Mode mode; Loading Loading @@ -1485,7 +1489,6 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, Texture* texture = mCaches.textureCache.get(bitmap); if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); const float width = texture->width; const float height = texture->height; Loading @@ -1502,6 +1505,8 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); texture->setWrap(GL_CLAMP_TO_EDGE, true); if (mSnapshot->transform->isPureTranslate()) { const float x = (int) floorf(dstLeft + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(dstTop + mSnapshot->transform->getTranslateY() + 0.5f); Loading @@ -1509,17 +1514,16 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, GLenum filter = GL_NEAREST; // Enable linear filtering if the source rectangle is scaled if (srcRight - srcLeft != dstRight - dstLeft || srcBottom - srcTop != dstBottom - dstTop) { filter = GL_LINEAR; filter = FILTER(paint); } texture->setFilter(filter, filter, true); texture->setFilter(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); texture->setFilter(FILTER(paint), 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); Loading @@ -1539,8 +1543,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int Texture* texture = mCaches.textureCache.get(bitmap); if (!texture) return; const AutoTexture autoCleanup(texture); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); texture->setFilter(GL_LINEAR, true); int alpha; SkXfermode::Mode mode; Loading Loading @@ -2250,11 +2254,11 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) { x = (int) floorf(x + mSnapshot->transform->getTranslateX() + 0.5f); y = (int) floorf(y + mSnapshot->transform->getTranslateY() + 0.5f); layer->setFilter(GL_NEAREST, GL_NEAREST); layer->setFilter(GL_NEAREST); setupDrawModelViewTranslate(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight(), true); } else { layer->setFilter(GL_LINEAR, GL_LINEAR); layer->setFilter(GL_LINEAR); setupDrawModelViewTranslate(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight()); } Loading Loading @@ -2447,18 +2451,18 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, true); texture->setWrap(GL_CLAMP_TO_EDGE, true); if (mSnapshot->transform->isPureTranslate()) { const float x = (int) floorf(left + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(top + mSnapshot->transform->getTranslateY() + 0.5f); texture->setFilter(GL_NEAREST, GL_NEAREST, true); texture->setFilter(GL_NEAREST, true); drawTextureMesh(x, y, x + texture->width, y + texture->height, texture->id, alpha / 255.0f, mode, texture->blend, (GLvoid*) NULL, (GLvoid*) gMeshTextureOffset, GL_TRIANGLE_STRIP, gMeshCount, false, true); } else { texture->setFilter(GL_LINEAR, GL_LINEAR, true); texture->setFilter(FILTER(paint), true); drawTextureMesh(left, top, right, bottom, texture->id, alpha / 255.0f, mode, texture->blend, (GLvoid*) NULL, (GLvoid*) gMeshTextureOffset, GL_TRIANGLE_STRIP, gMeshCount); Loading
libs/hwui/ShapeCache.h +2 −2 Original line number Diff line number Diff line Loading @@ -584,8 +584,8 @@ void ShapeCache<Entry>::generateTexture(SkBitmap& bitmap, Texture* texture) { glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.getPixels()); texture->setFilter(GL_LINEAR, GL_LINEAR); texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture->setFilter(GL_LINEAR); texture->setWrap(GL_CLAMP_TO_EDGE); } }; // namespace uirenderer Loading
libs/hwui/SkiaShader.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ void SkiaShader::setupProgram(Program* program, const mat4& modelView, const Sna void SkiaShader::bindTexture(Texture* texture, GLenum wrapS, GLenum wrapT) { glBindTexture(GL_TEXTURE_2D, texture->id); texture->setWrap(wrapS, wrapT); texture->setWrapST(wrapS, wrapT); } void SkiaShader::computeScreenSpaceMatrix(mat4& screenSpace, const mat4& modelView) { Loading Loading @@ -148,7 +148,7 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView, // ::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); texture->setFilter(GL_LINEAR); glUniform1i(program->getUniform("bitmapSampler"), textureSlot); glUniformMatrix4fv(program->getUniform("textureTransform"), 1, Loading