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

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 980903002: Option for SkCodec to treat dst as all zeroes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« include/codec/SkCodec.h ('K') | « src/codec/SkSwizzler.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkSwizzler.h" 9 #include "SkSwizzler.h"
10 #include "SkTemplates.h" 10 #include "SkTemplates.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 src += deltaSrc; 129 src += deltaSrc;
130 alphaMask &= alpha; 130 alphaMask &= alpha;
131 } 131 }
132 return alphaMask != 0xFF; 132 return alphaMask != 0xFF;
133 } 133 }
134 */ 134 */
135 135
136 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, const SkPMColor * ctable, 136 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, const SkPMColor * ctable,
137 const SkImageInfo& info, void* dst, 137 const SkImageInfo& info, void* dst,
138 size_t dstRowBytes, bool skipZeroes) { 138 size_t dstRowBytes, SkCodec::ZeroInitiali zed zeroInit) {
139 if (info.colorType() == kUnknown_SkColorType) { 139 if (info.colorType() == kUnknown_SkColorType) {
140 return NULL; 140 return NULL;
141 } 141 }
142 if (info.minRowBytes() > dstRowBytes) { 142 if (info.minRowBytes() > dstRowBytes) {
143 return NULL; 143 return NULL;
144 } 144 }
145 if (kIndex == sc && NULL == ctable) { 145 if (kIndex == sc && NULL == ctable) {
146 return NULL; 146 return NULL;
147 } 147 }
148 RowProc proc = NULL; 148 RowProc proc = NULL;
149 switch (sc) { 149 switch (sc) {
150 case kIndex: 150 case kIndex:
151 switch (info.colorType()) { 151 switch (info.colorType()) {
152 case kN32_SkColorType: 152 case kN32_SkColorType:
153 // We assume the color premultiplied ctable (or not) as desi red. 153 // We assume the color premultiplied ctable (or not) as desi red.
154 if (skipZeroes) { 154 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
155 proc = &swizzle_index_to_n32_skipZ; 155 proc = &swizzle_index_to_n32_skipZ;
156 } else { 156 } else {
157 proc = &swizzle_index_to_n32; 157 proc = &swizzle_index_to_n32;
158 } 158 }
159 break; 159 break;
160 160
161 default: 161 default:
162 break; 162 break;
163 } 163 }
164 break; 164 break;
165 case kRGBX: 165 case kRGBX:
166 // TODO: Support other swizzles. 166 // TODO: Support other swizzles.
167 switch (info.colorType()) { 167 switch (info.colorType()) {
168 case kN32_SkColorType: 168 case kN32_SkColorType:
169 proc = &swizzle_rgbx_to_n32; 169 proc = &swizzle_rgbx_to_n32;
170 break; 170 break;
171 default: 171 default:
172 break; 172 break;
173 } 173 }
174 break; 174 break;
175 case kRGBA: 175 case kRGBA:
176 switch (info.colorType()) { 176 switch (info.colorType()) {
177 case kN32_SkColorType: 177 case kN32_SkColorType:
178 if (info.alphaType() == kUnpremul_SkAlphaType) { 178 if (info.alphaType() == kUnpremul_SkAlphaType) {
179 // Respect skipZeroes? 179 // Respect zeroInit?
180 proc = &swizzle_rgba_to_n32_unpremul; 180 proc = &swizzle_rgba_to_n32_unpremul;
181 } else { 181 } else {
182 if (skipZeroes) { 182 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
183 proc = &swizzle_rgba_to_n32_premul_skipZ; 183 proc = &swizzle_rgba_to_n32_premul_skipZ;
184 } else { 184 } else {
185 proc = &swizzle_rgba_to_n32_premul; 185 proc = &swizzle_rgba_to_n32_premul;
186 } 186 }
187 } 187 }
188 break; 188 break;
189 default: 189 default:
190 break; 190 break;
191 } 191 }
192 break; 192 break;
(...skipping 19 matching lines...) Expand all
212 } 212 }
213 213
214 bool SkSwizzler::next(const uint8_t* SK_RESTRICT src) { 214 bool SkSwizzler::next(const uint8_t* SK_RESTRICT src) {
215 SkASSERT(fCurrY < fDstInfo.height()); 215 SkASSERT(fCurrY < fDstInfo.height());
216 const bool hadAlpha = fRowProc(fDstRow, src, fDstInfo.width(), fSrcPixelSize , 216 const bool hadAlpha = fRowProc(fDstRow, src, fDstInfo.width(), fSrcPixelSize ,
217 fCurrY, fColorTable); 217 fCurrY, fColorTable);
218 fCurrY++; 218 fCurrY++;
219 fDstRow = SkTAddOffset<void>(fDstRow, fDstRowBytes); 219 fDstRow = SkTAddOffset<void>(fDstRow, fDstRowBytes);
220 return hadAlpha; 220 return hadAlpha;
221 } 221 }
OLDNEW
« include/codec/SkCodec.h ('K') | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698