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

Unified Diff: tools/android/SkBitmapRegionCodec.cpp

Issue 1420053010: Make BRD take advantage of zero initialized memory (Closed) Base URL: https://skia.googlesource.com/skia.git@zero-init
Patch Set: Reduce scope of local variable Created 5 years, 1 month 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 | « tools/android/SkBitmapRegionCodec.h ('k') | tools/android/SkBitmapRegionDecoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/SkBitmapRegionCodec.cpp
diff --git a/tools/android/SkBitmapRegionCodec.cpp b/tools/android/SkBitmapRegionCodec.cpp
index 93ece4a59f9b983ae572adcd6956249982c479b3..7c3c2471b0cbf7db75e778b399709ac4d169a521 100644
--- a/tools/android/SkBitmapRegionCodec.cpp
+++ b/tools/android/SkBitmapRegionCodec.cpp
@@ -16,7 +16,7 @@ SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec)
, fCodec(codec)
{}
-bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* allocator,
+bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
bool requireUnpremul) {
@@ -104,10 +104,10 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* al
// TODO (msarett): Can we make this faster by implementing it to only
// zero parts of the image that we won't overwrite with
// pixels?
- // TODO (msarett): This could be skipped if memory is zero initialized.
- // This would matter if this code is moved to Android and
- // uses Android bitmaps.
- if (SubsetType::kPartiallyInside_SubsetType == type) {
+ SkCodec::ZeroInitialized zeroInit = allocator ? allocator->zeroInit() :
+ SkCodec::kNo_ZeroInitialized;
+ if (SubsetType::kPartiallyInside_SubsetType == type &&
+ SkCodec::kNo_ZeroInitialized == zeroInit) {
void* pixels = bitmap->getPixels();
size_t bytes = outInfo.getSafeSize(bitmap->rowBytes());
memset(pixels, 0, bytes);
@@ -119,6 +119,7 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* al
options.fSubset = ⊂
options.fColorPtr = colorPtr;
options.fColorCount = colorCountPtr;
+ options.fZeroInitialized = zeroInit;
void* dst = bitmap->getAddr(scaledOutX, scaledOutY);
// FIXME: skbug.com/4538
« no previous file with comments | « tools/android/SkBitmapRegionCodec.h ('k') | tools/android/SkBitmapRegionDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698