summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge/src/android/graphics
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-12-01 12:28:43 -0800
committerXavier Ducrohet <xav@android.com>2010-12-02 10:58:19 -0800
commit9eb6d412af6859b6c0bb969c76bbfc48eec8fd4b (patch)
tree99f3c5fc4823142589c4c4d809d55ff84de8d420 /tools/layoutlib/bridge/src/android/graphics
parentc14e7dd8ba15f517a5402ad802377b1d60784416 (diff)
downloadframeworks_base-9eb6d412af6859b6c0bb969c76bbfc48eec8fd4b.zip
frameworks_base-9eb6d412af6859b6c0bb969c76bbfc48eec8fd4b.tar.gz
frameworks_base-9eb6d412af6859b6c0bb969c76bbfc48eec8fd4b.tar.bz2
LayoutLib: Reuse canvas when possible.
Also moved the prepare/cleanupThread methods to Bridge as they are not really specific to the scene anymore. Change-Id: I7b93821913ce4d2fcbe3d8be489be6533ff87e57
Diffstat (limited to 'tools/layoutlib/bridge/src/android/graphics')
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index b901e0d..bc6ad64 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -92,13 +92,6 @@ public class Canvas_Delegate {
return mGraphicsStack.peek();
}
- /**
- * Disposes of the {@link Graphics2D} stack.
- */
- public void dispose() {
-
- }
-
// ---- native methods ----
/*package*/ static boolean isOpaque(Canvas thisCanvas) {
@@ -985,6 +978,16 @@ public class Canvas_Delegate {
}
/*package*/ static void finalizer(int nativeCanvas) {
+ // get the delegate from the native int so that it can be disposed.
+ Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
+ if (canvasDelegate == null) {
+ assert false;
+ return;
+ }
+
+ canvasDelegate.dispose();
+
+ // remove it from the manager.
sManager.removeDelegate(nativeCanvas);
}
@@ -997,6 +1000,15 @@ public class Canvas_Delegate {
private Canvas_Delegate() {
}
+ /**
+ * Disposes of the {@link Graphics2D} stack.
+ */
+ private void dispose() {
+ while (mGraphicsStack.size() > 0) {
+ mGraphicsStack.pop().dispose();
+ }
+ }
+
private void setBitmap(BufferedImage image) {
mBufferedImage = image;
mGraphicsStack.push(mBufferedImage.createGraphics());