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

Unified Diff: include/core/SkColorTable.h

Issue 25353002: change SkColorTable to be immutable (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months 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
Index: include/core/SkColorTable.h
diff --git a/include/core/SkColorTable.h b/include/core/SkColorTable.h
index f8d1ccf07b7a45325c7dcf7e01347316befa8724..75d2524fe228eec5be333a40c8d17fc65d1347a2 100644
--- a/include/core/SkColorTable.h
+++ b/include/core/SkColorTable.h
@@ -10,6 +10,7 @@
#ifndef SkColorTable_DEFINED
#define SkColorTable_DEFINED
+#include "SkAlpha.h"
#include "SkColor.h"
#include "SkFlattenable.h"
@@ -25,25 +26,15 @@ public:
/** Makes a deep copy of colors.
*/
SkColorTable(const SkColorTable& src);
- /** Preallocates the colortable to have 'count' colors, which
- * are initially set to 0.
- */
- explicit SkColorTable(int count);
- SkColorTable(const SkPMColor colors[], int count);
+ SkColorTable(const SkPMColor colors[], int count,
scroggo 2013/10/02 22:19:16 Comment that this makes a deep copy? (Or possibly
+ SkAlphaType alphaType = kPremul_SkAlphaType);
virtual ~SkColorTable();
- enum Flags {
- kColorsAreOpaque_Flag = 0x01 //!< if set, all of the colors in the table are opaque (alpha==0xFF)
- };
- /** Returns the flag bits for the color table. These can be changed with setFlags().
- */
- unsigned getFlags() const { return fFlags; }
- /** Set the flags for the color table. See the Flags enum for possible values.
- */
- void setFlags(unsigned flags);
scroggo 2013/10/02 21:16:27 We still have callers of setFlags and getFlags in
+ SkAlphaType alphaType() const { return (SkAlphaType)fAlphaType; }
- bool isOpaque() const { return (fFlags & kColorsAreOpaque_Flag) != 0; }
- void setIsOpaque(bool isOpaque);
+ bool isOpaque() const {
+ return SkAlphaTypeIsOpaque(this->alphaType());
+ }
/** Returns the number of colors in the table.
*/
@@ -57,25 +48,19 @@ public:
return fColors[index];
}
- /** Specify the number of colors in the color table. This does not initialize the colors
- to any value, just allocates memory for them. To initialize the values, either call
- setColors(array, count), or follow setCount(count) with a call to
- lockColors()/{set the values}/unlockColors(true).
- */
-// void setColors(int count) { this->setColors(NULL, count); }
-// void setColors(const SkPMColor[], int count);
-
- /** Return the array of colors for reading and/or writing. This must be
- balanced by a call to unlockColors(changed?), telling the colortable if
- the colors were changed during the lock.
- */
- SkPMColor* lockColors() {
+ /**
+ * Return the array of colors for reading. This must be balanced by a call
+ * to unlockColors().
+ */
+ const SkPMColor* lockColors() {
scroggo 2013/10/02 22:19:16 We'll need to update the image decoders' use of co
SkDEBUGCODE(sk_atomic_inc(&fColorLockCount);)
return fColors;
}
- /** Balancing call to lockColors(). If the colors have been changed, pass true.
- */
- void unlockColors(bool changed);
+
+ /**
+ * Balancing call to lockColors().
+ */
+ void unlockColors();
scroggo 2013/10/01 17:38:28 Callers need to be updated in src/images/SkImageDe
/** Similar to lockColors(), lock16BitCache() returns the array of
RGB16 colors that mirror the 32bit colors. However, this function
@@ -100,7 +85,8 @@ private:
SkPMColor* fColors;
uint16_t* f16BitCache;
uint16_t fCount;
- uint8_t fFlags;
+ uint8_t fAlphaType;
+ uint8_t fPad;
scroggo 2013/10/01 17:30:38 fPad is never used.
SkDEBUGCODE(int fColorLockCount;)
SkDEBUGCODE(int f16BitCacheLockCount;)
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkBitmap.cpp » ('j') | src/core/SkColorTable.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698