summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/SurfaceControl.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java8
2 files changed, 12 insertions, 6 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index e3da757fa74f..63a5ee42d043 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -1126,7 +1126,9 @@ public class SurfaceControl implements Parcelable {
}
/**
- * Copy the current screen contents into a bitmap and return it.
+ * Copy the current screen contents into a hardware bitmap and return it.
+ * Note: If you want to modify the Bitmap in software, you will need to copy the Bitmap into
+ * a software Bitmap using {@link Bitmap#copy(Bitmap.Config, boolean)}
*
* CAVEAT: Versions of screenshot that return a {@link Bitmap} can
* be extremely slow; avoid use unless absolutely necessary; prefer
@@ -1151,7 +1153,7 @@ public class SurfaceControl implements Parcelable {
* screenshots in its native portrait orientation by default, so this is
* useful for returning screenshots that are independent of device
* orientation.
- * @return Returns a Bitmap containing the screen contents, or null
+ * @return Returns a hardware Bitmap containing the screen contents, or null
* if an error occurs. Make sure to call Bitmap.recycle() as soon as
* possible, once its content is not needed anymore.
*/
@@ -1179,7 +1181,7 @@ public class SurfaceControl implements Parcelable {
}
/**
- * Like {@link SurfaceControl#screenshot(int, int, int, int, boolean)} but
+ * Like {@link SurfaceControl#screenshot(Rect, int, int, int, int, boolean, int)} but
* includes all Surfaces in the screenshot. This will also update the orientation so it
* sends the correct coordinates to SF based on the rotation value.
*
@@ -1236,7 +1238,7 @@ public class SurfaceControl implements Parcelable {
}
/**
- * Captures a layer and its children into the provided {@link Surface}.
+ * Captures a layer and its children and returns a {@link GraphicBuffer} with the content.
*
* @param layerHandleToken The root layer to capture.
* @param sourceCrop The portion of the root surface to capture; caller may pass in 'new
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 5fcd0061fa6f..83163316bac0 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -161,10 +161,14 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
Matrix matrix = new Matrix();
int overlayColor = 0x40FFFFFF;
+ // Bitmaps created for screenshots are hardware bitmaps. Copy to a software bitmap in order
+ // to update size for previews.
+ Bitmap swBitmap = data.image.copy(Bitmap.Config.ARGB_8888, true);
+
Bitmap picture = Bitmap.createBitmap(previewWidth, previewHeight, Bitmap.Config.ARGB_8888);
matrix.setTranslate((previewWidth - mImageWidth) / 2, (previewHeight - mImageHeight) / 2);
c.setBitmap(picture);
- c.drawBitmap(data.image, matrix, paint);
+ c.drawBitmap(swBitmap, matrix, paint);
c.drawColor(overlayColor);
c.setBitmap(null);
@@ -175,7 +179,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
matrix.postTranslate((iconSize - (scale * mImageWidth)) / 2,
(iconSize - (scale * mImageHeight)) / 2);
c.setBitmap(icon);
- c.drawBitmap(data.image, matrix, paint);
+ c.drawBitmap(swBitmap, matrix, paint);
c.drawColor(overlayColor);
c.setBitmap(null);