From b79a3e301a8d89b9e1b1f6f3d7fd6aa56610a6f0 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Tue, 11 Mar 2014 12:20:17 -0700 Subject: 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 --- libs/hwui/OpenGLRenderer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libs/hwui/OpenGLRenderer.cpp') 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(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); } -- cgit v1.2.3-59-g8ed1b