Skip to content

Commit 1e43657

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Make sure we have the correct GL context when grabbing a bitmap Bug #5427391"
2 parents 184b44e + 589b0bb commit 1e43657

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

core/java/android/view/TextureView.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,23 @@ public Bitmap getBitmap(int width, int height) {
502502
* @see #isAvailable()
503503
* @see #getBitmap(int, int)
504504
* @see #getBitmap()
505+
*
506+
* @throws IllegalStateException if the hardware rendering context cannot be
507+
* acquired to capture the bitmap
505508
*/
506509
public Bitmap getBitmap(Bitmap bitmap) {
507510
if (bitmap != null && isAvailable()) {
511+
AttachInfo info = mAttachInfo;
512+
if (info != null && info.mHardwareRenderer != null &&
513+
info.mHardwareRenderer.isEnabled()) {
514+
if (!info.mHardwareRenderer.validate()) {
515+
throw new IllegalStateException("Could not acquire hardware rendering context");
516+
}
517+
}
518+
519+
applyUpdate();
520+
applyTransformMatrix();
521+
508522
mLayer.copyInto(bitmap);
509523
}
510524
return bitmap;

core/java/android/view/View.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10125,6 +10125,14 @@ HardwareLayer getHardwareLayer() {
1012510125
return mHardwareLayer;
1012610126
}
1012710127

10128+
/**
10129+
* Destroys this View's hardware layer if possible.
10130+
*
10131+
* @return True if the layer was destroyed, false otherwise.
10132+
*
10133+
* @see #setLayerType(int, android.graphics.Paint)
10134+
* @see #LAYER_TYPE_HARDWARE
10135+
*/
1012810136
boolean destroyLayer() {
1012910137
if (mHardwareLayer != null) {
1013010138
mHardwareLayer.destroy();

0 commit comments

Comments
 (0)