aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-28 16:05:39 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-28 16:05:39 +0000
commitc1587f94a77eaafe257a6ecf504364d40362c66a (patch)
tree64126ea39cdada39b348437f84edb860ee67d3bc
parenta96176dc0315d786c187bfa9be5dccf2f08feba2 (diff)
change setAlphaType to not modify the pixelref's genID
BUG=skia: R=bsalomon@google.com, halcanary@google.com Review URL: https://codereview.chromium.org/137263009 git-svn-id: http://skia.googlecode.com/svn/trunk@13219 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkBitmap.h5
-rw-r--r--include/core/SkPixelRef.h16
-rw-r--r--src/core/SkBitmap.cpp2
-rw-r--r--src/core/SkPixelRef.cpp7
4 files changed, 15 insertions, 15 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 1dd2c8034f..2cdac27bad 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -131,10 +131,7 @@ public:
*
* Note: this changes the alphatype for the underlying pixels, which means
* that all bitmaps that might be sharing (subsets of) the pixels will
- * be affected. This is an expensive change for some backends (e.g. GPU)
- * since changing the alphatype can invalidate internal caches. Thus this
- * call should only be made if it is associated with real changes to the
- * pixel data.
+ * be affected.
*/
bool setAlphaType(SkAlphaType);
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 62edc3ec95..5a9a5a05f7 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -130,15 +130,15 @@ public:
* Call this if you have changed the contents of the pixels. This will in-
* turn cause a different generation ID value to be returned from
* getGenerationID().
- *
- * If the alphatype has also changed, specify its new value as well. If
- * the new pixels' alphatype is the same, this can be called with no
- * parameter.
*/
- void notifyPixelsChanged(SkAlphaType);
- void notifyPixelsChanged() {
- this->notifyPixelsChanged(fInfo.fAlphaType);
- }
+ void notifyPixelsChanged();
+
+ /**
+ * Change the info's AlphaType. Note that this does not automatically
+ * invalidate the generation ID. If the pixel values themselves have
+ * changed, then you must explicitly call notifyPixelsChanged() as well.
+ */
+ void changeAlphaType(SkAlphaType at);
/** Returns true if this pixelref is marked as immutable, meaning that the
contents of its pixels will not change for the lifetime of the pixelref.
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 825b1dceca..e12840adab 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -324,7 +324,7 @@ bool SkBitmap::setAlphaType(SkAlphaType alphaType) {
if (fAlphaType != alphaType) {
fAlphaType = SkToU8(alphaType);
if (fPixelRef) {
- fPixelRef->notifyPixelsChanged(alphaType);
+ fPixelRef->changeAlphaType(alphaType);
}
}
return true;
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 507a4fcd48..d08796b18c 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -254,17 +254,20 @@ void SkPixelRef::callGenIDChangeListeners() {
fGenIDChangeListeners.deleteAll();
}
-void SkPixelRef::notifyPixelsChanged(SkAlphaType at) {
+void SkPixelRef::notifyPixelsChanged() {
#ifdef SK_DEBUG
if (fIsImmutable) {
SkDebugf("========== notifyPixelsChanged called on immutable pixelref");
}
#endif
- *const_cast<SkAlphaType*>(&fInfo.fAlphaType) = at;
this->callGenIDChangeListeners();
this->needsNewGenID();
}
+void SkPixelRef::changeAlphaType(SkAlphaType at) {
+ *const_cast<SkAlphaType*>(&fInfo.fAlphaType) = at;
+}
+
void SkPixelRef::setImmutable() {
fIsImmutable = true;
}