diff options
author | Xavier Ducrohet <xav@android.com> | 2010-11-29 11:45:47 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-11-29 17:56:58 -0800 |
commit | e80f4d4d2ac48db8d94b6071e296a8acba32a09a (patch) | |
tree | 43b28ce213e1eda4d4cdac29453d0c70c41444ae /eclipse/plugins/com.android.ide.eclipse.adt/src/com | |
parent | 7f3dac3959c0e9ea04d7cece780ef4eca22ea6f0 (diff) | |
download | sdk-e80f4d4d2ac48db8d94b6071e296a8acba32a09a.zip sdk-e80f4d4d2ac48db8d94b6071e296a8acba32a09a.tar.gz sdk-e80f4d4d2ac48db8d94b6071e296a8acba32a09a.tar.bz2 |
ADT: more animation stuff.
Change-Id: I020342a4fe205161328f22e9dabb0b03343677b5
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com')
2 files changed, 47 insertions, 9 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java index 4782204..ff5d3c4 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java @@ -346,6 +346,8 @@ class LayoutCanvas extends Canvas { mImageOverlay.dispose(); mImageOverlay = null; } + + mViewHierarchy.dispose(); } /** Returns the Rules Engine, associated with the current project. */ @@ -1004,7 +1006,8 @@ class LayoutCanvas extends Canvas { // Add test action // Don't add it at the top above (by the cut action) because the // dynamic context menu makes some assumptions about where things are - manager.add(new Action("Run My Test", IAction.AS_PUSH_BUTTON) { + // FIXME remove test. + manager.add(new Action("Play anim test", IAction.AS_PUSH_BUTTON) { @Override public void run() { List<SelectionItem> selection = mSelectionManager.getSelections(); @@ -1017,14 +1020,21 @@ class LayoutCanvas extends Canvas { scene.animate(viewObject, "testanim", false /*isFrameworkAnimation*/, new IAnimationListener() { - - public void onNewFrame(final BufferedImage image) { - getDisplay().asyncExec(new Runnable() { - public void run() { - mImageOverlay.setImage(image); - redraw(); - } - }); + private int mCount = 0; + private BufferedImage mImage; + private boolean mPendingDrawing = false; + public synchronized void onNewFrame(final BufferedImage image) { + mCount++; + mImage = image; + if (mPendingDrawing == false) { + getDisplay().asyncExec(new Runnable() { + public void run() { + drawImage(); + } + }); + + mPendingDrawing = true; + } } public boolean isCanceled() { @@ -1032,6 +1042,23 @@ class LayoutCanvas extends Canvas { } public void done(SceneResult result) { + System.out.println("Animation count: " + mCount); + } + + /** + * this is called from the UI thread from the asyncRunnable. + */ + public void drawImage() { + // get last image + BufferedImage image; + synchronized (this) { + image = mImage; + mImage = null; + mPendingDrawing = false; + } + + mImageOverlay.setImage(image); + redraw(); } }); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ViewHierarchy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ViewHierarchy.java index 58e3d1a..686b0ba 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ViewHierarchy.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ViewHierarchy.java @@ -98,6 +98,17 @@ public class ViewHierarchy { private LayoutScene mScene; /** + * Disposes the view hierarchy content. + */ + public void dispose() { + if (mScene != null) { + mScene.dispose(); + mScene = null; + } + } + + + /** * Sets the result of the layout rendering. The result object indicates if the layout * rendering succeeded. If it did, it contains a bitmap and the objects rectangles. * |