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

Side by Side Diff: src/core/SkColorTable.cpp

Issue 1311893010: Specialize SkOncePtr<T[]>. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months 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/private/SkOncePtr.h ('k') | no next file » | 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 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
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
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
OLDNEW
« no previous file with comments | « include/private/SkOncePtr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698