aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-12-14 10:44:35 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-14 16:35:01 +0000
commitd096e0d126bfe11aa33886124103ad128b807693 (patch)
treef7747fed36213c110aa7e38b125718928a24458d
parent10b814260a59927aa209cbee7b47f43aa0142e41 (diff)
quick-reject before transforming images
Transforming images is expensive, and pointless if they're clipped out. Bug: chromium:794690 Change-Id: Iffa4f6c60275caf310b8327e083b8857018621c2 Reviewed-on: https://skia-review.googlesource.com/85044 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
-rw-r--r--src/core/SkColorSpaceXformCanvas.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/core/SkColorSpaceXformCanvas.cpp b/src/core/SkColorSpaceXformCanvas.cpp
index 44b35f4e9e..b6d6c87aa1 100644
--- a/src/core/SkColorSpaceXformCanvas.cpp
+++ b/src/core/SkColorSpaceXformCanvas.cpp
@@ -139,26 +139,34 @@ 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()));
+ if (!fTarget->quickReject(SkRect::Make(img->bounds()).makeOffset(l,t))) {
+ fTarget->drawImage(prepareImage(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(),
- src ? *src : SkRect::MakeIWH(img->width(), img->height()), dst,
- MaybePaint(paint, fXformer.get()), constraint);
+ if (!fTarget->quickReject(dst)) {
+ fTarget->drawImageRect(prepareImage(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,
- MaybePaint(paint, fXformer.get()));
+ if (!fTarget->quickReject(dst)) {
+ fTarget->drawImageNine(prepareImage(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,
- MaybePaint(paint, fXformer.get()));
+ if (!fTarget->quickReject(dst)) {
+ fTarget->drawImageLattice(prepareImage(img).get(), lattice, dst,
+ MaybePaint(paint, fXformer.get()));
+ }
}
void onDrawAtlas(const SkImage* atlas, const SkRSXform* xforms, const SkRect* tex,
const SkColor* colors, int count, SkBlendMode mode,
@@ -173,6 +181,7 @@ public:
MaybePaint(paint, fXformer.get()));
}
+ // TODO: quick reject bitmap draw calls before transforming too?
void onDrawBitmap(const SkBitmap& bitmap,
SkScalar l, SkScalar t,
const SkPaint* paint) override {