Merge "Make sure we have the correct GL context when grabbing a bitmap Bug #5427391"

This commit is contained in:
Romain Guy
2011-10-10 14:07:10 -07:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 0 deletions

View File

@@ -502,9 +502,23 @@ public class TextureView extends View {
* @see #isAvailable()
* @see #getBitmap(int, int)
* @see #getBitmap()
*
* @throws IllegalStateException if the hardware rendering context cannot be
* acquired to capture the bitmap
*/
public Bitmap getBitmap(Bitmap bitmap) {
if (bitmap != null && isAvailable()) {
AttachInfo info = mAttachInfo;
if (info != null && info.mHardwareRenderer != null &&
info.mHardwareRenderer.isEnabled()) {
if (!info.mHardwareRenderer.validate()) {
throw new IllegalStateException("Could not acquire hardware rendering context");
}
}
applyUpdate();
applyTransformMatrix();
mLayer.copyInto(bitmap);
}
return bitmap;

View File

@@ -10125,6 +10125,14 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
return mHardwareLayer;
}
/**
* Destroys this View's hardware layer if possible.
*
* @return True if the layer was destroyed, false otherwise.
*
* @see #setLayerType(int, android.graphics.Paint)
* @see #LAYER_TYPE_HARDWARE
*/
boolean destroyLayer() {
if (mHardwareLayer != null) {
mHardwareLayer.destroy();