aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-06-08 09:16:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-08 09:16:54 -0700
commit0963f5dab079627c5523ce6a443af27a33e361f7 (patch)
treea500e299303532d888a7518982ac3b9e545a6d83 /include
parent28937843f49b3015e9f4c04e04eb2604c3f873cf (diff)
move erase into SkPixmap
Diffstat (limited to 'include')
-rw-r--r--include/core/SkBitmap.h20
-rw-r--r--include/core/SkPixmap.h34
2 files changed, 44 insertions, 10 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index c070203d04..b13b6f7451 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -473,10 +473,7 @@ public:
* of the color is ignored (treated as opaque). If the colortype only supports
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
*/
- void eraseColor(SkColor c) const {
- this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c),
- SkColorGetB(c));
- }
+ void eraseColor(SkColor c) const;
/**
* Fill the entire bitmap with the specified color.
@@ -484,7 +481,9 @@ public:
* of the color is ignored (treated as opaque). If the colortype only supports
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
*/
- void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const;
+ void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const {
+ this->eraseColor(SkColorSetARGB(a, r, g, b));
+ }
SK_ATTR_DEPRECATED("use eraseARGB or eraseColor")
void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const {
@@ -497,7 +496,12 @@ public:
* of the color is ignored (treated as opaque). If the colortype only supports
* alpha (e.g. A1 or A8) then the color's r,g,b components are ignored.
*/
- void eraseArea(const SkIRect& area, SkColor c) const;
+ void erase(SkColor c, const SkIRect& area) const;
+
+ // DEPRECATED
+ void eraseArea(const SkIRect& area, SkColor c) const {
+ this->erase(c, area);
+ }
/**
* Return the SkColor of the specified pixel. In most cases this will
@@ -736,13 +740,9 @@ private:
};
SkImageInfo fInfo;
-
uint32_t fRowBytes;
-
uint8_t fFlags;
- void internalErase(const SkIRect&, U8CPU a, U8CPU r, U8CPU g, U8CPU b)const;
-
/* Unreference any pixelrefs or colortables
*/
void freePixels();
diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h
index 913d007c4d..a32b40c58d 100644
--- a/include/core/SkPixmap.h
+++ b/include/core/SkPixmap.h
@@ -133,6 +133,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 +173,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;
};
/////////////////////////////////////////////////////////////////////////////////////////////