diff options
author | 2017-04-15 21:41:22 -0700 | |
---|---|---|
committer | 2017-04-15 21:41:22 -0700 | |
commit | 55455181233cadcd6d2e28d28d0dfc9a653f7787 (patch) | |
tree | df8e1a022f7363fa15d0b11a0f90035b7a76c259 | |
parent | 7859022e8eeabb5aa65af15773fe9cff329c71ec (diff) |
Properly decode colors spaces in BitmapRegionDecoder
Reusing a bitmap with BitmapRegionDecoder would preserve the
previous color space. This change also tweaks color space
matching to make sure we pick Display P3 with parameter d=0.039
or d=0.04045
Bug: 36905374
Test: CtsGraphicsTestCases
Change-Id: I4d2d66e5babebb0b5ce5cbdc7e8244177b4b7f9c
-rw-r--r-- | core/jni/android/graphics/BitmapRegionDecoder.cpp | 1 | ||||
-rw-r--r-- | core/jni/android/graphics/Graphics.cpp | 6 | ||||
-rw-r--r-- | graphics/java/android/graphics/ColorSpace.java | 2 | ||||
-rw-r--r-- | libs/hwui/GlopBuilder.cpp | 4 |
4 files changed, 9 insertions, 4 deletions
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp index 5022b22e8ea7..9355cfcdb0d3 100644 --- a/core/jni/android/graphics/BitmapRegionDecoder.cpp +++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp @@ -218,6 +218,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle, jint in // If we may have reused a bitmap, we need to indicate that the pixels have changed. if (javaBitmap) { recycleAlloc.copyIfNecessary(); + bitmap::reinitBitmap(env, javaBitmap, recycledBitmap->info(), !requireUnpremul); return javaBitmap; } diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index 452d0a941c7b..b11fd4fce714 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -658,7 +658,11 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // mRecycledBitmap->info() for the SkImageInfo. According to the // specification for BitmapRegionDecoder, we are not allowed to change // the SkImageInfo. - mRecycledBitmap->reconfigure(mRecycledBitmap->info(), rowBytes, ctable); + // We can (must) preserve the color space since it doesn't affect the + // storage needs + mRecycledBitmap->reconfigure( + mRecycledBitmap->info().makeColorSpace(bitmap->refColorSpace()), + rowBytes, ctable); // Give the bitmap the same pixelRef as mRecycledBitmap. // skbug.com/4538: We also need to make sure that the rowBytes on the pixel ref diff --git a/graphics/java/android/graphics/ColorSpace.java b/graphics/java/android/graphics/ColorSpace.java index 67504cfe323b..f2957a30b05e 100644 --- a/graphics/java/android/graphics/ColorSpace.java +++ b/graphics/java/android/graphics/ColorSpace.java @@ -1592,7 +1592,7 @@ public abstract class ColorSpace { Math.abs(a.a - b.a) < 1e-3 && Math.abs(a.b - b.b) < 1e-3 && Math.abs(a.c - b.c) < 1e-3 && - Math.abs(a.d - b.d) < 1e-3 && + Math.abs(a.d - b.d) < 2e-3 && // Special case for variations in sRGB OETF/EOTF Math.abs(a.e - b.e) < 1e-3 && Math.abs(a.f - b.f) < 1e-3 && Math.abs(a.g - b.g) < 1e-3; diff --git a/libs/hwui/GlopBuilder.cpp b/libs/hwui/GlopBuilder.cpp index 3e7a246bb281..931a55a70fd8 100644 --- a/libs/hwui/GlopBuilder.cpp +++ b/libs/hwui/GlopBuilder.cpp @@ -600,12 +600,12 @@ void verify(const ProgramDescription& description, const Glop& glop) { void GlopBuilder::build() { REQUIRE_STAGES(kAllStages); if (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) { - if (mOutGlop->fill.texture.texture->target() == GL_TEXTURE_2D) { + Texture* texture = mOutGlop->fill.texture.texture; + if (texture->target() == GL_TEXTURE_2D) { mDescription.hasTexture = true; } else { mDescription.hasExternalTexture = true; } - Texture* texture = mOutGlop->fill.texture.texture; mDescription.hasLinearTexture = texture->isLinear(); mDescription.hasColorSpaceConversion = texture->hasColorSpaceConversion(); mDescription.transferFunction = texture->getTransferFunctionType(); |