Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: src/core/SkDraw.cpp

Issue 2389973003: Avoid unneeded paint copies in SkDraw::drawBitmap (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 34c7d73b3ed1852342ad7a924ccc7a8a698b04fb..53c8e5f0e886a7f93a217213cb5b36ee4571ab52 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1302,8 +1302,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);
@@ -1313,7 +1315,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.
@@ -1328,7 +1330,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);
@@ -1344,9 +1346,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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698