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

Unified Diff: include/core/SkMallocPixelRef.h

Issue 1430593007: For non-opaque SkBitmapDevices, replace malloc-then-zero with calloc. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMallocPixelRef.h
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index 1baceae1667fad1a772292dabb301afe6d23c08a..ab337b9241ec72a9364b0d35cbbe70f257b45fc0 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -43,6 +43,12 @@ public:
size_t rowBytes, SkColorTable*);
/**
+ * Identical to NewAllocate, except all pixel bytes are zeroed.
+ */
+ static SkMallocPixelRef* NewZeroed(const SkImageInfo& info,
+ size_t rowBytes, SkColorTable*);
+
+ /**
* Return a new SkMallocPixelRef with the provided pixel storage,
* rowBytes, and optional colortable. On destruction, ReleaseProc
* will be called.
@@ -81,9 +87,12 @@ public:
class PRFactory : public SkPixelRefFactory {
public:
- virtual SkPixelRef* create(const SkImageInfo&,
- size_t rowBytes,
- SkColorTable*) override;
+ SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable*) override;
+ };
+
+ class ZeroedPRFactory : public SkPixelRefFactory {
+ public:
+ SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable*) override;
};
protected:
@@ -97,6 +106,12 @@ protected:
size_t getAllocatedSizeInBytes() const override;
private:
+ // Uses alloc to implement NewAllocate or NewZeroed.
+ static SkMallocPixelRef* NewUsing(void*(*alloc)(size_t),
+ const SkImageInfo&,
+ size_t rowBytes,
+ SkColorTable*);
+
void* fStorage;
SkColorTable* fCTable;
size_t fRB;
« no previous file with comments | « no previous file | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698