Merge "Fix view outline for shadows in LayoutLib." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8381e2cdcc
@@ -15778,11 +15778,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBackgroundSizeChanged) {
|
||||
background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
|
||||
mBackgroundSizeChanged = false;
|
||||
rebuildOutline();
|
||||
}
|
||||
setBackgroundBounds();
|
||||
|
||||
// Attempt to use a display list if requested.
|
||||
if (canvas.isHardwareAccelerated() && mAttachInfo != null
|
||||
@@ -15808,6 +15804,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the correct background bounds and rebuilds the outline, if needed.
|
||||
* <p/>
|
||||
* This is called by LayoutLib.
|
||||
*/
|
||||
void setBackgroundBounds() {
|
||||
if (mBackgroundSizeChanged && mBackground != null) {
|
||||
mBackground.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
|
||||
mBackgroundSizeChanged = false;
|
||||
rebuildOutline();
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundRenderNodeProperties(RenderNode renderNode) {
|
||||
renderNode.setTranslationX(mScrollX);
|
||||
renderNode.setTranslationY(mScrollY);
|
||||
|
||||
@@ -220,7 +220,8 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_restore(long nativeCanvas) {
|
||||
/*package*/ static void native_restore(long nativeCanvas, boolean throwOnUnderflow) {
|
||||
// FIXME: implement throwOnUnderflow.
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -231,7 +232,9 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_restoreToCount(long nativeCanvas, int saveCount) {
|
||||
/*package*/ static void native_restoreToCount(long nativeCanvas, int saveCount,
|
||||
boolean throwOnUnderflow) {
|
||||
// FIXME: implement throwOnUnderflow.
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
|
||||
@@ -46,16 +46,12 @@ public class ViewGroup_Delegate {
|
||||
/*package*/ static boolean drawChild(ViewGroup thisVG, Canvas canvas, View child,
|
||||
long drawingTime) {
|
||||
if (child.getZ() > thisVG.getZ()) {
|
||||
// The background's bounds are set lazily. Make sure they are set correctly so that
|
||||
// the outline obtained is correct.
|
||||
child.setBackgroundBounds();
|
||||
ViewOutlineProvider outlineProvider = child.getOutlineProvider();
|
||||
Outline outline = new Outline();
|
||||
Outline outline = child.mAttachInfo.mTmpOutline;
|
||||
outlineProvider.getOutline(child, outline);
|
||||
if (outline.mPath == null && outline.mRect == null) {
|
||||
// Sometimes, the bounds of the background drawable are not set until View.draw()
|
||||
// is called. So, we set the bounds manually and try to get the outline again.
|
||||
child.getBackground().setBounds(0, 0, child.mRight - child.mLeft,
|
||||
child.mBottom - child.mTop);
|
||||
outlineProvider.getOutline(child, outline);
|
||||
}
|
||||
if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) {
|
||||
int restoreTo = transformCanvas(thisVG, canvas, child);
|
||||
drawShadow(thisVG, canvas, child, outline);
|
||||
|
||||
Reference in New Issue
Block a user