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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 }; | 60 }; |
61 // assumes ownership of colors (assumes it was allocated w/ malloc) | 61 // assumes ownership of colors (assumes it was allocated w/ malloc) |
62 SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc); | 62 SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc); |
63 | 63 |
64 SkPMColor* fColors; | 64 SkPMColor* fColors; |
65 SkOncePtr<uint16_t[]> f16BitCache; | 65 SkOncePtr<uint16_t[]> f16BitCache; |
66 int fCount; | 66 int fCount; |
67 | 67 |
68 void init(const SkPMColor* colors, int count); | 68 void init(const SkPMColor* colors, int count); |
69 | 69 |
| 70 friend class SkImageGenerator; |
| 71 // Only call if no other thread or cache has seen this table. |
| 72 void dangerous_overwriteColors(const SkPMColor newColors[], int count) { |
| 73 if (count < 0 || count > fCount) { |
| 74 sk_throw(); |
| 75 } |
| 76 // assumes that f16BitCache nas NOT been initialized yet, so we don't tr
y to update it |
| 77 memcpy(fColors, newColors, count * sizeof(SkPMColor)); |
| 78 fCount = count; // update fCount, in case count is smaller |
| 79 } |
| 80 |
70 typedef SkRefCnt INHERITED; | 81 typedef SkRefCnt INHERITED; |
71 }; | 82 }; |
72 | 83 |
73 #endif | 84 #endif |
OLD | NEW |