summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-02-13 17:09:45 -0800
committerztenghui <ztenghui@google.com>2014-02-13 17:09:45 -0800
commitef94c6f88fbb1deb095b1494378befcdb9722839 (patch)
treed0917ce76760da1e439a94ee3ddabb10af2026dc /libs
parentb9122c672e76923018198ab0eda07fa6a2145dbc (diff)
downloadframeworks_base-ef94c6f88fbb1deb095b1494378befcdb9722839.zip
frameworks_base-ef94c6f88fbb1deb095b1494378befcdb9722839.tar.gz
frameworks_base-ef94c6f88fbb1deb095b1494378befcdb9722839.tar.bz2
Separate spot and ambient shadow strength setting
Change-Id: I4530e618b09a7f44b5382f8a40646c0ebf5f214c
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Caches.cpp13
-rw-r--r--libs/hwui/Caches.h3
-rw-r--r--libs/hwui/OpenGLRenderer.cpp33
3 files changed, 30 insertions, 19 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 8bd9de0..21cf658 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -685,7 +685,8 @@ void Caches::initTempProperties() {
propertyDirtyViewport = false;
propertyEnable3d = false;
propertyCameraDistance = 1.0f;
- propertyShadowStrength = 0x3f;
+ propertyAmbientShadowStrength = 0x3f;
+ propertySpotShadowStrength = 0x3f;
propertyLightPosXScale = 0.5f;
propertyLightPosYScale = 0.0f;
@@ -704,9 +705,13 @@ void Caches::setTempProperty(const char* name, const char* value) {
propertyDirtyViewport = true;
ALOGD("camera dist multiplier = %.2f", propertyCameraDistance);
return;
- } else if (!strcmp(name, "shadowStrength")) {
- propertyShadowStrength = atoi(value);
- ALOGD("shadow strength = 0x%x out of 0xff", propertyShadowStrength);
+ } else if (!strcmp(name, "ambientShadowStrength")) {
+ propertyAmbientShadowStrength = atoi(value);
+ ALOGD("ambient shadow strength = 0x%x out of 0xff", propertyAmbientShadowStrength);
+ return;
+ } else if (!strcmp(name, "spotShadowStrength")) {
+ propertySpotShadowStrength = atoi(value);
+ ALOGD("spot shadow strength = 0x%x out of 0xff", propertySpotShadowStrength);
return;
} else if (!strcmp(name, "lightPosXScale")) {
propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0);
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index e7ba9ac..2cc15cc 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -367,7 +367,8 @@ public:
float propertyLightPosXScale;
float propertyLightPosYScale;
float propertyLightPosZScale;
- int propertyShadowStrength;
+ int propertyAmbientShadowStrength;
+ int propertySpotShadowStrength;
private:
enum OverdrawColorSet {
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index fee916b..9b253a6 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -3214,7 +3214,6 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
mCaches.enableScissor();
SkPaint paint;
- paint.setARGB(mCaches.propertyShadowStrength, 0, 0, 0);
paint.setAntiAlias(true); // want to use AlphaVertex
// tessellate caster outline into a 2d polygon
@@ -3238,19 +3237,25 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
}
// draw caster's shadows
- VertexBuffer ambientShadowVertexBuffer;
- ShadowTessellator::tessellateAmbientShadow(casterPolygon, casterVertexCount,
- ambientShadowVertexBuffer);
- drawVertexBuffer(ambientShadowVertexBuffer, &paint);
-
- VertexBuffer spotShadowVertexBuffer;
- Vector3 lightPosScale(mCaches.propertyLightPosXScale,
- mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale);
- ShadowTessellator::tessellateSpotShadow(casterPolygon, casterVertexCount,
- lightPosScale, *currentTransform(), getWidth(), getHeight(),
- spotShadowVertexBuffer);
-
- drawVertexBuffer(spotShadowVertexBuffer, &paint);
+ if (mCaches.propertyAmbientShadowStrength > 0) {
+ paint.setARGB(mCaches.propertyAmbientShadowStrength, 0, 0, 0);
+ VertexBuffer ambientShadowVertexBuffer;
+ ShadowTessellator::tessellateAmbientShadow(casterPolygon, casterVertexCount,
+ ambientShadowVertexBuffer);
+ drawVertexBuffer(ambientShadowVertexBuffer, &paint);
+ }
+
+ if (mCaches.propertySpotShadowStrength > 0) {
+ paint.setARGB(mCaches.propertySpotShadowStrength, 0, 0, 0);
+ VertexBuffer spotShadowVertexBuffer;
+ Vector3 lightPosScale(mCaches.propertyLightPosXScale,
+ mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale);
+ ShadowTessellator::tessellateSpotShadow(casterPolygon, casterVertexCount,
+ lightPosScale, *currentTransform(), getWidth(), getHeight(),
+ spotShadowVertexBuffer);
+
+ drawVertexBuffer(spotShadowVertexBuffer, &paint);
+ }
return DrawGlInfo::kStatusDrew;
}