| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkColorTable_DEFINED | 10 #ifndef SkColorTable_DEFINED |
| 11 #define SkColorTable_DEFINED | 11 #define SkColorTable_DEFINED |
| 12 | 12 |
| 13 #include "../private/SkOncePtr.h" |
| 13 #include "SkColor.h" | 14 #include "SkColor.h" |
| 14 #include "SkFlattenable.h" | 15 #include "SkFlattenable.h" |
| 15 #include "SkImageInfo.h" | 16 #include "SkImageInfo.h" |
| 16 #include "SkLazyPtr.h" | |
| 17 | 17 |
| 18 /** \class SkColorTable | 18 /** \class SkColorTable |
| 19 | 19 |
| 20 SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by | 20 SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by |
| 21 8-bit bitmaps, where the bitmap bytes are interpreted as indices into the co
lortable. | 21 8-bit bitmaps, where the bitmap bytes are interpreted as indices into the co
lortable. |
| 22 | 22 |
| 23 SkColorTable is thread-safe. | 23 SkColorTable is thread-safe. |
| 24 */ | 24 */ |
| 25 class SK_API SkColorTable : public SkRefCnt { | 25 class SK_API SkColorTable : public SkRefCnt { |
| 26 public: | 26 public: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 /** read16BitCache() returns the array of RGB16 colors that mirror the 32bit
colors. | 48 /** read16BitCache() returns the array of RGB16 colors that mirror the 32bit
colors. |
| 49 */ | 49 */ |
| 50 const uint16_t* read16BitCache() const; | 50 const uint16_t* read16BitCache() const; |
| 51 | 51 |
| 52 void writeToBuffer(SkWriteBuffer&) const; | 52 void writeToBuffer(SkWriteBuffer&) const; |
| 53 | 53 |
| 54 // may return null | 54 // may return null |
| 55 static SkColorTable* Create(SkReadBuffer&); | 55 static SkColorTable* Create(SkReadBuffer&); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 static void Free16BitCache(uint16_t*); | |
| 59 | |
| 60 enum AllocatedWithMalloc { | 58 enum AllocatedWithMalloc { |
| 61 kAllocatedWithMalloc | 59 kAllocatedWithMalloc |
| 62 }; | 60 }; |
| 63 // assumes ownership of colors (assumes it was allocated w/ malloc) | 61 // assumes ownership of colors (assumes it was allocated w/ malloc) |
| 64 SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc); | 62 SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc); |
| 65 | 63 |
| 64 struct Free16BitCache { void operator()(uint16_t* cache) const { sk_free(cac
he); } }; |
| 65 |
| 66 SkPMColor* fColors; | 66 SkPMColor* fColors; |
| 67 SkLazyPtr<uint16_t, Free16BitCache> f16BitCache; | 67 SkOncePtr<uint16_t, Free16BitCache> f16BitCache; |
| 68 int fCount; | 68 int fCount; |
| 69 | 69 |
| 70 void init(const SkPMColor* colors, int count); | 70 void init(const SkPMColor* colors, int count); |
| 71 | 71 |
| 72 typedef SkRefCnt INHERITED; | 72 typedef SkRefCnt INHERITED; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 #endif | 75 #endif |
| OLD | NEW |