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" |
11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
12 #include "SkStream.h" | 12 #include "SkStream.h" |
13 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
14 | 14 |
15 SK_DEFINE_INST_COUNT(SkColorTable) | |
16 | |
17 // As copy constructor is hidden in the class hierarchy, we need to call | 15 // As copy constructor is hidden in the class hierarchy, we need to call |
18 // default constructor explicitly to suppress a compiler warning. | 16 // default constructor explicitly to suppress a compiler warning. |
19 SkColorTable::SkColorTable(const SkColorTable& src) : INHERITED() { | 17 SkColorTable::SkColorTable(const SkColorTable& src) : INHERITED() { |
20 f16BitCache = NULL; | 18 f16BitCache = NULL; |
21 fAlphaType = src.fAlphaType; | 19 fAlphaType = src.fAlphaType; |
22 int count = src.count(); | 20 int count = src.count(); |
23 fCount = SkToU16(count); | 21 fCount = SkToU16(count); |
24 fColors = reinterpret_cast<SkPMColor*>( | 22 fColors = reinterpret_cast<SkPMColor*>( |
25 sk_malloc_throw(count * sizeof(SkPMColor))); | 23 sk_malloc_throw(count * sizeof(SkPMColor))); |
26 memcpy(fColors, src.fColors, count * sizeof(SkPMColor)); | 24 memcpy(fColors, src.fColors, count * sizeof(SkPMColor)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 #ifdef SK_DEBUG | 95 #ifdef SK_DEBUG |
98 SkASSERT((unsigned)fCount <= 256); | 96 SkASSERT((unsigned)fCount <= 256); |
99 SkASSERT(success); | 97 SkASSERT(success); |
100 #endif | 98 #endif |
101 } | 99 } |
102 | 100 |
103 void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { | 101 void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { |
104 buffer.writeUInt(fAlphaType); | 102 buffer.writeUInt(fAlphaType); |
105 buffer.writeColorArray(fColors, fCount); | 103 buffer.writeColorArray(fColors, fCount); |
106 } | 104 } |
OLD | NEW |