Notify views when EGL resources are about to be destroyed
Bug #5639899
Change-Id: I7c5d8bebf02294426f5b3ab1358a31c38a4fd064
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index e2f3919..5002be7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10073,7 +10073,7 @@
switch (mLayerType) {
case LAYER_TYPE_HARDWARE:
destroyLayer();
- // fall through - unaccelerated views may use software layer mechanism instead
+ // fall through - non-accelerated views may use software layer mechanism instead
case LAYER_TYPE_SOFTWARE:
destroyDrawingCache();
break;
@@ -10235,12 +10235,31 @@
if (mHardwareLayer != null) {
mHardwareLayer.destroy();
mHardwareLayer = null;
+
+ invalidate(true);
+ invalidateParentCaches();
+
return true;
}
return false;
}
/**
+ * Destroys all hardware rendering resources. This method is invoked
+ * when the system needs to reclaim resources. Upon execution of this
+ * method, you should free any OpenGL resources created by the view.
+ *
+ * Note: you <strong>must</strong> call
+ * <code>super.destroyHardwareResources()</code> when overriding
+ * this method.
+ *
+ * @hide
+ */
+ protected void destroyHardwareResources() {
+ destroyLayer();
+ }
+
+ /**
* <p>Enables or disables the drawing cache. When the drawing cache is enabled, the next call
* to {@link #getDrawingCache()} or {@link #buildDrawingCache()} will draw the view in a
* bitmap. Calling {@link #draw(android.graphics.Canvas)} will not draw from the cache when