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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 SkColorTable::~SkColorTable() { | 43 SkColorTable::~SkColorTable() { |
44 sk_free(fColors); | 44 sk_free(fColors); |
45 // f16BitCache frees itself | 45 // f16BitCache frees itself |
46 } | 46 } |
47 | 47 |
48 #include "SkColorPriv.h" | 48 #include "SkColorPriv.h" |
49 | 49 |
50 const uint16_t* SkColorTable::read16BitCache() const { | 50 const uint16_t* SkColorTable::read16BitCache() const { |
51 return f16BitCache.get([&]{ | 51 return f16BitCache.get([&]{ |
52 uint16_t* cache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t)); | 52 auto cache = new uint16_t[fCount]; |
53 for (int i = 0; i < fCount; i++) { | 53 for (int i = 0; i < fCount; i++) { |
54 cache[i] = SkPixel32ToPixel16_ToU16(fColors[i]); | 54 cache[i] = SkPixel32ToPixel16_ToU16(fColors[i]); |
55 } | 55 } |
56 return cache; | 56 return cache; |
57 }); | 57 }); |
58 } | 58 } |
59 | 59 |
60 /////////////////////////////////////////////////////////////////////////////// | 60 /////////////////////////////////////////////////////////////////////////////// |
61 | 61 |
62 #if 0 | 62 #if 0 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 const size_t allocSize = count * sizeof(SkPMColor); | 104 const size_t allocSize = count * sizeof(SkPMColor); |
105 SkAutoTDelete<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize)); | 105 SkAutoTDelete<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize)); |
106 if (!buffer.readColorArray(colors, count)) { | 106 if (!buffer.readColorArray(colors, count)) { |
107 return nullptr; | 107 return nullptr; |
108 } | 108 } |
109 | 109 |
110 return new SkColorTable(colors.detach(), count, kAllocatedWithMalloc); | 110 return new SkColorTable(colors.detach(), count, kAllocatedWithMalloc); |
111 } | 111 } |
112 | 112 |
OLD | NEW |