Handle shader matrix correctly when ignoring canvas transform
bug:20063841
Restores old SkShader matrix behavior from before the Glop refactor.
Many drawing operations draw without sending the canvas transform to
the GL shader. In such cases, we need to adapt the matrix sent to the
SkShader logic to invert the canvas transform that's built into
the mesh.
Change-Id: I42b6f59df36ce46436322b95bf9ad2140795ee58
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index c79ae77..9664f58 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -51,17 +51,20 @@
///////////////////////////////////////////////////////////////////////////////
void TextDrawFunctor::draw(CacheTexture& texture, bool linearFiltering) {
- int textureFillFlags = static_cast<int>(texture.getFormat() == GL_ALPHA
- ? TextureFillFlags::kIsAlphaMaskTexture : TextureFillFlags::kNone);
- if (linearFiltering) {
- textureFillFlags |= TextureFillFlags::kForceFilter;
+ int textureFillFlags = TextureFillFlags::None;
+ if (texture.getFormat() == GL_ALPHA) {
+ textureFillFlags |= TextureFillFlags::IsAlphaMaskTexture;
}
- const Matrix4& transform = pureTranslate ? Matrix4::identity() : *(renderer->currentTransform());
+ if (linearFiltering) {
+ textureFillFlags |= TextureFillFlags::ForceFilter;
+ }
+ int transformFlags = pureTranslate
+ ? TransformFlags::MeshIgnoresCanvasTransform : TransformFlags::None;
Glop glop;
GlopBuilder(renderer->mRenderState, renderer->mCaches, &glop)
.setMeshTexturedIndexedQuads(texture.mesh(), texture.meshElementCount())
.setFillTexturePaint(texture.getTexture(), textureFillFlags, paint, renderer->currentSnapshot()->alpha)
- .setTransform(renderer->currentSnapshot()->getOrthoMatrix(), transform, false)
+ .setTransform(*(renderer->currentSnapshot()), transformFlags)
.setModelViewOffsetRect(0, 0, Rect(0, 0, 0, 0))
.setRoundRectClipState(renderer->currentSnapshot()->roundRectClipState)
.build();