diff options
author | Romain Guy <romainguy@google.com> | 2011-07-08 16:27:47 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-08 16:27:47 -0700 |
commit | fcc8fae91e74a24eba8bb20c80d7f29aaf31a828 (patch) | |
tree | 5c5671162be056beb0db42c5671f7b12ac04bae6 /graphics/java/android | |
parent | db13e879830cb7f8305421fffa808a4ce2cb14b7 (diff) | |
parent | d4b5795e5efd05be7e482e013dfdec519ad2601e (diff) | |
download | frameworks_base-fcc8fae91e74a24eba8bb20c80d7f29aaf31a828.zip frameworks_base-fcc8fae91e74a24eba8bb20c80d7f29aaf31a828.tar.gz frameworks_base-fcc8fae91e74a24eba8bb20c80d7f29aaf31a828.tar.bz2 |
Merge "Correctly render nested rectangles with different winding rules."
Diffstat (limited to 'graphics/java/android')
-rw-r--r-- | graphics/java/android/graphics/Path.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java index 1324431..c5d7500 100644 --- a/graphics/java/android/graphics/Path.java +++ b/graphics/java/android/graphics/Path.java @@ -40,6 +40,7 @@ public class Path { */ public Region rects; private boolean mDetectSimplePaths; + private Direction mLastDirection = null; /** * Create an empty path @@ -70,6 +71,7 @@ public class Path { public void reset() { isSimplePath = true; if (mDetectSimplePaths) { + mLastDirection = null; if (rects != null) rects.setEmpty(); } native_reset(mNativePath); @@ -82,6 +84,7 @@ public class Path { public void rewind() { isSimplePath = true; if (mDetectSimplePaths) { + mLastDirection = null; if (rects != null) rects.setEmpty(); } native_rewind(mNativePath); @@ -378,6 +381,20 @@ public class Path { final int nativeInt; } + private void detectSimplePath(float left, float top, float right, float bottom, Direction dir) { + if (mDetectSimplePaths) { + if (mLastDirection == null) { + mLastDirection = dir; + } + if (mLastDirection != dir) { + isSimplePath = false; + } else { + if (rects == null) rects = new Region(); + rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); + } + } + } + /** * Add a closed rectangle contour to the path * @@ -388,11 +405,7 @@ public class Path { if (rect == null) { throw new NullPointerException("need rect parameter"); } - if (mDetectSimplePaths) { - if (rects == null) rects = new Region(); - rects.op((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom, - Region.Op.UNION); - } + detectSimplePath(rect.left, rect.top, rect.right, rect.bottom, dir); native_addRect(mNativePath, rect, dir.nativeInt); } @@ -406,10 +419,7 @@ public class Path { * @param dir The direction to wind the rectangle's contour */ public void addRect(float left, float top, float right, float bottom, Direction dir) { - if (mDetectSimplePaths) { - if (rects == null) rects = new Region(); - rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); - } + detectSimplePath(left, top, right, bottom, dir); native_addRect(mNativePath, left, top, right, bottom, dir.nativeInt); } |