diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-10 14:44:56 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-10 14:44:56 +0000 |
commit | 0a6151d66cc32d91eca037c91e557158cf8a2be2 (patch) | |
tree | 7fe96285f9fee5c8804bbbc60dd0395b983511a0 /include | |
parent | b006fe7e2f6178ce076a5e2c76b4540d3d27ca98 (diff) |
Revert "Revert "change SkColorTable to be immutable""
This reverts commit b8162cb840f4cb6002ef68d5ac775c6a122c52a9.
Fixed was call-sites in benches that used the (now gone) setIsOpaque api.
R=scroggo@google.com
Review URL: https://codereview.chromium.org/26572006
git-svn-id: http://skia.googlecode.com/svn/trunk@11695 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkAlpha.h | 3 | ||||
-rw-r--r-- | include/core/SkBitmap.h | 4 | ||||
-rw-r--r-- | include/core/SkColorTable.h | 51 |
3 files changed, 23 insertions, 35 deletions
diff --git a/include/core/SkAlpha.h b/include/core/SkAlpha.h index 9e0fcab0e2..74ea687f96 100644 --- a/include/core/SkAlpha.h +++ b/include/core/SkAlpha.h @@ -47,4 +47,7 @@ enum SkAlphaType { kLastEnum_SkAlphaType = kUnpremul_SkAlphaType }; +static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) { + return (unsigned)at <= kOpaque_SkAlphaType; +} #endif diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 887169ccb5..07d2b95553 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -748,7 +748,7 @@ public: } ~SkAutoLockColors() { if (fCTable) { - fCTable->unlockColors(false); + fCTable->unlockColors(); } } @@ -762,7 +762,7 @@ public: */ const SkPMColor* lockColors(SkColorTable* ctable) { if (fCTable) { - fCTable->unlockColors(false); + fCTable->unlockColors(); } fCTable = ctable; fColors = ctable ? ctable->lockColors() : NULL; diff --git a/include/core/SkColorTable.h b/include/core/SkColorTable.h index f8d1ccf07b..c6e31b94d4 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, + 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); + 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() { 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(); /** Similar to lockColors(), lock16BitCache() returns the array of RGB16 colors that mirror the 32bit colors. However, this function @@ -100,7 +85,7 @@ private: SkPMColor* fColors; uint16_t* f16BitCache; uint16_t fCount; - uint8_t fFlags; + uint8_t fAlphaType; SkDEBUGCODE(int fColorLockCount;) SkDEBUGCODE(int f16BitCacheLockCount;) |