Merge "Fix view outline for shadows in LayoutLib." into mnc-dev

This commit is contained in:
Deepanshu Gupta
2015-04-27 23:20:34 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 15 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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);