Merge "Fix how outlines are sent to rendernode" into nyc-dev

This commit is contained in:
Chris Craik
2016-04-04 22:08:30 +00:00
committed by Android (Google) Code Review
3 changed files with 42 additions and 17 deletions

View File

@@ -307,18 +307,22 @@ public class RenderNode {
*
* Deep copies the data into native to simplify reference ownership.
*/
public boolean setOutline(Outline outline) {
public boolean setOutline(@Nullable Outline outline) {
if (outline == null) {
return nSetOutlineNone(mNativeRenderNode);
} else if (outline.isEmpty()) {
return nSetOutlineEmpty(mNativeRenderNode);
} else if (outline.mRect != null) {
return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top,
outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha);
} else if (outline.mPath != null) {
return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath,
outline.mAlpha);
}
switch(outline.mMode) {
case Outline.MODE_EMPTY:
return nSetOutlineEmpty(mNativeRenderNode);
case Outline.MODE_ROUND_RECT:
return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top,
outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha);
case Outline.MODE_CONVEX_PATH:
return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath,
outline.mAlpha);
}
throw new IllegalArgumentException("Unrecognized outline?");
}

View File

@@ -37,22 +37,26 @@ import java.lang.annotation.RetentionPolicy;
public final class Outline {
private static final float RADIUS_UNDEFINED = Float.NEGATIVE_INFINITY;
private static final int MODE_EMPTY = 0;
private static final int MODE_RECT = 1;
private static final int MODE_CONVEX_PATH = 2;
/** @hide */
public static final int MODE_EMPTY = 0;
/** @hide */
public static final int MODE_ROUND_RECT = 1;
/** @hide */
public static final int MODE_CONVEX_PATH = 2;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = false,
value = {
MODE_EMPTY,
MODE_RECT,
MODE_ROUND_RECT,
MODE_CONVEX_PATH,
})
public @interface Mode {}
/** @hide */
@Mode
private int mMode = MODE_EMPTY;
public int mMode = MODE_EMPTY;
/** @hide */
public final Path mPath = new Path();
@@ -176,7 +180,7 @@ public final class Outline {
return;
}
mMode = MODE_RECT;
mMode = MODE_ROUND_RECT;
mRect.set(left, top, right, bottom);
mRadius = radius;
mPath.rewind();
@@ -199,7 +203,7 @@ public final class Outline {
* bounds, or {@code false} if no outline bounds are set
*/
public boolean getRect(@NonNull Rect outRect) {
if (mMode != MODE_RECT) {
if (mMode != MODE_ROUND_RECT) {
return false;
}
outRect.set(mRect);
@@ -270,7 +274,7 @@ public final class Outline {
* Offsets the Outline by (dx,dy)
*/
public void offset(int dx, int dy) {
if (mMode == MODE_RECT) {
if (mMode == MODE_ROUND_RECT) {
mRect.offset(dx, dy);
} else if (mMode == MODE_CONVEX_PATH) {
mPath.offset(dx, dy);

View File

@@ -155,6 +155,23 @@ void RenderProperties::debugOutputProperties(const int level) const {
ALOGD("%*s(ClipRect %d, %d, %d, %d)", level * 2, "",
(int)clipRect.left, (int)clipRect.top, (int)clipRect.right, (int)clipRect.bottom);
}
if (getRevealClip().willClip()) {
Rect bounds;
getRevealClip().getBounds(&bounds);
ALOGD("%*s(Clip to reveal clip with bounds %.2f %.2f %.2f %.2f)", level * 2, "",
RECT_ARGS(bounds));
}
auto& outline = mPrimitiveFields.mOutline;
if (outline.getShouldClip()) {
if (outline.isEmpty()) {
ALOGD("%*s(Clip to empty outline)", level * 2, "");
} else if (outline.willClip()) {
ALOGD("%*s(Clip to outline with bounds %.2f %.2f %.2f %.2f)", level * 2, "",
RECT_ARGS(outline.getBounds()));
}
}
}
void RenderProperties::updateMatrix() {