Loading libs/hwui/Caches.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -686,6 +686,10 @@ void Caches::initTempProperties() { propertyEnable3d = false; propertyCameraDistance = 1.0f; propertyShadowStrength = 0x3f; propertyLightPosXScale = 0.5f; propertyLightPosYScale = 0.0f; propertyLightPosZScale = 1.0f; } void Caches::setTempProperty(const char* name, const char* value) { Loading @@ -704,6 +708,21 @@ void Caches::setTempProperty(const char* name, const char* value) { propertyShadowStrength = atoi(value); ALOGD("shadow strength = 0x%x out of 0xff", propertyShadowStrength); return; } else if (!strcmp(name, "lightPosXScale")) { propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos X Scale = %.2f", propertyLightPosXScale); return; } else if (!strcmp(name, "lightPosYScale")) { propertyLightPosYScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos Y Scale = %.2f", propertyLightPosXScale); return; } else if (!strcmp(name, "lightPosZScale")) { propertyLightPosZScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos Z Scale = %.2f", propertyLightPosXScale); return; } ALOGD(" failed"); } Loading libs/hwui/Caches.h +8 −0 Original line number Diff line number Diff line Loading @@ -359,6 +359,14 @@ public: bool propertyEnable3d; bool propertyDirtyViewport; // flag set when dirtying the viewport float propertyCameraDistance; // These scaling factors range from 0 to 1, to scale the light position // within the bound of (screenwidth, screenheight, max(screenwidth, screenheight)); // The default scale is (0.5, 0, 1) which put the light at // (screenwidth / 2, 0, max(screenwidth, screenheight)). float propertyLightPosXScale; float propertyLightPosYScale; float propertyLightPosZScale; int propertyShadowStrength; private: Loading libs/hwui/OpenGLRenderer.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -3200,9 +3200,12 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp drawVertexBuffer(ambientShadowVertexBuffer, &paint); VertexBuffer spotShadowVertexBuffer; ShadowTessellator::tessellateSpotShadow(width, height, Vector3 lightPosScale(mCaches.propertyLightPosXScale, mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale); ShadowTessellator::tessellateSpotShadow(width, height, lightPosScale, *currentTransform(), getWidth(), getHeight(), casterTransform, spotShadowVertexBuffer); drawVertexBuffer(spotShadowVertexBuffer, &paint); return DrawGlInfo::kStatusDrew; Loading libs/hwui/ShadowTessellator.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -85,8 +85,9 @@ void ShadowTessellator::tessellateAmbientShadow(float width, float height, } void ShadowTessellator::tessellateSpotShadow(float width, float height, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) { const Vector3& lightPosScale, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) { const int vertexCount = 4; Vector3 polygon[vertexCount]; generateCasterPolygon(width, height, casterTransform, vertexCount, polygon); Loading @@ -97,7 +98,8 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height, const int layers = 2; const float strength = 0.5; int maximal = max(screenWidth, screenHeight); Vector3 lightCenter(screenWidth / 2, 0, maximal); Vector3 lightCenter(screenWidth * lightPosScale.x, screenHeight * lightPosScale.y, maximal * lightPosScale.z); #if DEBUG_SHADOW ALOGD("light center %f %f %f", lightCenter.x, lightCenter.y, lightCenter.z); #endif Loading @@ -108,7 +110,7 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height, reverseReceiverTransform.loadInverse(receiverTransform); reverseReceiverTransform.mapPoint3d(lightCenter); const float lightSize = maximal / 8; const float lightSize = maximal / 4; const int lightVertexCount = 16; SpotShadow::createSpotShadow(polygon, vertexCount, lightCenter, lightSize, Loading libs/hwui/ShadowTessellator.h +3 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,9 @@ public: const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); static void tessellateSpotShadow(float width, float height, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); const Vector3& lightPosScale, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); private: static void generateCasterPolygon(float width, float height, Loading Loading
libs/hwui/Caches.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -686,6 +686,10 @@ void Caches::initTempProperties() { propertyEnable3d = false; propertyCameraDistance = 1.0f; propertyShadowStrength = 0x3f; propertyLightPosXScale = 0.5f; propertyLightPosYScale = 0.0f; propertyLightPosZScale = 1.0f; } void Caches::setTempProperty(const char* name, const char* value) { Loading @@ -704,6 +708,21 @@ void Caches::setTempProperty(const char* name, const char* value) { propertyShadowStrength = atoi(value); ALOGD("shadow strength = 0x%x out of 0xff", propertyShadowStrength); return; } else if (!strcmp(name, "lightPosXScale")) { propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos X Scale = %.2f", propertyLightPosXScale); return; } else if (!strcmp(name, "lightPosYScale")) { propertyLightPosYScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos Y Scale = %.2f", propertyLightPosXScale); return; } else if (!strcmp(name, "lightPosZScale")) { propertyLightPosZScale = fmin(fmax(atof(value), 0.0), 1.0); propertyDirtyViewport = true; ALOGD("lightPos Z Scale = %.2f", propertyLightPosXScale); return; } ALOGD(" failed"); } Loading
libs/hwui/Caches.h +8 −0 Original line number Diff line number Diff line Loading @@ -359,6 +359,14 @@ public: bool propertyEnable3d; bool propertyDirtyViewport; // flag set when dirtying the viewport float propertyCameraDistance; // These scaling factors range from 0 to 1, to scale the light position // within the bound of (screenwidth, screenheight, max(screenwidth, screenheight)); // The default scale is (0.5, 0, 1) which put the light at // (screenwidth / 2, 0, max(screenwidth, screenheight)). float propertyLightPosXScale; float propertyLightPosYScale; float propertyLightPosZScale; int propertyShadowStrength; private: Loading
libs/hwui/OpenGLRenderer.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -3200,9 +3200,12 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp drawVertexBuffer(ambientShadowVertexBuffer, &paint); VertexBuffer spotShadowVertexBuffer; ShadowTessellator::tessellateSpotShadow(width, height, Vector3 lightPosScale(mCaches.propertyLightPosXScale, mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale); ShadowTessellator::tessellateSpotShadow(width, height, lightPosScale, *currentTransform(), getWidth(), getHeight(), casterTransform, spotShadowVertexBuffer); drawVertexBuffer(spotShadowVertexBuffer, &paint); return DrawGlInfo::kStatusDrew; Loading
libs/hwui/ShadowTessellator.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -85,8 +85,9 @@ void ShadowTessellator::tessellateAmbientShadow(float width, float height, } void ShadowTessellator::tessellateSpotShadow(float width, float height, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) { const Vector3& lightPosScale, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer) { const int vertexCount = 4; Vector3 polygon[vertexCount]; generateCasterPolygon(width, height, casterTransform, vertexCount, polygon); Loading @@ -97,7 +98,8 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height, const int layers = 2; const float strength = 0.5; int maximal = max(screenWidth, screenHeight); Vector3 lightCenter(screenWidth / 2, 0, maximal); Vector3 lightCenter(screenWidth * lightPosScale.x, screenHeight * lightPosScale.y, maximal * lightPosScale.z); #if DEBUG_SHADOW ALOGD("light center %f %f %f", lightCenter.x, lightCenter.y, lightCenter.z); #endif Loading @@ -108,7 +110,7 @@ void ShadowTessellator::tessellateSpotShadow(float width, float height, reverseReceiverTransform.loadInverse(receiverTransform); reverseReceiverTransform.mapPoint3d(lightCenter); const float lightSize = maximal / 8; const float lightSize = maximal / 4; const int lightVertexCount = 16; SpotShadow::createSpotShadow(polygon, vertexCount, lightCenter, lightSize, Loading
libs/hwui/ShadowTessellator.h +3 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,9 @@ public: const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); static void tessellateSpotShadow(float width, float height, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); const Vector3& lightPosScale, const mat4& receiverTransform, int screenWidth, int screenHeight, const mat4& casterTransform, VertexBuffer& shadowVertexBuffer); private: static void generateCasterPolygon(float width, float height, Loading