From afb0bd4f447c3c58007ced563f31b3e856346d3b Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 5 Sep 2017 21:06:47 +0000 Subject: Revert "Optimize SkColorSpaceXformCanvas for GPU-acceleration" This reverts commit 19c8726a0829e506c5c42d22d67b3fe7505ed24e. Reason for revert: Breaking Chrome roll Original change's description: > Optimize SkColorSpaceXformCanvas for GPU-acceleration > > This change ensures that SkImages are uploaded to the GPU before > applying the xform when the destination canvas is on the GPU. This > makes it possible to get hits in the texture cache and it ensure > that transforms get computed on the GPU. > > This fixes a severe performance regression in Chrome that happened > when color correction was enabled. > > BUG=chromium:760738 > > Change-Id: I52032a9f06ccbe1a7fd56a91db15377925143b26 > Reviewed-on: https://skia-review.googlesource.com/42422 > Reviewed-by: Brian Osman > Commit-Queue: Justin Novosad TBR=brianosman@google.com,junov@chromium.org Change-Id: Ia117d6f95c34324383aaf3bfc990bb13e48bed6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:760738 Reviewed-on: https://skia-review.googlesource.com/42720 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- src/core/SkColorSpaceXformCanvas.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/core/SkColorSpaceXformCanvas.cpp b/src/core/SkColorSpaceXformCanvas.cpp index 4e1b75b117..6d6d27b399 100644 --- a/src/core/SkColorSpaceXformCanvas.cpp +++ b/src/core/SkColorSpaceXformCanvas.cpp @@ -139,25 +139,25 @@ public: void onDrawImage(const SkImage* img, SkScalar l, SkScalar t, const SkPaint* paint) override { - fTarget->drawImage(prepareImage(img).get(), l, t, MaybePaint(paint, fXformer.get())); + fTarget->drawImage(fXformer->apply(img).get(), l, t, MaybePaint(paint, fXformer.get())); } void onDrawImageRect(const SkImage* img, const SkRect* src, const SkRect& dst, const SkPaint* paint, SrcRectConstraint constraint) override { - fTarget->drawImageRect(prepareImage(img).get(), + fTarget->drawImageRect(fXformer->apply(img).get(), src ? *src : SkRect::MakeIWH(img->width(), img->height()), dst, MaybePaint(paint, fXformer.get()), constraint); } void onDrawImageNine(const SkImage* img, const SkIRect& center, const SkRect& dst, const SkPaint* paint) override { - fTarget->drawImageNine(prepareImage(img).get(), center, dst, + fTarget->drawImageNine(fXformer->apply(img).get(), center, dst, MaybePaint(paint, fXformer.get())); } void onDrawImageLattice(const SkImage* img, const Lattice& lattice, const SkRect& dst, const SkPaint* paint) override { - fTarget->drawImageLattice(prepareImage(img).get(), lattice, dst, + fTarget->drawImageLattice(fXformer->apply(img).get(), lattice, dst, MaybePaint(paint, fXformer.get())); } void onDrawAtlas(const SkImage* atlas, const SkRSXform* xforms, const SkRect* tex, @@ -169,7 +169,7 @@ public: fXformer->apply(xformed.begin(), colors, count); colors = xformed.begin(); } - fTarget->drawAtlas(prepareImage(atlas).get(), xforms, tex, colors, count, mode, cull, + fTarget->drawAtlas(fXformer->apply(atlas).get(), xforms, tex, colors, count, mode, cull, MaybePaint(paint, fXformer.get())); } @@ -308,20 +308,6 @@ public: void onFlush() override { return fTarget->flush(); } private: - sk_sp prepareImage(const SkImage* image) { - GrContext* gr = fTarget->getGrContext(); - if (gr) { - // If fTarget is GPU-accelerated, we want to upload to a texture - // before applying the transform. This way, we can get cache hits - // in the texture cache and the transform gets applied on the GPU. - return fXformer->apply(image->makeTextureImage(gr, nullptr).get()); - } - // TODO: Extract a sub image corresponding to the src rect in order - // to xform only the useful part of the image. Sub image could be reduced - // even further by taking into account dst_rect+ctm+clip - return fXformer->apply(image); - } - bool skipXform(const SkBitmap& bitmap) { return (!bitmap.colorSpace() && fTargetCS->isSRGB()) || (SkColorSpace::Equals(bitmap.colorSpace(), fTargetCS.get())) || -- cgit v1.2.3