aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-10-03 13:46:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-03 13:46:58 -0700
commitf85d2a4fa1b71e6ee28518431e2a34df5683bc81 (patch)
tree864ca4d4bd44f1a7f9d688c2ca94d22d4ef643df /src/core
parentd368211a2a98125ba0dc29ce8bcaf28bfc65c358 (diff)
Avoid unneeded paint copies in SkDraw::drawBitmap
Use SkTCopyOnFirstWrite to only copy when needed. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2389973003 Review-Url: https://codereview.chromium.org/2389973003
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkDraw.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index c6c5cf3c81..2a88781e48 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1299,8 +1299,10 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
return;
}
- SkPaint paint(origPaint);
- paint.setStyle(SkPaint::kFill_Style);
+ SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
+ if (origPaint.getStyle() != SkPaint::kFill_Style) {
+ paint.writable()->setStyle(SkPaint::kFill_Style);
+ }
SkMatrix matrix;
matrix.setConcat(*fMatrix, prematrix);
@@ -1310,7 +1312,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
}
if (bitmap.colorType() != kAlpha_8_SkColorType
- && SkTreatAsSprite(matrix, bitmap.dimensions(), paint)) {
+ && SkTreatAsSprite(matrix, bitmap.dimensions(), *paint)) {
//
// It is safe to call lock pixels now, since we know the matrix is
// (more or less) identity.
@@ -1325,7 +1327,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
if (clipHandlesSprite(*fRC, ix, iy, pmap)) {
SkTBlitterAllocator allocator;
// blitter will be owned by the allocator.
- SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, ix, iy, &allocator);
+ SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, *paint, pmap, ix, iy, &allocator);
if (blitter) {
SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.height()),
*fRC, blitter);
@@ -1341,9 +1343,9 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
draw.fMatrix = &matrix;
if (bitmap.colorType() == kAlpha_8_SkColorType) {
- draw.drawBitmapAsMask(bitmap, paint);
+ draw.drawBitmapAsMask(bitmap, *paint);
} else {
- SkAutoBitmapShaderInstall install(bitmap, paint);
+ SkAutoBitmapShaderInstall install(bitmap, *paint);
const SkPaint& paintWithShader = install.paintWithShader();
const SkRect srcBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height());
if (dstBounds) {