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>
This commit is contained in:
Mike Reed 2018-04-16 14:29:49 -04:00 committed by Skia Commit-Bot
parent 945918714b
commit 888fc05ef0

View File

@ -72,20 +72,25 @@ public:
fRootPixmap.reset(dev->imageInfo(), nullptr, 0);
}
// 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::MakeIWH(fRootPixmap.width(), fRootPixmap.height()))) {
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 {
fSrcBounds = SkIRect::MakeWH(fRootPixmap.width(), fRootPixmap.height());
fSrcBounds = clipR;
}
}
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()
@ -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 {