really fix [3118445] Transform * Transform does not work as expected
Two bugs were counter acting each other.
- rotation matrices are on the left-hand side of multiplies
- the transform of the overlay is applied before that of the layer
Change-Id: Ia79bd368e9b719235c89ecf244ea263f01ce906a
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 069b85a..64eed4b 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -415,6 +415,20 @@
cb = (texture.NPOTAdjust ? texture.hScale : 1.0f);
}
+ /*
+ * For the buffer transformation, we apply the rotation last.
+ * Since we're transforming the texture-coordinates, we need
+ * to apply the inverse of the buffer transformation:
+ * inverse( FLIP_V -> FLIP_H -> ROT_90 )
+ * <=> inverse( ROT_90 * FLIP_H * FLIP_V )
+ * = inverse(FLIP_V) * inverse(FLIP_H) * inverse(ROT_90)
+ * = FLIP_V * FLIP_H * ROT_270
+ * <=> ROT_270 -> FLIP_H -> FLIP_V
+ *
+ * The rotation is performed first, in the texture coordinate space.
+ *
+ */
+
struct TexCoords {
GLfloat u;
GLfloat v;