aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkPixmap.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-06-08 10:22:22 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-08 10:22:22 -0700
commit7aefe0321122d92393d30ddc44fb76e4744f34bf (patch)
tree58996cbf56f33ec3654b44f78eff3ea09163c575 /include/core/SkPixmap.h
parentcca9b3ac908cf3e9a0c5774a5ffd118d8429e08a (diff)
Revert "Revert of move erase into SkPixmap (patchset #1 id:1 of https://codereview.chromium.org/1161033005/)"
Diffstat (limited to 'include/core/SkPixmap.h')
-rw-r--r--include/core/SkPixmap.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h
index 913d007c4d..05c7101735 100644
--- a/include/core/SkPixmap.h
+++ b/include/core/SkPixmap.h
@@ -8,6 +8,7 @@
#ifndef SkPixmap_DEFINED
#define SkPixmap_DEFINED
+#include "SkColor.h"
#include "SkImageInfo.h"
class SkColorTable;
@@ -133,6 +134,14 @@ public:
return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), 0, 0);
}
+ /**
+ * Returns true if pixels were written to (e.g. if colorType is kUnknown_SkColorType, this
+ * will return false). If subset does not intersect the bounds of this pixmap, returns false.
+ */
+ bool erase(SkColor, const SkIRect& subset) const;
+
+ bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
+
private:
const void* fPixels;
SkColorTable* fCTable;
@@ -165,8 +174,34 @@ public:
*/
void alloc(const SkImageInfo&);
+ // We wrap these so we can clear our internal storage
+
+ void reset() {
+ this->freeStorage();
+ this->INHERITED::reset();
+ }
+ void reset(const SkImageInfo& info, const void* addr, size_t rb, SkColorTable* ctable = NULL) {
+ this->freeStorage();
+ this->INHERITED::reset(info, addr, rb, ctable);
+ }
+ void reset(const SkImageInfo& info) {
+ this->freeStorage();
+ this->INHERITED::reset(info);
+ }
+ bool SK_WARN_UNUSED_RESULT reset(const SkMask& mask) {
+ this->freeStorage();
+ return this->INHERITED::reset(mask);
+ }
+
private:
void* fStorage;
+
+ void freeStorage() {
+ sk_free(fStorage);
+ fStorage = NULL;
+ }
+
+ typedef SkPixmap INHERITED;
};
/////////////////////////////////////////////////////////////////////////////////////////////