use scratch path to save on mallocs in drawAtlas

20% savings on drawAtlas with rotated content

Change-Id: I928de590629c9f1ea41e9053041095922cab3efc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239917
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-09-06 09:58:14 -04:00 committed by Skia Commit-Bot
parent bf8bf83642
commit 43ad1a4e30

View File

@ -20,16 +20,16 @@
#include "src/core/SkScan.h"
static void fill_rect(const SkMatrix& ctm, const SkRasterClip& rc,
const SkRect& r, SkBlitter* blitter) {
const SkRect& r, SkBlitter* blitter, SkPath* scratchPath) {
if (ctm.rectStaysRect()) {
SkRect dr;
ctm.mapRect(&dr, r);
SkScan::FillRect(dr, rc, blitter);
} else {
SkPath path;
path.addRect(r);
path.transform(ctm);
SkScan::FillPath(path, rc, blitter);
scratchPath->rewind();
scratchPath->addRect(r);
scratchPath->transform(ctm);
SkScan::FillPath(*scratchPath, rc, blitter);
}
}
@ -97,6 +97,7 @@ void SkDraw::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRe
}
auto blitter = SkCreateRasterPipelineBlitter(fDst, p, pipeline, isOpaque, &alloc);
SkPath scratchPath;
for (int i = 0; i < count; ++i) {
if (colors) {
@ -111,6 +112,6 @@ void SkDraw::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRe
mx.postConcat(*fMatrix);
updator->update(mx, nullptr);
fill_rect(mx, *fRC, textures[i], blitter);
fill_rect(mx, *fRC, textures[i], blitter, &scratchPath);
}
}