Merge "Scale light z value relative to screen size" into tm-qpr-dev am: ed5f49d918
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19197402 Change-Id: I4e34c9333dfe15cf38a3ead28a60d82d17006fb5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,11 +25,11 @@ import android.graphics.BLASTBufferQueue;
|
|||||||
import android.graphics.FrameInfo;
|
import android.graphics.FrameInfo;
|
||||||
import android.graphics.HardwareRenderer;
|
import android.graphics.HardwareRenderer;
|
||||||
import android.graphics.Picture;
|
import android.graphics.Picture;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.RecordingCanvas;
|
import android.graphics.RecordingCanvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RenderNode;
|
import android.graphics.RenderNode;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Surface.OutOfResourcesException;
|
import android.view.Surface.OutOfResourcesException;
|
||||||
import android.view.View.AttachInfo;
|
import android.view.View.AttachInfo;
|
||||||
@@ -596,11 +596,18 @@ public final class ThreadedRenderer extends HardwareRenderer {
|
|||||||
*/
|
*/
|
||||||
void setLightCenter(AttachInfo attachInfo) {
|
void setLightCenter(AttachInfo attachInfo) {
|
||||||
// Adjust light position for window offsets.
|
// Adjust light position for window offsets.
|
||||||
final Point displaySize = attachInfo.mPoint;
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
attachInfo.mDisplay.getRealSize(displaySize);
|
attachInfo.mDisplay.getRealMetrics(displayMetrics);
|
||||||
final float lightX = displaySize.x / 2f - attachInfo.mWindowLeft;
|
final float lightX = displayMetrics.widthPixels / 2f - attachInfo.mWindowLeft;
|
||||||
final float lightY = mLightY - attachInfo.mWindowTop;
|
final float lightY = mLightY - attachInfo.mWindowTop;
|
||||||
setLightSourceGeometry(lightX, lightY, mLightZ, mLightRadius);
|
// To prevent shadow distortion on larger screens, scale the z position of the light source
|
||||||
|
// relative to the smallest screen dimension.
|
||||||
|
final float zRatio = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels)
|
||||||
|
/ (450f * displayMetrics.density);
|
||||||
|
final float zWeightedAdjustment = (zRatio + 2) / 3f;
|
||||||
|
final float lightZ = mLightZ * zWeightedAdjustment;
|
||||||
|
|
||||||
|
setLightSourceGeometry(lightX, lightY, lightZ, mLightRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -849,12 +856,18 @@ public final class ThreadedRenderer extends HardwareRenderer {
|
|||||||
public void setLightCenter(final Display display,
|
public void setLightCenter(final Display display,
|
||||||
final int windowLeft, final int windowTop) {
|
final int windowLeft, final int windowTop) {
|
||||||
// Adjust light position for window offsets.
|
// Adjust light position for window offsets.
|
||||||
final Point displaySize = new Point();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
display.getRealSize(displaySize);
|
display.getRealMetrics(displayMetrics);
|
||||||
final float lightX = displaySize.x / 2f - windowLeft;
|
final float lightX = displayMetrics.widthPixels / 2f - windowLeft;
|
||||||
final float lightY = mLightY - windowTop;
|
final float lightY = mLightY - windowTop;
|
||||||
|
// To prevent shadow distortion on larger screens, scale the z position of the light
|
||||||
|
// source relative to the smallest screen dimension.
|
||||||
|
final float zRatio = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels)
|
||||||
|
/ (450f * displayMetrics.density);
|
||||||
|
final float zWeightedAdjustment = (zRatio + 2) / 3f;
|
||||||
|
final float lightZ = mLightZ * zWeightedAdjustment;
|
||||||
|
|
||||||
setLightSourceGeometry(lightX, lightY, mLightZ, mLightRadius);
|
setLightSourceGeometry(lightX, lightY, lightZ, mLightRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderNode getRootNode() {
|
public RenderNode getRootNode() {
|
||||||
|
|||||||
@@ -684,7 +684,7 @@
|
|||||||
|
|
||||||
<!-- Lighting and shadow properties -->
|
<!-- Lighting and shadow properties -->
|
||||||
<dimen name="light_y">0dp</dimen>
|
<dimen name="light_y">0dp</dimen>
|
||||||
<dimen name="light_z">600dp</dimen>
|
<dimen name="light_z">500dp</dimen>
|
||||||
<dimen name="light_radius">800dp</dimen>
|
<dimen name="light_radius">800dp</dimen>
|
||||||
<item type="dimen" format="float" name="ambient_shadow_alpha">0.039</item>
|
<item type="dimen" format="float" name="ambient_shadow_alpha">0.039</item>
|
||||||
<item type="dimen" format="float" name="spot_shadow_alpha">0.19</item>
|
<item type="dimen" format="float" name="spot_shadow_alpha">0.19</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user