DO NOT MERGE Prevent ImageWallpaper from crashing due to wide gamut am: 34c8ecdf28
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11700113 Change-Id: I7166c3a9ee9dd6882d4d233665f108d6840a2a21
This commit is contained in:
@@ -167,7 +167,7 @@ class ImageGLWallpaper {
|
|||||||
private void setupTexture(Bitmap bitmap) {
|
private void setupTexture(Bitmap bitmap) {
|
||||||
final int[] tids = new int[1];
|
final int[] tids = new int[1];
|
||||||
|
|
||||||
if (bitmap == null) {
|
if (bitmap == null || bitmap.isRecycled()) {
|
||||||
Log.w(TAG, "setupTexture: invalid bitmap");
|
Log.w(TAG, "setupTexture: invalid bitmap");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,16 +179,20 @@ class ImageGLWallpaper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind a named texture to a target.
|
try {
|
||||||
glBindTexture(GL_TEXTURE_2D, tids[0]);
|
// Bind a named texture to a target.
|
||||||
// Load the bitmap data and copy it over into the texture object that is currently bound.
|
glBindTexture(GL_TEXTURE_2D, tids[0]);
|
||||||
GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
|
// Load the bitmap data and copy it over into the texture object
|
||||||
// Use bilinear texture filtering when minification.
|
// that is currently bound.
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
|
||||||
// Use bilinear texture filtering when magnification.
|
// Use bilinear texture filtering when minification.
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
// Use bilinear texture filtering when magnification.
|
||||||
mTextureId = tids[0];
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
mTextureId = tids[0];
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.w(TAG, "Failed uploading texture: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void useTexture() {
|
void useTexture() {
|
||||||
|
|||||||
@@ -86,7 +86,13 @@ class ImageProcessHelper {
|
|||||||
protected Float doInBackground(Bitmap... bitmaps) {
|
protected Float doInBackground(Bitmap... bitmaps) {
|
||||||
Bitmap bitmap = bitmaps[0];
|
Bitmap bitmap = bitmaps[0];
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
return new Threshold().compute(bitmap);
|
try {
|
||||||
|
return new Threshold().compute(bitmap);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Log.e(TAG, "Failed at computing threshold, color space="
|
||||||
|
+ bitmap.getColorSpace(), e);
|
||||||
|
return DEFAULT_THRESHOLD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.e(TAG, "ThresholdComputeTask: Can't get bitmap");
|
Log.e(TAG, "ThresholdComputeTask: Can't get bitmap");
|
||||||
return DEFAULT_THRESHOLD;
|
return DEFAULT_THRESHOLD;
|
||||||
@@ -116,7 +122,8 @@ class ImageProcessHelper {
|
|||||||
int width = bitmap.getWidth();
|
int width = bitmap.getWidth();
|
||||||
int height = bitmap.getHeight();
|
int height = bitmap.getHeight();
|
||||||
|
|
||||||
Bitmap grayscale = Bitmap.createBitmap(width, height, bitmap.getConfig());
|
Bitmap grayscale = Bitmap.createBitmap(width, height,
|
||||||
|
bitmap.getConfig(), false, bitmap.getColorSpace());
|
||||||
Canvas canvas = new Canvas(grayscale);
|
Canvas canvas = new Canvas(grayscale);
|
||||||
ColorMatrix cm = new ColorMatrix(LUMINOSITY_MATRIX);
|
ColorMatrix cm = new ColorMatrix(LUMINOSITY_MATRIX);
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
|
|||||||
Reference in New Issue
Block a user