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

Unified Diff: src/core/SkBitmapDevice.cpp

Issue 2216403002: use SkMakeBitmapShader to not force copies when possible (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/SkBitmapDevice.cpp
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 21601f40372b004dea942545abc812789de67fa9..86bb49e69bef3175e17484b4f6094af0cef14c22 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -322,9 +322,14 @@ void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
}
USE_SHADER:
+
+ // Since the shader need only live for our stack-frame, pass in a custom allocator. This
+ // can save malloc calls, and signals to SkMakeBitmapShader to not try to copy the bitmap
+ // if its mutable, since that precaution is not needed (give the short lifetime of the shader).
+ SkTBlitterAllocator allocator;
mtklein 2016/08/05 15:46:43 Perhaps as a follow up, I think this signal wants
f(malita) 2016/08/05 15:52:50 We already have ForceCopyMode for SkImageShader::M
reed1 2016/08/05 16:45:12 It is actually used to avoid mallocs when we alloc
// construct a shader, so we can call drawRect with the dst
- auto s = SkShader::MakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode, &matrix);
+ auto s = SkMakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
+ &matrix, &allocator);
if (!s) {
return;
}
« 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