From 589b0bb6ab81657ba201cbc441a49f85305170bc Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 10 Oct 2011 13:57:47 -0700 Subject: Make sure we have the correct GL context when grabbing a bitmap Bug #5427391 Change-Id: I4687a6a3e8968fc3ca8ef171833b2bb7afc16f89 --- core/java/android/view/TextureView.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/java/android/view/TextureView.java') diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index d57132aef84d..169738257b3b 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -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; -- cgit v1.2.3