summaryrefslogtreecommitdiff
path: root/libs/hwui/OpenGLRenderer.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2014-03-11 12:20:17 -0700
committer Chris Craik <ccraik@google.com> 2014-03-12 09:44:41 -0700
commitb79a3e301a8d89b9e1b1f6f3d7fd6aa56610a6f0 (patch)
tree6b92898b802b665b62127766baa87e8261569062 /libs/hwui/OpenGLRenderer.cpp
parente361ad7ab15fcf4919a56a6293689d968ee8dcff (diff)
Fix orthographic shadows projection, simplify shadow reordering
Separate matrix passed to shadow system into two parts, one for transforming the polygon XY points (using the actual draw matrix) and a separate one which respects correct 4x4 3d rotations and translations for determining Z values. Change-Id: I7e30a84774a8709df6b2241e8f51fc5583648fe8
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 7002e2674af7..83de77219881 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -3190,8 +3190,16 @@ status_t OpenGLRenderer::drawRects(const float* rects, int count, const SkPaint*
return drawColorRects(rects, count, paint, false, true, true);
}
-status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlpha,
- const SkPath* casterOutline) {
+static void mapPointFakeZ(Vector3& point, const mat4& transformXY, const mat4& transformZ) {
+ // map z coordinate with true 3d matrix
+ point.z = transformZ.mapZ(point);
+
+ // map x,y coordinates with draw/Skia matrix
+ transformXY.mapPoint(point.x, point.y);
+}
+
+status_t OpenGLRenderer::drawShadow(const mat4& casterTransformXY, const mat4& casterTransformZ,
+ float casterAlpha, const SkPath* casterOutline) {
if (currentSnapshot()->isIgnored()) return DrawGlInfo::kStatusDone;
// TODO: use quickRejectWithScissor. For now, always force enable scissor.
@@ -3217,7 +3225,7 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
for (int i = 0; i < casterVertexCount; i++) {
const Vertex& point2d = casterVertices2d[i];
casterPolygon[i] = Vector3(point2d.x, point2d.y, 0);
- casterTransform.mapPoint3d(casterPolygon[i]);
+ mapPointFakeZ(casterPolygon[i], casterTransformXY, casterTransformZ);
}
// map the centroid of the caster into 3d
@@ -3225,7 +3233,7 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
reinterpret_cast<const Vector2*>(casterVertices2d.array()),
casterVertexCount);
Vector3 centroid3d(centroid.x, centroid.y, 0);
- casterTransform.mapPoint3d(centroid3d);
+ mapPointFakeZ(centroid3d, casterTransformXY, casterTransformZ);
// draw caster's shadows
if (mCaches.propertyAmbientShadowStrength > 0) {
@@ -3244,7 +3252,6 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
ShadowTessellator::tessellateSpotShadow(casterPolygon, casterVertexCount,
lightPosScale, *currentTransform(), getWidth(), getHeight(),
spotShadowVertexBuffer);
-
drawVertexBuffer(kVertexBufferMode_Shadow, spotShadowVertexBuffer, &paint);
}