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/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index df12e63..3ebd57b 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -217,8 +217,8 @@
fill.program->set(glop.transform.ortho,
glop.transform.modelView,
- glop.transform.canvas,
- glop.transform.fudgingOffset);
+ glop.transform.meshTransform(),
+ glop.transform.transformFlags & TransformFlags::OffsetByFudgeFactor);
// Color filter uniforms
if (fill.filterMode == ProgramDescription::kColorBlend) {
@@ -260,7 +260,7 @@
// indices
meshState().bindIndicesBufferInternal(indices.bufferObject);
- if (vertices.attribFlags & VertexAttribFlags::kTextureCoord) {
+ if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
const Glop::Fill::TextureData& texture = fill.texture;
// texture always takes slot 0, shader samplers increment from there
mCaches->textureState().activateTexture(0);
@@ -284,13 +284,13 @@
meshState().disableTexCoordsVertexArray();
}
int colorLocation = -1;
- if (vertices.attribFlags & VertexAttribFlags::kColor) {
+ if (vertices.attribFlags & VertexAttribFlags::Color) {
colorLocation = fill.program->getAttrib("colors");
glEnableVertexAttribArray(colorLocation);
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, vertices.stride, vertices.color);
}
int alphaLocation = -1;
- if (vertices.attribFlags & VertexAttribFlags::kAlpha) {
+ if (vertices.attribFlags & VertexAttribFlags::Alpha) {
// NOTE: alpha vertex position is computed assuming no VBO
const void* alphaCoords = ((const GLbyte*) vertices.position) + kVertexAlphaOffset;
alphaLocation = fill.program->getAttrib("vtxAlpha");
@@ -318,7 +318,7 @@
// rebind pointers without forcing, since initial bind handled above
meshState().bindPositionVertexPointer(false, vertexData, vertices.stride);
- if (vertices.attribFlags & VertexAttribFlags::kTextureCoord) {
+ if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
meshState().bindTexCoordsVertexPointer(false,
vertexData + kMeshTextureOffset, vertices.stride);
}
@@ -336,10 +336,10 @@
// -----------------------------------
// ---------- Mesh teardown ----------
// -----------------------------------
- if (vertices.attribFlags & VertexAttribFlags::kAlpha) {
+ if (vertices.attribFlags & VertexAttribFlags::Alpha) {
glDisableVertexAttribArray(alphaLocation);
}
- if (vertices.attribFlags & VertexAttribFlags::kColor) {
+ if (vertices.attribFlags & VertexAttribFlags::Color) {
glDisableVertexAttribArray(colorLocation);
}
}