diff options
Diffstat (limited to 'tools/layoutlib')
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java | 27 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java | 13 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java | 9 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java | 46 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java | 37 | ||||
-rw-r--r-- | tools/layoutlib/bridge/tests/Android.mk | 2 | ||||
-rw-r--r-- | tools/layoutlib/bridge/tests/res/com/android/layoutlib/testdata/layout1.xml (renamed from tools/layoutlib/bridge/tests/src/com/android/layoutlib/testdata/layout1.xml) | 0 | ||||
-rw-r--r-- | tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java | 2 |
8 files changed, 92 insertions, 44 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java index 8e3ed93..b4448a9 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java @@ -1093,6 +1093,33 @@ public final class Canvas_Delegate { } @LayoutlibDelegate + /*package*/ static void native_drawTextWithGlyphs(int nativeCanvas, char[] text, + int index, int count, float x, + float y, int flags, int paint) { + native_drawText(nativeCanvas, text, index, count, x, y, flags, paint); + } + + @LayoutlibDelegate + /*package*/ static void native_drawTextWithGlyphs(int nativeCanvas, String text, + int start, int end, float x, + float y, int flags, int paint) { + int count = end - start; + char[] buffer = TemporaryBuffer.obtain(count); + TextUtils.getChars(text, start, end, buffer, 0); + + native_drawText(nativeCanvas, text, 0, count, x, y, flags, paint); + } + + @LayoutlibDelegate + /*package*/ static void native_drawGlyphs(int nativeCanvas, char[] glyphs, + int index, int count, float x, + float y, int flags, int paint) { + // FIXME + Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, + "Canvas.drawGlyphs is not supported.", null, null /*data*/); + } + + @LayoutlibDelegate /*package*/ static void native_drawPosText(int nativeCanvas, char[] text, int index, int count, float[] pos, diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 373f482..7777e19 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -940,9 +940,16 @@ public class Paint_Delegate { } @LayoutlibDelegate + /* package */static int native_getTextGlyphs(int native_object, String text, int start, + int end, int contextStart, int contextEnd, int flags, char[] glyphs) { + // FIXME + return 0; + } + + @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, - int flags, float[] advances, int advancesIndex) { + int flags, float[] advances, int advancesIndex, int reserved) { // get the delegate from the native int. Paint_Delegate delegate = sManager.getDelegate(native_object); if (delegate == null) { @@ -986,14 +993,14 @@ public class Paint_Delegate { @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(int native_object, String text, int start, int end, int contextStart, int contextEnd, - int flags, float[] advances, int advancesIndex) { + int flags, float[] advances, int advancesIndex, int reserved) { // FIXME: support contextStart, contextEnd and direction flag int count = end - start; char[] buffer = TemporaryBuffer.obtain(count); TextUtils.getChars(text, start, end, buffer, 0); return native_getTextRunAdvances(native_object, buffer, 0, count, contextStart, - contextEnd - contextStart, flags, advances, advancesIndex); + contextEnd - contextStart, flags, advances, advancesIndex, reserved); } @LayoutlibDelegate diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java index 65919ad..368c0384 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java @@ -73,14 +73,6 @@ public abstract class Shader_Delegate { public abstract boolean isSupported(); public abstract String getSupportMessage(); - public boolean isValid() { - if (mLocalMatrix != null && mLocalMatrix.getAffineTransform().getDeterminant() == 0) { - return false; - } - - return true; - } - // ---- native methods ---- @LayoutlibDelegate @@ -109,4 +101,5 @@ public abstract class Shader_Delegate { return new java.awt.geom.AffineTransform(); } + } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java index 89ef18e..21d6b1a 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java @@ -609,14 +609,12 @@ public class GcSnapshot { createCustomGraphics(originalGraphics, paint, compositeOnly, forceSrcMode) : (Graphics2D) originalGraphics.create(); - if (configuredGraphics2D != null) { - try { - drawable.draw(configuredGraphics2D, paint); - layer.change(); - } finally { - // dispose Graphics2D object - configuredGraphics2D.dispose(); - } + try { + drawable.draw(configuredGraphics2D, paint); + layer.change(); + } finally { + // dispose Graphics2D object + configuredGraphics2D.dispose(); } } @@ -689,13 +687,11 @@ public class GcSnapshot { Graphics2D g = createCustomGraphics(baseGfx, mLocalLayerPaint, true /*alphaOnly*/, false /*forceSrcMode*/); - if (g != null) { - g.drawImage(mLocalLayer.getImage(), - mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, - mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, - null); - g.dispose(); - } + g.drawImage(mLocalLayer.getImage(), + mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, + mLayerBounds.left, mLayerBounds.top, mLayerBounds.right, mLayerBounds.bottom, + null); + g.dispose(); baseGfx.dispose(); } @@ -725,17 +721,11 @@ public class GcSnapshot { Shader_Delegate shaderDelegate = paint.getShader(); if (shaderDelegate != null) { if (shaderDelegate.isSupported()) { - // shader could have a local matrix that's not valid (for instance 0 scaling). - if (shaderDelegate.isValid()) { - java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); - assert shaderPaint != null; - if (shaderPaint != null) { - g.setPaint(shaderPaint); - customShader = true; - } - } else { - g.dispose(); - return null; + java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint(); + assert shaderPaint != null; + if (shaderPaint != null) { + g.setPaint(shaderPaint); + customShader = true; } } else { Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, @@ -759,7 +749,7 @@ public class GcSnapshot { if (forceSrcMode) { g.setComposite(AlphaComposite.getInstance( - AlphaComposite.SRC, alpha / 255.f)); + AlphaComposite.SRC, (float) alpha / 255.f)); } else { boolean customXfermode = false; Xfermode_Delegate xfermodeDelegate = paint.getXfermode(); @@ -783,7 +773,7 @@ public class GcSnapshot { // that will handle the alpha. if (customXfermode == false && alpha != 0xFF) { g.setComposite(AlphaComposite.getInstance( - AlphaComposite.SRC_OVER, alpha / 255.f)); + AlphaComposite.SRC_OVER, (float) alpha / 255.f)); } } diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java index e6dc646..fb2fc85 100644 --- a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java +++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java @@ -44,6 +44,16 @@ public class ICU_Delegate { // --- Native methods accessing ICU's database. @LayoutlibDelegate + /*package*/ static String getIcuVersion() { + return "unknown_layoutlib"; + } + + @LayoutlibDelegate + /*package*/ static String getUnicodeVersion() { + return "5.2"; + } + + @LayoutlibDelegate /*package*/ static String[] getAvailableBreakIteratorLocalesNative() { return new String[0]; } @@ -74,17 +84,27 @@ public class ICU_Delegate { } @LayoutlibDelegate - /*package*/ static String getCurrencyCodeNative(String locale) { + /*package*/ static String[] getAvailableCurrencyCodes() { + return new String[0]; + } + + @LayoutlibDelegate + /*package*/ static String getCurrencyCode(String locale) { + return ""; + } + + @LayoutlibDelegate + /*package*/ static String getCurrencyDisplayName(String locale, String currencyCode) { return ""; } @LayoutlibDelegate - /*package*/ static int getCurrencyFractionDigitsNative(String currencyCode) { + /*package*/ static int getCurrencyFractionDigits(String currencyCode) { return 0; } @LayoutlibDelegate - /*package*/ static String getCurrencySymbolNative(String locale, String currencyCode) { + /*package*/ static String getCurrencySymbol(String locale, String currencyCode) { return ""; } @@ -114,6 +134,16 @@ public class ICU_Delegate { } @LayoutlibDelegate + /*package*/ static String addLikelySubtags(String locale) { + return ""; + } + + @LayoutlibDelegate + /*package*/ static String getScript(String locale) { + return ""; + } + + @LayoutlibDelegate /*package*/ static String[] getISOLanguagesNative() { return Locale.getISOLanguages(); } @@ -160,7 +190,6 @@ public class ICU_Delegate { // Used by DecimalFormatSymbols. result.zeroDigit = '0'; - result.digit = '0'; result.decimalSeparator = '.'; result.groupingSeparator = ','; result.patternSeparator = ' '; diff --git a/tools/layoutlib/bridge/tests/Android.mk b/tools/layoutlib/bridge/tests/Android.mk index e303638..98cade9 100644 --- a/tools/layoutlib/bridge/tests/Android.mk +++ b/tools/layoutlib/bridge/tests/Android.mk @@ -19,6 +19,8 @@ include $(CLEAR_VARS) # Only compile source java files in this lib. LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_RESOURCE_DIRS := res + LOCAL_MODULE := layoutlib-tests LOCAL_MODULE_TAGS := optional diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/testdata/layout1.xml b/tools/layoutlib/bridge/tests/res/com/android/layoutlib/testdata/layout1.xml index b8fc947..b8fc947 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/testdata/layout1.xml +++ b/tools/layoutlib/bridge/tests/res/com/android/layoutlib/testdata/layout1.xml diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java index 96436fe..865a008 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java +++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java @@ -38,7 +38,7 @@ public class BridgeXmlBlockParserTest extends TestCase { public void testXmlBlockParser() throws Exception { XmlPullParser parser = ParserFactory.create( - getClass().getResourceAsStream("com/android/layoutlib/testdata/layout1.xml"), + getClass().getResourceAsStream("/com/android/layoutlib/testdata/layout1.xml"), "layout1.xml"); parser = new BridgeXmlBlockParser(parser, null, false /* platformResourceFlag */); |