summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aurélien Pomini <pomini@google.com> 2022-10-10 13:58:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-10-10 13:58:11 +0000
commitda56b4d9b643eb34ae2d300fc002fdf31737e8e1 (patch)
treea770baedf5081a09e3da97fe380ae1dd91c1d209
parent018b513b1a42ad38c5c37f8d18764b4819a129df (diff)
parentd100aed6386fc82e573909e6843cc0e1eb6fc06d (diff)
Merge "Reintroduce WCG drawing if supported" into tm-qpr-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java
index 6b3beeb54c76..42d7d52a71ab 100644
--- a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java
@@ -528,6 +528,7 @@ public class ImageWallpaper extends WallpaperService {
@VisibleForTesting
static final int MIN_SURFACE_HEIGHT = 128;
private Bitmap mBitmap;
+ private boolean mWideColorGamut = false;
/*
* Counter to unload the bitmap as soon as possible.
@@ -674,14 +675,16 @@ public class ImageWallpaper extends WallpaperService {
@VisibleForTesting
void drawFrameOnCanvas(Bitmap bitmap) {
Trace.beginSection("ImageWallpaper.CanvasEngine#drawFrame");
- // TODO change SurfaceHolder API to add wcg support
- Canvas c = mSurfaceHolder.lockHardwareCanvas();
- if (c != null) {
+ Surface surface = mSurfaceHolder.getSurface();
+ Canvas canvas = mWideColorGamut
+ ? surface.lockHardwareWideColorGamutCanvas()
+ : surface.lockHardwareCanvas();
+ if (canvas != null) {
Rect dest = mSurfaceHolder.getSurfaceFrame();
try {
- c.drawBitmap(bitmap, null, dest, null);
+ canvas.drawBitmap(bitmap, null, dest, null);
} finally {
- mSurfaceHolder.unlockCanvasAndPost(c);
+ surface.unlockCanvasAndPost(canvas);
}
}
Trace.endSection();
@@ -778,6 +781,8 @@ public class ImageWallpaper extends WallpaperService {
mBitmap.recycle();
}
mBitmap = bitmap;
+ mWideColorGamut = mWallpaperManager.wallpaperSupportsWcg(
+ WallpaperManager.FLAG_SYSTEM);
// +2 usages for the color extraction and the delayed unload.
mBitmapUsages += 2;
@@ -839,10 +844,6 @@ public class ImageWallpaper extends WallpaperService {
public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep,
int xPixelOffset, int yPixelOffset) {
- /*
- * TODO check this formula. mPages is always >= 4, even when launcher is single-paged
- * this formula is also used in the GL engine
- */
final int pages;
if (xOffsetStep > 0 && xOffsetStep <= 1) {
pages = Math.round(1 / xOffsetStep) + 1;