aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-01-10 14:35:35 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-11 19:17:31 +0000
commit7c4ca043361f6adb3d17a9d3db2397d86bac5a2d (patch)
treee58f4495f746932fa25c5dec396cb7e32bc2d04d
parentdeb7998834245983ae89b776256d47c2eeb39192 (diff)
fix legacy makeRasterImage()
Passing the color space down into SkImage_Lazy ends up triggering a SkTransferFunctionBehavior::kRespect decode (tf(r*a)), where we want ignore (tf(r)*a) to have any hope of working with the legacy backend. This fix in turn needs another little extension of another old hack in SkImage_Gpu for makeNonTextureImage() to keep working there. Bug: skia:7479 Change-Id: If48ca68e95d9eee597f6b10434498049981314ba Reviewed-on: https://skia-review.googlesource.com/93380 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
-rw-r--r--gm/makeRasterImage.cpp15
-rw-r--r--gn/gm.gni1
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkImage_Gpu.cpp8
4 files changed, 23 insertions, 3 deletions
diff --git a/gm/makeRasterImage.cpp b/gm/makeRasterImage.cpp
new file mode 100644
index 0000000000..06c1af1d8c
--- /dev/null
+++ b/gm/makeRasterImage.cpp
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Resources.h"
+#include "SkSurface.h"
+#include "gm.h"
+
+DEF_SIMPLE_GM(makeRasterImage, canvas, 128,128) {
+ auto img = GetResourceAsImage("images/color_wheel.png");
+ canvas->drawImage(img->makeRasterImage(), 0,0);
+}
diff --git a/gn/gm.gni b/gn/gm.gni
index 25c80bf886..418957f34d 100644
--- a/gn/gm.gni
+++ b/gn/gm.gni
@@ -204,6 +204,7 @@ gm_sources = [
"$_gm/localmatriximageshader.cpp",
"$_gm/lumafilter.cpp",
"$_gm/makecolorspace.cpp",
+ "$_gm/makeRasterImage.cpp",
"$_gm/manypaths.cpp",
"$_gm/matrixconvolution.cpp",
"$_gm/matriximagefilter.cpp",
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index e618f7f454..b5d68bf865 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -334,7 +334,7 @@ sk_sp<SkImage> SkImage::makeRasterImage() const {
}
sk_sp<SkData> data = SkData::MakeUninitialized(size);
- pm = { info, data->writable_data(), info.minRowBytes() };
+ pm = { info.makeColorSpace(nullptr), data->writable_data(), info.minRowBytes() };
if (!this->readPixels(pm, 0, 0)) {
return nullptr;
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index a47587f1bc..e70ba05be5 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -211,9 +211,13 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
// with arbitrary color spaces. Unfortunately, this is one spot where we go from image to
// surface (rather than the opposite), and our lenient image rules break our (currently) more
// strict surface rules.
+ // We treat null-dst color space as always equal to fColorSpace for this kind of read-back.
sk_sp<SkColorSpace> surfaceColorSpace = fColorSpace;
- if (!flags && SkColorSpace::Equals(fColorSpace.get(), dstInfo.colorSpace())) {
- surfaceColorSpace = nullptr;
+ if (!flags) {
+ if (!dstInfo.colorSpace() ||
+ SkColorSpace::Equals(fColorSpace.get(), dstInfo.colorSpace())) {
+ surfaceColorSpace = nullptr;
+ }
}
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(