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

Side by Side Diff: src/effects/SkTableMaskFilter.cpp

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/effects/SkTableColorFilter.cpp ('k') | src/effects/SkTestImageFilters.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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkTableMaskFilter.h" 9 #include "SkTableMaskFilter.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 SkMask::Format SkTableMaskFilter::getFormat() const { 68 SkMask::Format SkTableMaskFilter::getFormat() const {
69 return SkMask::kA8_Format; 69 return SkMask::kA8_Format;
70 } 70 }
71 71
72 void SkTableMaskFilter::flatten(SkWriteBuffer& wb) const { 72 void SkTableMaskFilter::flatten(SkWriteBuffer& wb) const {
73 wb.writeByteArray(fTable, 256); 73 wb.writeByteArray(fTable, 256);
74 } 74 }
75 75
76 SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { 76 sk_sp<SkFlattenable> SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) {
77 uint8_t table[256]; 77 uint8_t table[256];
78 if (!buffer.readByteArray(table, 256)) { 78 if (!buffer.readByteArray(table, 256)) {
79 return nullptr; 79 return nullptr;
80 } 80 }
81 return Create(table); 81 return sk_sp<SkFlattenable>(Create(table));
82 } 82 }
83 83
84 /////////////////////////////////////////////////////////////////////////////// 84 ///////////////////////////////////////////////////////////////////////////////
85 85
86 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { 86 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) {
87 const float dx = 1 / 255.0f; 87 const float dx = 1 / 255.0f;
88 const float g = SkScalarToFloat(gamma); 88 const float g = SkScalarToFloat(gamma);
89 89
90 float x = 0; 90 float x = 0;
91 for (int i = 0; i < 256; i++) { 91 for (int i = 0; i < 256; i++) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 str->append("table: "); 136 str->append("table: ");
137 for (int i = 0; i < 255; ++i) { 137 for (int i = 0; i < 255; ++i) {
138 str->appendf("%d, ", fTable[i]); 138 str->appendf("%d, ", fTable[i]);
139 } 139 }
140 str->appendf("%d", fTable[255]); 140 str->appendf("%d", fTable[255]);
141 141
142 str->append(")"); 142 str->append(")");
143 } 143 }
144 #endif 144 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/SkTestImageFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698