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

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

Issue 1282073004: Support decoding opaque images to unpremul/premul (Closed) Base URL: https://skia.googlesource.com/skia.git@CodexTestCleanup
Patch Set: Created 5 years, 4 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/codec/SkCodecPriv.h ('k') | tests/CodexTest.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 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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkJpegCodec.h" 9 #include "SkJpegCodec.h"
10 #include "SkJpegDecoderMgr.h" 10 #include "SkJpegDecoderMgr.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 * Sets the output color space 219 * Sets the output color space
220 */ 220 */
221 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { 221 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
222 const SkImageInfo& src = this->getInfo(); 222 const SkImageInfo& src = this->getInfo();
223 223
224 // Ensure that the profile type is unchanged 224 // Ensure that the profile type is unchanged
225 if (dst.profileType() != src.profileType()) { 225 if (dst.profileType() != src.profileType()) {
226 return false; 226 return false;
227 } 227 }
228 228
229 // Ensure that the alpha type is opaque
230 if (kOpaque_SkAlphaType != dst.alphaType()) {
231 return false;
232 }
233
234 // Check if we will decode to CMYK because a conversion to RGBA is not suppo rted 229 // Check if we will decode to CMYK because a conversion to RGBA is not suppo rted
235 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; 230 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space;
236 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; 231 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace;
237 232
238 // Check for valid color types and set the output color space 233 // Check for valid color types and set the output color space
239 switch (dst.colorType()) { 234 switch (dst.colorType()) {
240 case kN32_SkColorType: 235 case kN32_SkColorType:
241 if (isCMYK) { 236 if (isCMYK) {
242 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; 237 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK;
243 } else { 238 } else {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 SkScanlineDecoder* SkJpegCodec::NewSDFromStream(SkStream* stream) { 501 SkScanlineDecoder* SkJpegCodec::NewSDFromStream(SkStream* stream) {
507 SkAutoTDelete<SkJpegCodec> codec(static_cast<SkJpegCodec*>(SkJpegCodec::NewF romStream(stream))); 502 SkAutoTDelete<SkJpegCodec> codec(static_cast<SkJpegCodec*>(SkJpegCodec::NewF romStream(stream)));
508 if (!codec) { 503 if (!codec) {
509 return NULL; 504 return NULL;
510 } 505 }
511 506
512 const SkImageInfo& srcInfo = codec->getInfo(); 507 const SkImageInfo& srcInfo = codec->getInfo();
513 // Return the new scanline decoder 508 // Return the new scanline decoder
514 return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach())); 509 return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach()));
515 } 510 }
OLDNEW
« no previous file with comments | « src/codec/SkCodecPriv.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698