aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureImageGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Christopher Cameron <ccameron@chromium.org>2017-07-08 01:47:47 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-10 17:45:28 +0000
commit77e966647f6b495fe44772086c709528c711fc6e (patch)
treeab864785bf834f2743537c662fe90a4bb592ba39 /src/core/SkPictureImageGenerator.cpp
parent62ae664e7491f77e1746a42418661c20c256c26d (diff)
Make SkImage_Lazy::onMakeColorSpace return a SkImage_Lazy
Make SkImage_Lazy::onMakeColorSpace return a new SkImage_Lazy with the color space of SkImage_Lazy::fInfo changed. Update the call to SkImageGenerator::getPixels to specify image info with this new color space. Update the call to SkImageGenerator::generateTexture to specify this new color space. Update SkPictureImageGenerator to respect the color space argument. Add a SkTransferFunctionBehavior argument to SkImageGenerator::generateTexture to indicate if color conversion is to be doing using an xform canvas. Update Generator_GrYUVProvider::refAsTextureProxy to include a color conversion step to respect this new color space. TBR=reed@google.com Bug:739559 Change-Id: I156a858884659e9dfae739a653bab2ef89274959 Reviewed-on: https://skia-review.googlesource.com/21605 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Christopher Cameron <ccameron@chromium.org> Reviewed-by: Christopher Cameron <ccameron@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core/SkPictureImageGenerator.cpp')
-rw-r--r--src/core/SkPictureImageGenerator.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index 86e98d828b..1f60380b8d 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -100,23 +100,32 @@ SkImageGenerator::MakeFromPicture(const SkISize& size, sk_sp<SkPicture> picture,
///////////////////////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(GrContext* ctx,
- const SkImageInfo& info,
- const SkIPoint& origin) {
+sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(
+ GrContext* ctx, const SkImageInfo& info, const SkIPoint& origin,
+ SkTransferFunctionBehavior behavior) {
SkASSERT(ctx);
+ bool useXformCanvas = SkTransferFunctionBehavior::kIgnore == behavior && info.colorSpace();
//
// TODO: respect the usage, by possibly creating a different (pow2) surface
//
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, info));
+ SkImageInfo surfaceInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
+ sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo));
if (!surface) {
return nullptr;
}
+ SkCanvas* canvas = surface->getCanvas();
+ std::unique_ptr<SkCanvas> xformCanvas;
+ if (useXformCanvas) {
+ xformCanvas = SkCreateColorSpaceXformCanvas(canvas, info.refColorSpace());
+ canvas = xformCanvas.get();
+ }
+
SkMatrix matrix = fMatrix;
matrix.postTranslate(-origin.x(), -origin.y());
- surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this for us?
- surface->getCanvas()->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
+ canvas->clear(0); // does NewRenderTarget promise to do this for us?
+ canvas->drawPicture(fPicture.get(), &matrix, fPaint.getMaybeNull());
sk_sp<SkImage> image(surface->makeImageSnapshot());
if (!image) {
return nullptr;