Loading tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +28 −7 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ import java.util.Map; */ public final class NinePatch_Delegate { // ---- delegate manager ---- private static final DelegateManager<NinePatch_Delegate> sManager = new DelegateManager<NinePatch_Delegate>(NinePatch_Delegate.class); // ---- delegate helper data ---- /** * Cache map for {@link NinePatchChunk}. * When the chunks are created they are serialized into a byte[], and both are put Loading @@ -60,6 +65,10 @@ public final class NinePatch_Delegate { private final static Map<byte[], SoftReference<NinePatchChunk>> sChunkCache = new HashMap<byte[], SoftReference<NinePatchChunk>>(); // ---- delegate data ---- private byte[] chunk; // ---- Public Helper methods ---- /** Loading Loading @@ -149,32 +158,39 @@ public final class NinePatch_Delegate { } @LayoutlibDelegate /*package*/ static void validateNinePatchChunk(int bitmap, byte[] chunk) { /*package*/ static int validateNinePatchChunk(int bitmap, byte[] chunk) { // the default JNI implementation only checks that the byte[] has the same // size as the C struct it represent. Since we cannot do the same check (serialization // will return different size depending on content), we do nothing. NinePatch_Delegate newDelegate = new NinePatch_Delegate(); newDelegate.chunk = chunk; return sManager.addNewDelegate(newDelegate); } /*package*/ static void nativeFinalize(int chunk) { sManager.removeJavaReferenceFor(chunk); } @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, (int) loc.left, (int) loc.top, (int) loc.width(), (int) loc.height(), bitmap_instance, c, paint_instance_or_null, bitmap_instance, chunk, paint_instance_or_null, destDensity, srcDensity); } @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, loc.left, loc.top, loc.width(), loc.height(), bitmap_instance, c, paint_instance_or_null, bitmap_instance, chunk, paint_instance_or_null, destDensity, srcDensity); } @LayoutlibDelegate /*package*/ static int nativeGetTransparentRegion(int bitmap, byte[] chunk, Rect location) { /*package*/ static int nativeGetTransparentRegion(int bitmap, int chunk, Rect location) { return 0; } Loading @@ -182,7 +198,7 @@ public final class NinePatch_Delegate { private static void draw(int canvas_instance, final int left, final int top, final int right, final int bottom, int bitmap_instance, byte[] c, int paint_instance_or_null, int bitmap_instance, int chunk, int paint_instance_or_null, final int destDensity, final int srcDensity) { // get the delegate from the native int. final Bitmap_Delegate bitmap_delegate = Bitmap_Delegate.getDelegate(bitmap_instance); Loading @@ -190,6 +206,11 @@ public final class NinePatch_Delegate { return; } byte[] c = null; NinePatch_Delegate delegate = sManager.getDelegate(chunk); if (delegate != null) { c = delegate.chunk; } if (c == null) { // not a 9-patch? BufferedImage image = bitmap_delegate.getImage(); Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android.view; import android.util.DisplayMetrics; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayInfo; import android.view.View; import android.view.WindowManager; Loading @@ -32,7 +33,8 @@ public class WindowManagerImpl implements WindowManager { DisplayInfo info = new DisplayInfo(); info.logicalHeight = mMetrics.heightPixels; info.logicalWidth = mMetrics.widthPixels; mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, null); mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS); } @Override Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +15 −6 Original line number Diff line number Diff line Loading @@ -248,11 +248,16 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso * The counterpart is {@link #setUp()}. */ private void tearDown() { // The context may be null, if there was an error during init(). if (mContext != null) { // Make sure to remove static references, otherwise we could not unload the lib mContext.disposeResources(); } if (sCurrentContext != null) { // quit HandlerThread created during this session. HandlerThread_Delegate.cleanUp(sCurrentContext); } // clear the stored ViewConfiguration since the map is per density and not per context. ViewConfiguration_Accessor.clearConfigurations(); Loading @@ -263,10 +268,14 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso sCurrentContext = null; Bridge.setLog(null); if (mContext != null) { mContext.getRenderResources().setFrameworkResourceIdProvider(null); mContext.getRenderResources().setLogger(null); } mContext = null; } public static BridgeContext getCurrentContext() { return sCurrentContext; } Loading tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java +4 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package libcore.icu; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import com.ibm.icu.text.DateTimePatternGenerator; import com.ibm.icu.util.ULocale; import java.util.Locale; Loading Loading @@ -45,7 +47,8 @@ public class ICU_Delegate { @LayoutlibDelegate /*package*/ static String getBestDateTimePattern(String skeleton, String localeName) { return ""; // TODO: check what the right value should be. return DateTimePatternGenerator.getInstance(new ULocale(localeName)) .getBestPattern(skeleton); } @LayoutlibDelegate Loading Loading
tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +28 −7 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ import java.util.Map; */ public final class NinePatch_Delegate { // ---- delegate manager ---- private static final DelegateManager<NinePatch_Delegate> sManager = new DelegateManager<NinePatch_Delegate>(NinePatch_Delegate.class); // ---- delegate helper data ---- /** * Cache map for {@link NinePatchChunk}. * When the chunks are created they are serialized into a byte[], and both are put Loading @@ -60,6 +65,10 @@ public final class NinePatch_Delegate { private final static Map<byte[], SoftReference<NinePatchChunk>> sChunkCache = new HashMap<byte[], SoftReference<NinePatchChunk>>(); // ---- delegate data ---- private byte[] chunk; // ---- Public Helper methods ---- /** Loading Loading @@ -149,32 +158,39 @@ public final class NinePatch_Delegate { } @LayoutlibDelegate /*package*/ static void validateNinePatchChunk(int bitmap, byte[] chunk) { /*package*/ static int validateNinePatchChunk(int bitmap, byte[] chunk) { // the default JNI implementation only checks that the byte[] has the same // size as the C struct it represent. Since we cannot do the same check (serialization // will return different size depending on content), we do nothing. NinePatch_Delegate newDelegate = new NinePatch_Delegate(); newDelegate.chunk = chunk; return sManager.addNewDelegate(newDelegate); } /*package*/ static void nativeFinalize(int chunk) { sManager.removeJavaReferenceFor(chunk); } @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, (int) loc.left, (int) loc.top, (int) loc.width(), (int) loc.height(), bitmap_instance, c, paint_instance_or_null, bitmap_instance, chunk, paint_instance_or_null, destDensity, srcDensity); } @LayoutlibDelegate /*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance, byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) { int chunk, int paint_instance_or_null, int destDensity, int srcDensity) { draw(canvas_instance, loc.left, loc.top, loc.width(), loc.height(), bitmap_instance, c, paint_instance_or_null, bitmap_instance, chunk, paint_instance_or_null, destDensity, srcDensity); } @LayoutlibDelegate /*package*/ static int nativeGetTransparentRegion(int bitmap, byte[] chunk, Rect location) { /*package*/ static int nativeGetTransparentRegion(int bitmap, int chunk, Rect location) { return 0; } Loading @@ -182,7 +198,7 @@ public final class NinePatch_Delegate { private static void draw(int canvas_instance, final int left, final int top, final int right, final int bottom, int bitmap_instance, byte[] c, int paint_instance_or_null, int bitmap_instance, int chunk, int paint_instance_or_null, final int destDensity, final int srcDensity) { // get the delegate from the native int. final Bitmap_Delegate bitmap_delegate = Bitmap_Delegate.getDelegate(bitmap_instance); Loading @@ -190,6 +206,11 @@ public final class NinePatch_Delegate { return; } byte[] c = null; NinePatch_Delegate delegate = sManager.getDelegate(chunk); if (delegate != null) { c = delegate.chunk; } if (c == null) { // not a 9-patch? BufferedImage image = bitmap_delegate.getImage(); Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android.view; import android.util.DisplayMetrics; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayInfo; import android.view.View; import android.view.WindowManager; Loading @@ -32,7 +33,8 @@ public class WindowManagerImpl implements WindowManager { DisplayInfo info = new DisplayInfo(); info.logicalHeight = mMetrics.heightPixels; info.logicalWidth = mMetrics.widthPixels; mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, null); mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS); } @Override Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +15 −6 Original line number Diff line number Diff line Loading @@ -248,11 +248,16 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso * The counterpart is {@link #setUp()}. */ private void tearDown() { // The context may be null, if there was an error during init(). if (mContext != null) { // Make sure to remove static references, otherwise we could not unload the lib mContext.disposeResources(); } if (sCurrentContext != null) { // quit HandlerThread created during this session. HandlerThread_Delegate.cleanUp(sCurrentContext); } // clear the stored ViewConfiguration since the map is per density and not per context. ViewConfiguration_Accessor.clearConfigurations(); Loading @@ -263,10 +268,14 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso sCurrentContext = null; Bridge.setLog(null); if (mContext != null) { mContext.getRenderResources().setFrameworkResourceIdProvider(null); mContext.getRenderResources().setLogger(null); } mContext = null; } public static BridgeContext getCurrentContext() { return sCurrentContext; } Loading
tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java +4 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package libcore.icu; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; import com.ibm.icu.text.DateTimePatternGenerator; import com.ibm.icu.util.ULocale; import java.util.Locale; Loading Loading @@ -45,7 +47,8 @@ public class ICU_Delegate { @LayoutlibDelegate /*package*/ static String getBestDateTimePattern(String skeleton, String localeName) { return ""; // TODO: check what the right value should be. return DateTimePatternGenerator.getInstance(new ULocale(localeName)) .getBestPattern(skeleton); } @LayoutlibDelegate Loading