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

Unified Diff: include/core/SkColorTable.h

Issue 769323002: Make SkColorTable explicitly thread-safe. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698