From ca9be759c8ea04ad2e58db8d5b8a5bdf31078730 Mon Sep 17 00:00:00 2001 From: Diego Perez Date: Mon, 23 May 2016 16:01:41 +0100 Subject: [PATCH] Fix Path_Delegate reset Path_Delegate.reset was not clearing the last point when called. This caused some vector drawables that relied on relative position to fail to render correctly. Bug: http://b.android.com/91383 Bug: http://b.android.com/203797 Change-Id: Id250ecf8a5a5c66671aa8d3ddd213996f824fd56 (cherry picked from commit d6db7133af7b5aed76d83c17b60b27742608a2df) --- .../src/android/graphics/Path_Delegate.java | 4 +- .../golden/vector_drawable_91383.png | Bin 0 -> 2449 bytes .../src/main/res/drawable/android.xml | 65 ++++++++++++++++++ .../src/main/res/drawable/headset.xml | 25 +++++++ .../res/layout/vector_drawable_android.xml | 34 +++++++++ .../layoutlib/bridge/intensive/Main.java | 18 +++++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/vector_drawable_91383.png create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/android.xml create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/headset.xml create mode 100644 tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/vector_drawable_android.xml diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index 265ebd1755e30..219c487cac53a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -86,6 +86,8 @@ public final class Path_Delegate { public void reset() { mPath.reset(); + mLastX = 0; + mLastY = 0; } public void setPathIterator(PathIterator iterator) { @@ -124,7 +126,7 @@ public final class Path_Delegate { return; } - pathDelegate.mPath.reset(); + pathDelegate.reset(); } @LayoutlibDelegate diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/vector_drawable_91383.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/vector_drawable_91383.png new file mode 100644 index 0000000000000000000000000000000000000000..940fe5bc44ba1d54a2a8f741fd15a1f049365a50 GIT binary patch literal 2449 zcmai$c{CJ!7sqFeElaCq@K9Q&lwmAAlbvi?hD0RGOtMv?EF()}knor&L}A7g#VcDV zWK3pKN@y^cEHjpv%rl0JeUO*8dY|*0(|g`Oe)oIsJ@@?1?|07q+gT6mhlA(g!(|h8x4wgf$tdes2lCO#ke7e+IlA&9R=JP>oxtNJ? zRmc!YoJgJ~5m!6f!$V~bihucR@P$c=YJd9l>F$DaZDWbXSY`4~lqgIPy#I#^NB|+R z5hNvcHG}&1vxE*eP%`xU%_}s=^W}M@h5X(Eb=zhp? zjQvo|BGG8O^-PqBusW>|Rw*es-myczW2W?`5?g;d!zE@X49w&|bKqN? zf;o+>x!2Uy@eebDj~iN=M||YLX~otUUgGa^{Ie<1ytD(s+$P1EqWo1FksCZNR8)Wi z(ZCg1DR4KInHPN$*&NIZP>j!3L8azbq_C4TUE=e#t?s0isFYJ0dA=m~RVqE6X*6(< zlpUu5Y|!k#+^4bcQLW3WYXBj;;-XAHfg(pYP z;88u7SeEphi*8dG>8#ka-0|#~l)P6MOp`}ruPx#d&_bj;GStdU9h0b4{2V}w7|Oq< zIzYBWNcihwR~C1Gtbm2Gi{MUez~|Y>_9tuJZ?Hw+2mHG((Ju%|*?>^R3|!g9@NL#* zndU&j!lmL#sJQNN+(xM>vwpWG$k)?*%Kl^KV}wz@pB;bVFC@WzWOaFTmmQHI%;I@p zc{9R3MzzCsiAP_INz-2loEbB>alvk@bsF5xBqE=m5U@a&Regh&V*TCOS1k_^*Z#C0SG8O1g(Rg8-^4ty$StoPEWvMxFI;gi^Y{`T0W}!0;mp} zmVrgqWHL8+A7!Dz-)Io_jag2VeO`U+2jq+f(b%1TwKQ+lweaO!D#h+zR3si?`r{QM z!`Y96=KYLm09>Hw0|}UH4C6Jns4aJvI4t&FB<6BPn$j&q*J8X}Ze%n+q$ow$oB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%3l=Sbmv{=lYi;5z0D4E&W zxd&1fW^>^|);>N@IFw21C;kmq?66%P zz_x(wh0bJYS^ncJCFoJ7U_8|}-0 AYXATM literal 0 HcmV?d00001 diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/android.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/android.xml new file mode 100644 index 0000000000000..42e3beb50b814 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/android.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/headset.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/headset.xml new file mode 100644 index 0000000000000..897c4113ead67 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/headset.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/vector_drawable_android.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/vector_drawable_android.xml new file mode 100644 index 0000000000000..3b01ea0931229 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/vector_drawable_android.xml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java index 8f570aee96b7b..112a945ef8224 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java +++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java @@ -433,6 +433,24 @@ public class Main { renderAndVerify(params, "vector_drawable.png", TimeUnit.SECONDS.toNanos(2)); } + /** + * Regression test for http://b.android.com/91383 and http://b.android.com/203797 + */ + @Test + public void testVectorDrawable91383() throws ClassNotFoundException { + // Create the layout pull parser. + LayoutPullParser parser = createLayoutPullParser("vector_drawable_android.xml"); + // Create LayoutLibCallback. + LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger()); + layoutLibCallback.initResources(); + + SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, + layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, + RenderingMode.V_SCROLL, 22); + + renderAndVerify(params, "vector_drawable_91383.png", TimeUnit.SECONDS.toNanos(2)); + } + /** Test activity.xml */ @Test public void testScrolling() throws ClassNotFoundException {