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

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

Issue 1641273003: Support decoding opaque to *premul (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkMaskSwizzler to support opaque to premul Created 4 years, 10 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
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 * Sets the output color space 157 * Sets the output color space
158 */ 158 */
159 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { 159 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
160 const SkImageInfo& src = this->getInfo(); 160 const SkImageInfo& src = this->getInfo();
161 161
162 // Ensure that the profile type is unchanged 162 // Ensure that the profile type is unchanged
163 if (dst.profileType() != src.profileType()) { 163 if (dst.profileType() != src.profileType()) {
164 return false; 164 return false;
165 } 165 }
166 166
167 // Ensure that the alpha type is opaque 167 if (kUnknown_SkAlphaType == dst.alphaType()) {
168 return false;
169 }
170
168 if (kOpaque_SkAlphaType != dst.alphaType()) { 171 if (kOpaque_SkAlphaType != dst.alphaType()) {
169 return false; 172 SkCodecPrintf("Warning: an opaque image should be decoded as opaque "
173 "- it is being decoded as non-opaque, which will draw slow er\n");
170 } 174 }
171 175
172 // Check if we will decode to CMYK because a conversion to RGBA is not suppo rted 176 // Check if we will decode to CMYK because a conversion to RGBA is not suppo rted
173 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; 177 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space;
174 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; 178 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace;
175 179
176 // Check for valid color types and set the output color space 180 // Check for valid color types and set the output color space
177 switch (dst.colorType()) { 181 switch (dst.colorType()) {
178 case kN32_SkColorType: 182 case kN32_SkColorType:
179 if (isCMYK) { 183 if (isCMYK) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 641
638 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); 642 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock);
639 if (linesRead < remainingRows) { 643 if (linesRead < remainingRows) {
640 // FIXME: Handle incomplete YUV decodes without signalling an error. 644 // FIXME: Handle incomplete YUV decodes without signalling an error.
641 return kInvalidInput; 645 return kInvalidInput;
642 } 646 }
643 } 647 }
644 648
645 return kSuccess; 649 return kSuccess;
646 } 650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698