summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-05-02 21:36:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-02 21:36:57 +0000
commit7f090dfa647049dbbda08f295e06ee285c62d5c1 (patch)
tree1dc856e0fdde9ac010cb73ddcea05a3457d91fc6
parentf72382aec7af97a925b4f7228df97d83eb0ed2ba (diff)
parent1c058e96b3fb5075c34b89cf22773373811abf7a (diff)
downloadframeworks_base-7f090dfa647049dbbda08f295e06ee285c62d5c1.zip
frameworks_base-7f090dfa647049dbbda08f295e06ee285c62d5c1.tar.gz
frameworks_base-7f090dfa647049dbbda08f295e06ee285c62d5c1.tar.bz2
Merge "Allow starting an RT animation via Canvas"
-rw-r--r--core/java/android/view/GLES20RecordingCanvas.java9
-rw-r--r--core/java/android/view/RenderNode.java2
-rw-r--r--core/java/android/view/RenderNodeAnimator.java10
3 files changed, 19 insertions, 2 deletions
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index 2b29e5c..a94ec3a 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -16,6 +16,7 @@
package android.view;
+import android.annotation.NonNull;
import android.util.Pools.SynchronizedPool;
/**
@@ -32,19 +33,25 @@ class GLES20RecordingCanvas extends GLES20Canvas {
private static final SynchronizedPool<GLES20RecordingCanvas> sPool =
new SynchronizedPool<GLES20RecordingCanvas>(POOL_LIMIT);
+ RenderNode mNode;
+
private GLES20RecordingCanvas() {
super(true, true);
}
- static GLES20RecordingCanvas obtain() {
+ static GLES20RecordingCanvas obtain(@NonNull RenderNode node) {
+ if (node == null) throw new IllegalArgumentException("node cannot be null");
+
GLES20RecordingCanvas canvas = sPool.acquire();
if (canvas == null) {
canvas = new GLES20RecordingCanvas();
}
+ canvas.mNode = node;
return canvas;
}
void recycle() {
+ mNode = null;
sPool.release(this);
}
diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java
index 8b80c3e0..0cfde94 100644
--- a/core/java/android/view/RenderNode.java
+++ b/core/java/android/view/RenderNode.java
@@ -239,7 +239,7 @@ public class RenderNode {
* @see #isValid()
*/
public HardwareCanvas start(int width, int height) {
- HardwareCanvas canvas = GLES20RecordingCanvas.obtain();
+ HardwareCanvas canvas = GLES20RecordingCanvas.obtain(this);
canvas.setViewport(width, height);
// The dirty rect should always be null for a display list
canvas.onPreDraw(null);
diff --git a/core/java/android/view/RenderNodeAnimator.java b/core/java/android/view/RenderNodeAnimator.java
index b5089b0..a675821 100644
--- a/core/java/android/view/RenderNodeAnimator.java
+++ b/core/java/android/view/RenderNodeAnimator.java
@@ -16,6 +16,7 @@
package android.view;
+import android.graphics.Canvas;
import android.graphics.CanvasProperty;
import android.graphics.Paint;
import android.util.SparseIntArray;
@@ -100,6 +101,15 @@ public final class RenderNodeAnimator {
target.invalidateViewProperty(true, false);
}
+ public void start(Canvas canvas) {
+ if (!(canvas instanceof GLES20RecordingCanvas)) {
+ throw new IllegalArgumentException("Not a GLES20RecordingCanvas");
+ }
+ GLES20RecordingCanvas recordingCanvas = (GLES20RecordingCanvas) canvas;
+ mTarget = recordingCanvas.mNode;
+ mTarget.addAnimator(this);
+ }
+
public void cancel() {
mTarget.removeAnimator(this);
}