aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapDevice.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-04-16 14:29:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-16 19:09:50 +0000
commit888fc05ef08971628a3b3044b7a99ec3dd53c386 (patch)
tree5d60a2d984627e4a8a17d49be84d79415b0a2922 /src/core/SkBitmapDevice.cpp
parent945918714b22a5a8365bca8f7e95d9519c3e2c6c (diff)
optimize fast/simple case in raster tiling
1. We want to avoid as much overhead as possible in the tiler setup, so do a quick check before handling bounds 2. Compare against current clipbounds instead of devicesize, which may eliminate looping sometimes Follow-on to https://skia-review.googlesource.com/c/skia/+/119570 Bug: 818693 Bug: 820245 Bug: 820470 Change-Id: If34721c7e467d1ab9e879f25e7b86af6732ca384 Reviewed-on: https://skia-review.googlesource.com/121329 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core/SkBitmapDevice.cpp')
-rw-r--r--src/core/SkBitmapDevice.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 9d52334685..f50ce9e582 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -72,21 +72,26 @@ public:
fRootPixmap.reset(dev->imageInfo(), nullptr, 0);
}
- if (bounds) {
- SkRect devBounds;
- dev->ctm().mapRect(&devBounds, *bounds);
- if (devBounds.intersect(SkRect::MakeIWH(fRootPixmap.width(), fRootPixmap.height()))) {
- fSrcBounds = devBounds.roundOut();
+ // do a quick check, so we don't even have to process "bounds" if there is no need
+ const SkIRect clipR = dev->fRCStack.rc().getBounds();
+ fNeedsTiling = clipR.right() > kMaxDim || clipR.bottom() > kMaxDim;
+ if (fNeedsTiling) {
+ if (bounds) {
+ SkRect devBounds;
+ dev->ctm().mapRect(&devBounds, *bounds);
+ if (devBounds.intersect(SkRect::Make(clipR))) {
+ fSrcBounds = devBounds.roundOut();
+ } else {
+ fNeedsTiling = false;
+ fDone = true;
+ }
+ // Check again, now that we have computed srcbounds.
+ fNeedsTiling = fSrcBounds.right() > kMaxDim || fSrcBounds.bottom() > kMaxDim;
} else {
- fDone = true;
+ fSrcBounds = clipR;
}
- } else {
- fSrcBounds = SkIRect::MakeWH(fRootPixmap.width(), fRootPixmap.height());
}
- fNeedsTiling = !fRootPixmap.bounds().isEmpty() && // empty pixmap map fail extractSubset?
- (fRootPixmap.width() > kMaxDim || fRootPixmap.height() > kMaxDim);
-
if (fNeedsTiling) {
// fDraw.fDst is reset each time in setupTileDraw()
fDraw.fMatrix = &fTileMatrix;
@@ -94,6 +99,7 @@ public:
// we'll step/increase it before using it
fOrigin.set(fSrcBounds.fLeft - kMaxDim, fSrcBounds.fTop);
} else {
+ // don't reference fSrcBounds, as it may not have been set
fDraw.fDst = fRootPixmap;
fDraw.fMatrix = &dev->ctm();
fDraw.fRC = &dev->fRCStack.rc();
@@ -123,9 +129,6 @@ public:
return &fDraw;
}
- int curr_x() const { return fOrigin.x(); }
- int curr_y() const { return fOrigin.y(); }
-
private:
void stepAndSetupTileDraw() {
SkASSERT(!fDone);
@@ -165,8 +168,6 @@ private:
while (const SkDraw* priv_draw = priv_tiler.next()) { \
priv_draw->code; \
}
-#define TILER_X(x) (x) - priv_tiler.curr_x()
-#define TILER_Y(y) (y) - priv_tiler.curr_y()
// Helper to create an SkDraw from a device
class SkBitmapDevice::BDDraw : public SkDraw {