summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2014-01-17 02:09:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-01-17 02:09:19 +0000
commit8191effc83b3ec4cfc8647a6eb16ee641fa85a2f (patch)
treeb6436517e03490954add5a348a3ef1332f317e00
parented0f7cba53be0af991fc7435549f7a798b1d377b (diff)
parent3197cded4e265bc99dc82d695bbb7163fe134ed4 (diff)
Merge "Map shadow light position globally"
-rw-r--r--libs/hwui/OpenGLRenderer.cpp4
-rw-r--r--libs/hwui/ShadowTessellator.cpp9
-rw-r--r--libs/hwui/ShadowTessellator.h2
3 files changed, 11 insertions, 4 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 4f6da2b9eb1b..8fb6e38fbbc1 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -3201,8 +3201,8 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
VertexBuffer spotShadowVertexBuffer;
ShadowTessellator::tessellateSpotShadow(width, height,
- getWidth(), getHeight(), casterTransform,
- spotShadowVertexBuffer);
+ *currentTransform(), getWidth(), getHeight(),
+ casterTransform, spotShadowVertexBuffer);
drawVertexBuffer(spotShadowVertexBuffer, &paint);
return DrawGlInfo::kStatusDrew;
diff --git a/libs/hwui/ShadowTessellator.cpp b/libs/hwui/ShadowTessellator.cpp
index ddd1c6d928ac..b9ce872d6d71 100644
--- a/libs/hwui/ShadowTessellator.cpp
+++ b/libs/hwui/ShadowTessellator.cpp
@@ -85,7 +85,7 @@ void ShadowTessellator::tessellateAmbientShadow(float width, float height,
}
void ShadowTessellator::tessellateSpotShadow(float width, float height,
- int screenWidth, int screenHeight,
+ const mat4& receiverTransform, int screenWidth, int screenHeight,
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) {
const int vertexCount = 4;
Vector3 polygon[vertexCount];
@@ -101,6 +101,13 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height,
#if DEBUG_SHADOW
ALOGD("light center %f %f %f", lightCenter.x, lightCenter.y, lightCenter.z);
#endif
+
+ // light position (because it's in local space) needs to compensate for receiver transform
+ // TODO: should apply to light orientation, not just position
+ Matrix4 reverseReceiverTransform;
+ reverseReceiverTransform.loadInverse(receiverTransform);
+ reverseReceiverTransform.mapPoint3d(lightCenter);
+
const float lightSize = maximal / 8;
const int lightVertexCount = 16;
diff --git a/libs/hwui/ShadowTessellator.h b/libs/hwui/ShadowTessellator.h
index fff00b1e65ad..44ac8c0c2fc9 100644
--- a/libs/hwui/ShadowTessellator.h
+++ b/libs/hwui/ShadowTessellator.h
@@ -30,7 +30,7 @@ public:
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer);
static void tessellateSpotShadow(float width, float height,
- int screenWidth, int screenHeight,
+ const mat4& receiverTransform, int screenWidth, int screenHeight,
const mat4& casterTransform, VertexBuffer& shadowVertexBuffer);
private: