OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2009 The Android Open Source Project | 3 * Copyright 2009 The Android Open Source Project |
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 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 sk_malloc_throw(count * sizeof(SkPMColor))); | 24 sk_malloc_throw(count * sizeof(SkPMColor))); |
25 memcpy(fColors, src.fColors, count * sizeof(SkPMColor)); | 25 memcpy(fColors, src.fColors, count * sizeof(SkPMColor)); |
26 | 26 |
27 SkDEBUGCODE(fColorLockCount = 0;) | 27 SkDEBUGCODE(fColorLockCount = 0;) |
28 SkDEBUGCODE(f16BitCacheLockCount = 0;) | 28 SkDEBUGCODE(f16BitCacheLockCount = 0;) |
29 } | 29 } |
30 | 30 |
31 SkColorTable::SkColorTable(const SkPMColor colors[], int count, SkAlphaType at) | 31 SkColorTable::SkColorTable(const SkPMColor colors[], int count, SkAlphaType at) |
32 : f16BitCache(NULL), fAlphaType(SkToU8(at)) | 32 : f16BitCache(NULL), fAlphaType(SkToU8(at)) |
33 { | 33 { |
34 SkASSERT(0 == count || NULL != colors); | 34 SkASSERT(0 == count || colors); |
35 | 35 |
36 if (count < 0) { | 36 if (count < 0) { |
37 count = 0; | 37 count = 0; |
38 } else if (count > 256) { | 38 } else if (count > 256) { |
39 count = 256; | 39 count = 256; |
40 } | 40 } |
41 | 41 |
42 fCount = SkToU16(count); | 42 fCount = SkToU16(count); |
43 fColors = reinterpret_cast<SkPMColor*>( | 43 fColors = reinterpret_cast<SkPMColor*>( |
44 sk_malloc_throw(count * sizeof(SkPMColor))); | 44 sk_malloc_throw(count * sizeof(SkPMColor))); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 #ifdef SK_DEBUG | 103 #ifdef SK_DEBUG |
104 SkASSERT((unsigned)fCount <= 256); | 104 SkASSERT((unsigned)fCount <= 256); |
105 SkASSERT(success); | 105 SkASSERT(success); |
106 #endif | 106 #endif |
107 } | 107 } |
108 | 108 |
109 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { | 109 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { |
110 buffer.writeUInt(fAlphaType); | 110 buffer.writeUInt(fAlphaType); |
111 buffer.writeColorArray(fColors, fCount); | 111 buffer.writeColorArray(fColors, fCount); |
112 } | 112 } |
OLD | NEW |