OSDN Git Service

[Magnifier-64] Fix light source alpha for renderer
authorMihai Popa <popam@google.com>
Tue, 13 Nov 2018 13:25:02 +0000 (13:25 +0000)
committerMihai Popa <popam@google.com>
Tue, 13 Nov 2018 17:29:20 +0000 (17:29 +0000)
I9e6f44b07a170574a905f42338282c4bb7e95f56 changed the way the light
source alphas were set for renderers - the alphas were passed as ints
between 0 and 255 before, while now they are passed as a double between
0 and 1.  This CL updates SimpleRenderer, which is only used by the
magnifier, to use the API correctly. Before this CL, the incorrect usage
was causing the value validation to fail and apps to crash when the
magnifier was trigerred.

Bug: 119423778
Test: manually tested the magnifier
Change-Id: I8978ac16aca38906ec2cf4ae30a83beddfc9e941

core/java/android/view/ThreadedRenderer.java

index bac0154..6a90a37 100644 (file)
@@ -675,10 +675,8 @@ public final class ThreadedRenderer extends HardwareRenderer {
             mLightY = a.getDimension(R.styleable.Lighting_lightY, 0);
             mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0);
             mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0);
-            final int ambientShadowAlpha =
-                    (int) (255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0) + 0.5f);
-            final int spotShadowAlpha =
-                    (int) (255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0) + 0.5f);
+            final float ambientShadowAlpha = a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0);
+            final float spotShadowAlpha = a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0);
             a.recycle();
             setLightSourceAlpha(ambientShadowAlpha, spotShadowAlpha);
         }