Merge "Tweaking workaround to use fallback with null buffer" into rvc-dev am: 5be32a1c11
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12100099 Change-Id: Ice79c30eeb522ff47191feb8d4f1f20c57a6d995
This commit is contained in:
@@ -26,6 +26,7 @@ import android.app.ActivityManager.TaskSnapshot;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.GraphicBuffer;
|
import android.graphics.GraphicBuffer;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.hardware.HardwareBuffer;
|
import android.hardware.HardwareBuffer;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -63,10 +64,12 @@ public class ThumbnailData {
|
|||||||
|
|
||||||
public ThumbnailData(TaskSnapshot snapshot) {
|
public ThumbnailData(TaskSnapshot snapshot) {
|
||||||
final GraphicBuffer buffer = snapshot.getSnapshot();
|
final GraphicBuffer buffer = snapshot.getSnapshot();
|
||||||
if (buffer != null && (buffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
|
if (buffer == null || (buffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
|
||||||
// TODO(b/157562905): Workaround for a crash when we get a snapshot without this state
|
// TODO(b/157562905): Workaround for a crash when we get a snapshot without this state
|
||||||
Log.e("ThumbnailData", "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE");
|
Log.e("ThumbnailData", "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE: "
|
||||||
thumbnail = Bitmap.createBitmap(buffer.getWidth(), buffer.getHeight(), ARGB_8888);
|
+ buffer);
|
||||||
|
Point taskSize = snapshot.getTaskSize();
|
||||||
|
thumbnail = Bitmap.createBitmap(taskSize.x, taskSize.y, ARGB_8888);
|
||||||
thumbnail.eraseColor(Color.BLACK);
|
thumbnail.eraseColor(Color.BLACK);
|
||||||
} else {
|
} else {
|
||||||
thumbnail = Bitmap.wrapHardwareBuffer(buffer, snapshot.getColorSpace());
|
thumbnail = Bitmap.wrapHardwareBuffer(buffer, snapshot.getColorSpace());
|
||||||
|
|||||||
Reference in New Issue
Block a user