summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-11-10 19:23:58 -0800
committerRomain Guy <romainguy@google.com>2011-11-10 19:23:58 -0800
commitda96f8ac2c1c35a54f3f36e6d776cb386a251d03 (patch)
tree646abfdfeee4346b422943924182162f4a3cdf84 /core
parent50a66f0e9c5a85a6af4a99eb66656a69eba24572 (diff)
downloadframeworks_base-da96f8ac2c1c35a54f3f36e6d776cb386a251d03.zip
frameworks_base-da96f8ac2c1c35a54f3f36e6d776cb386a251d03.tar.gz
frameworks_base-da96f8ac2c1c35a54f3f36e6d776cb386a251d03.tar.bz2
Discard framebuffer rendering queues when discarding layers
Bug #5581817 Change-Id: If612846ec5f7793710fc4df152791fb32c506551
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/GLES20Canvas.java1
-rw-r--r--core/java/android/view/GLES20Layer.java7
-rw-r--r--core/java/android/view/HardwareLayer.java5
-rw-r--r--core/java/android/view/View.java19
-rw-r--r--core/java/android/view/ViewGroup.java11
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp5
6 files changed, 46 insertions, 2 deletions
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index d948ec2..ac06d2d 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -154,6 +154,7 @@ class GLES20Canvas extends HardwareCanvas {
static native void nSetTextureLayerTransform(int layerId, int matrix);
static native void nDestroyLayer(int layerId);
static native void nDestroyLayerDeferred(int layerId);
+ static native void nFlushLayer(int layerId);
static native boolean nCopyLayer(int layerId, int bitmap);
///////////////////////////////////////////////////////////////////////////
diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java
index fd3b9e5..4f25792 100644
--- a/core/java/android/view/GLES20Layer.java
+++ b/core/java/android/view/GLES20Layer.java
@@ -60,6 +60,13 @@ abstract class GLES20Layer extends HardwareLayer {
}
mLayer = 0;
}
+
+ @Override
+ void flush() {
+ if (mLayer != 0) {
+ GLES20Canvas.nFlushLayer(mLayer);
+ }
+ }
static class Finalizer {
private int mLayerId;
diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java
index 28389ab..d5666f3 100644
--- a/core/java/android/view/HardwareLayer.java
+++ b/core/java/android/view/HardwareLayer.java
@@ -116,6 +116,11 @@ abstract class HardwareLayer {
abstract void destroy();
/**
+ * Flush the render queue associated with this layer.
+ */
+ abstract void flush();
+
+ /**
* This must be invoked before drawing onto this layer.
* @param currentCanvas
*/
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index dc46d42..3bddeef 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10146,6 +10146,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
break;
}
}
+
+ void flushLayer() {
+ if (mLayerType == LAYER_TYPE_HARDWARE && mHardwareLayer != null) {
+ mHardwareLayer.flush();
+ }
+ }
/**
* <p>Returns a hardware layer that can be used to draw this view again
@@ -10158,6 +10164,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
!mAttachInfo.mHardwareRenderer.isEnabled()) {
return null;
}
+
+ if (!mAttachInfo.mHardwareRenderer.validate()) return null;
+
final int width = mRight - mLeft;
final int height = mBottom - mTop;
@@ -10232,8 +10241,14 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
*/
boolean destroyLayer() {
if (mHardwareLayer != null) {
- mHardwareLayer.destroy();
- mHardwareLayer = null;
+ AttachInfo info = mAttachInfo;
+ if (info != null && info.mHardwareRenderer != null &&
+ info.mHardwareRenderer.isEnabled()) {
+ if (!info.mHardwareRenderer.validate()) {
+ mHardwareLayer.destroy();
+ mHardwareLayer = null;
+ }
+ }
return true;
}
return false;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index e366e72..50b34b0 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2957,6 +2957,16 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (enabled != mDrawLayers) {
mDrawLayers = enabled;
invalidate(true);
+
+ AttachInfo info = mAttachInfo;
+ if (info != null && info.mHardwareRenderer != null &&
+ info.mHardwareRenderer.isEnabled()) {
+ if (!info.mHardwareRenderer.validate()) {
+ enabled = false;
+ }
+ } else {
+ enabled = false;
+ }
// We need to invalidate any child with a layer. For instance,
// if a child is backed by a hardware layer and we disable layers
@@ -2968,6 +2978,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
for (int i = 0; i < mChildrenCount; i++) {
View child = mChildren[i];
if (child.mLayerType != LAYER_TYPE_NONE) {
+ if (!enabled) child.flushLayer();
child.invalidate(true);
}
}
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 4f75fad..78b8e8e 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -718,6 +718,10 @@ static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env,
LayerRenderer::destroyLayerDeferred(layer);
}
+static void android_view_GLES20Canvas_flushLayer(JNIEnv* env, jobject clazz, Layer* layer) {
+ LayerRenderer::flushLayer(layer);
+}
+
static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, Layer* layer, jfloat x, jfloat y, SkPaint* paint) {
renderer->drawLayer(layer, x, y, paint);
@@ -860,6 +864,7 @@ static JNINativeMethod gMethods[] = {
{ "nSetTextureLayerTransform", "(II)V", (void*) android_view_GLES20Canvas_setTextureLayerTransform },
{ "nDestroyLayer", "(I)V", (void*) android_view_GLES20Canvas_destroyLayer },
{ "nDestroyLayerDeferred", "(I)V", (void*) android_view_GLES20Canvas_destroyLayerDeferred },
+ { "nFlushLayer", "(I)V", (void*) android_view_GLES20Canvas_flushLayer },
{ "nDrawLayer", "(IIFFI)V", (void*) android_view_GLES20Canvas_drawLayer },
{ "nCopyLayer", "(II)Z", (void*) android_view_GLES20Canvas_copyLayer },