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

Side by Side Diff: include/core/SkColorTable.h

Issue 719213008: SkColorTable locking serves no purpose anymore. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: oops 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 unified diff | Download patch
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 SK_DECLARE_INST_COUNT(SkColorTable) 24 SK_DECLARE_INST_COUNT(SkColorTable)
25 25
26 /** Makes a deep copy of colors. 26 /** Makes a deep copy of colors.
27 */ 27 */
28 SkColorTable(const SkColorTable& src); 28 SkColorTable(const SkColorTable& src);
29 SkColorTable(const SkPMColor colors[], int count); 29 SkColorTable(const SkPMColor colors[], int count);
30 virtual ~SkColorTable(); 30 virtual ~SkColorTable();
31 31
32 /** Returns the number of colors in the table. 32 /** Returns the number of colors in the table.
33 */ 33 */
34 int count() const { return fCount; } 34 int count() const { return fCount; }
35 35
36 /** Returns the specified color from the table. In the debug build, this ass erts that 36 /** Returns the specified color from the table. In the debug build, this ass erts that
37 the index is in range (0 <= index < count). 37 * the index is in range (0 <= index < count).
38 */ 38 */
39 SkPMColor operator[](int index) const { 39 SkPMColor operator[](int index) const {
40 SkASSERT(fColors != NULL && (unsigned)index < (unsigned)fCount); 40 SkASSERT(fColors != NULL && (unsigned)index < (unsigned)fCount);
41 return fColors[index]; 41 return fColors[index];
42 } 42 }
43 43
44 /** 44 // TODO: Would making the read() methods const allow us to avoid copies?
45 * Return the array of colors for reading. This must be balanced by a call 45
46 * to unlockColors(). 46 /** Return the array of colors for reading.
47 */ 47 */
48 const SkPMColor* lockColors() { 48 const SkPMColor* readColors() { return fColors; }
49 SkDEBUGCODE(sk_atomic_inc(&fColorLockCount);)
50 return fColors;
51 }
52 49
53 /** 50 /** read16BitCache() returns the array of RGB16 colors that mirror the 32bit colors.
54 * Balancing call to lockColors().
55 */ 51 */
56 void unlockColors(); 52 const uint16_t* read16BitCache();
57
58 /** Similar to lockColors(), lock16BitCache() returns the array of
59 RGB16 colors that mirror the 32bit colors. However, this function
60 will return null if kColorsAreOpaque_Flag is not set.
61 Also, unlike lockColors(), the returned array here cannot be modified.
62 */
63 const uint16_t* lock16BitCache();
64 /** Balancing call to lock16BitCache().
65 */
66 void unlock16BitCache() {
67 SkASSERT(f16BitCacheLockCount > 0);
68 SkDEBUGCODE(sk_atomic_dec(&f16BitCacheLockCount);)
69 }
70 53
71 explicit SkColorTable(SkReadBuffer&); 54 explicit SkColorTable(SkReadBuffer&);
72 void writeToBuffer(SkWriteBuffer&) const; 55 void writeToBuffer(SkWriteBuffer&) const;
73 56
74 private: 57 private:
75 SkPMColor* fColors; 58 SkPMColor* fColors;
76 uint16_t* f16BitCache; 59 uint16_t* f16BitCache;
77 int fCount; 60 int fCount;
78 SkDEBUGCODE(int fColorLockCount;)
79 SkDEBUGCODE(int f16BitCacheLockCount;)
80 61
81 void init(const SkPMColor* colors, int count); 62 void init(const SkPMColor* colors, int count);
82 63
83 void inval16BitCache();
84
85 typedef SkRefCnt INHERITED; 64 typedef SkRefCnt INHERITED;
86 }; 65 };
87 66
88 #endif 67 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698