aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-04-21 11:42:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-21 16:09:12 +0000
commit71f9df224ee2fba93a5caeab3136a1f0b7723daf (patch)
tree0d8a6af67cae7ad2f28c7171f49a839d6f61e3da
parent54cbcd7056a1a56946f177059b1a5537f131271a (diff)
SkColorSpaceXformCanvas: Use when drawing picture images
The new code path is triggered by SkImage::makeColorSpace() when the image is picture backed. Fixes 3 gms in gbr-8888 config. Bug: skia:6516 Change-Id: I397903eb0f926834efd277f30265339518777920 Reviewed-on: https://skia-review.googlesource.com/14034 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
-rw-r--r--src/core/SkPictureImageGenerator.cpp20
-rw-r--r--src/core/SkPictureImageGenerator.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index a960001e13..34046e9ae4 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -7,6 +7,7 @@
#include "SkImage_Base.h"
#include "SkCanvas.h"
+#include "SkColorSpaceXformCanvas.h"
#include "SkMakeUnique.h"
#include "SkMatrix.h"
#include "SkPaint.h"
@@ -69,6 +70,25 @@ bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels,
return true;
}
+bool SkPictureImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ const Options& opts) {
+ // No need to use the xform canvas if we want fully color correct behavior or if we do not
+ // have a destination color space.
+ if (SkTransferFunctionBehavior::kRespect == opts.fBehavior || !info.colorSpace()) {
+ return this->onGetPixels(info, pixels, rowBytes, opts.fColorTable, opts.fColorTableCount);
+ }
+
+ auto canvas = SkCanvas::MakeRasterDirect(info.makeColorSpace(nullptr), pixels, rowBytes);
+ if (!canvas) {
+ return false;
+ }
+ canvas->clear(0);
+
+ auto xformCanvas = SkCreateColorSpaceXformCanvas(canvas.get(), info.refColorSpace());
+ xformCanvas->drawPicture(fPicture, &fMatrix, fPaint.getMaybeNull());
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
std::unique_ptr<SkImageGenerator>
diff --git a/src/core/SkPictureImageGenerator.h b/src/core/SkPictureImageGenerator.h
index 83872608a5..ed5e87cfe5 100644
--- a/src/core/SkPictureImageGenerator.h
+++ b/src/core/SkPictureImageGenerator.h
@@ -19,6 +19,8 @@ public:
protected:
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
int* ctableCount) override;
+ bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts)
+ override;
#if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&,