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

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

Issue 1939503002: remove non-static uses of SkOncePtr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: leave it Created 4 years, 7 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 | « src/core/SkBigPicture.cpp ('k') | src/core/SkTypeface.cpp » ('j') | 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 * Copyright 2009 The Android Open Source Project 2 * Copyright 2009 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "SkColorTable.h" 9 #include "SkColorTable.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 23 matching lines...) Expand all
34 SkColorTable::SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc) 34 SkColorTable::SkColorTable(SkPMColor* colors, int count, AllocatedWithMalloc)
35 : fColors(colors) 35 : fColors(colors)
36 , fCount(count) 36 , fCount(count)
37 { 37 {
38 SkASSERT(count > 0 && count <= 256); 38 SkASSERT(count > 0 && count <= 256);
39 SkASSERT(colors); 39 SkASSERT(colors);
40 } 40 }
41 41
42 SkColorTable::~SkColorTable() { 42 SkColorTable::~SkColorTable() {
43 sk_free(fColors); 43 sk_free(fColors);
44 // f16BitCache frees itself 44 sk_free(f16BitCache);
45 } 45 }
46 46
47 #include "SkColorPriv.h" 47 #include "SkColorPriv.h"
48 48
49 const uint16_t* SkColorTable::read16BitCache() const { 49 const uint16_t* SkColorTable::read16BitCache() const {
50 return f16BitCache.get([&]{ 50 f16BitCacheOnce([this] {
51 auto cache = new uint16_t[fCount]; 51 f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t));
52 for (int i = 0; i < fCount; i++) { 52 for (int i = 0; i < fCount; i++) {
53 cache[i] = SkPixel32ToPixel16_ToU16(fColors[i]); 53 f16BitCache[i] = SkPixel32ToPixel16_ToU16(fColors[i]);
54 } 54 }
55 return cache;
56 }); 55 });
56 return f16BitCache;
57 } 57 }
58 58
59 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
60 60
61 #if 0 61 #if 0
62 SkColorTable::SkColorTable(SkReadBuffer& buffer) { 62 SkColorTable::SkColorTable(SkReadBuffer& buffer) {
63 if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) { 63 if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) {
64 /*fAlphaType = */buffer.readUInt(); 64 /*fAlphaType = */buffer.readUInt();
65 } 65 }
66 66
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 const size_t allocSize = count * sizeof(SkPMColor); 103 const size_t allocSize = count * sizeof(SkPMColor);
104 SkAutoTDelete<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize)); 104 SkAutoTDelete<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize));
105 if (!buffer.readColorArray(colors, count)) { 105 if (!buffer.readColorArray(colors, count)) {
106 return nullptr; 106 return nullptr;
107 } 107 }
108 108
109 return new SkColorTable(colors.release(), count, kAllocatedWithMalloc); 109 return new SkColorTable(colors.release(), count, kAllocatedWithMalloc);
110 } 110 }
OLDNEW
« no previous file with comments | « src/core/SkBigPicture.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698