Chromium Code Reviews| Index: include/core/SkColorTable.h |
| diff --git a/include/core/SkColorTable.h b/include/core/SkColorTable.h |
| index 20d18d26143530b90db3b3d9ec9a9b56b267a84b..c8cc3d0fb43a5ef1d662819c28d1767bf877fc60 100644 |
| --- a/include/core/SkColorTable.h |
| +++ b/include/core/SkColorTable.h |
| @@ -13,19 +13,19 @@ |
| #include "SkColor.h" |
| #include "SkFlattenable.h" |
| #include "SkImageInfo.h" |
| +#include "SkLazyPtr.h" |
| /** \class SkColorTable |
| SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by |
| 8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable. |
| + |
| + SkColorTable is thread-safe. |
| */ |
| class SK_API SkColorTable : public SkRefCnt { |
| public: |
| SK_DECLARE_INST_COUNT(SkColorTable) |
| - /** Makes a deep copy of colors. |
| - */ |
| - SkColorTable(const SkColorTable& src); |
| SkColorTable(const SkPMColor colors[], int count); |
| virtual ~SkColorTable(); |
| @@ -41,23 +41,23 @@ public: |
| return fColors[index]; |
| } |
| - // TODO: Would making the read() methods const allow us to avoid copies? |
| - |
| /** Return the array of colors for reading. |
| */ |
| - const SkPMColor* readColors() { return fColors; } |
| + const SkPMColor* readColors() const { return fColors; } |
| /** read16BitCache() returns the array of RGB16 colors that mirror the 32bit colors. |
| */ |
| - const uint16_t* read16BitCache(); |
| + const uint16_t* read16BitCache() const; |
| explicit SkColorTable(SkReadBuffer&); |
| void writeToBuffer(SkWriteBuffer&) const; |
| private: |
| - SkPMColor* fColors; |
| - uint16_t* f16BitCache; |
| - int fCount; |
| + static void Free16BitCache(uint16_t* cache) { sk_free(cache); } |
| + |
| + SkPMColor* fColors; |
| + SkLazyPtr<uint16_t, Free16BitCache> f16BitCache; |
| + int fCount; |
|
reed1
2014/12/02 17:46:31
can we make fColors and fCount const?
mtklein
2014/12/02 17:51:18
Maybe, but it'll be an awkward enough rewrite of S
|
| void init(const SkPMColor* colors, int count); |