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

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

Issue 1401883005: Add dm target to BUILD and refactor BUILD file. Fix blaze compilation errors. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 2 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 JpegDecoderMgr* decoderMgr) 144 JpegDecoderMgr* decoderMgr)
145 : INHERITED(srcInfo, stream) 145 : INHERITED(srcInfo, stream)
146 , fDecoderMgr(decoderMgr) 146 , fDecoderMgr(decoderMgr)
147 , fReadyState(decoderMgr->dinfo()->global_state) 147 , fReadyState(decoderMgr->dinfo()->global_state)
148 {} 148 {}
149 149
150 /* 150 /*
151 * Return the row bytes of a particular image type and width 151 * Return the row bytes of a particular image type and width
152 */ 152 */
153 static int get_row_bytes(const j_decompress_ptr dinfo) { 153 static int get_row_bytes(const j_decompress_ptr dinfo) {
154 #if defined (GOOGLE3)
155 int colorBytes = dinfo->out_color_components;
156 #else
154 int colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_col or_components; 157 int colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_col or_components;
msarett 2015/10/14 19:58:25 RGB565 is relatively new to turbo. I had to add t
dogben 2015/10/14 23:11:06 Acknowledged.
158 #endif
155 return dinfo->output_width * colorBytes; 159 return dinfo->output_width * colorBytes;
156 160
157 } 161 }
158 162
159 /* 163 /*
160 * Calculate output dimensions based on the provided factors. 164 * Calculate output dimensions based on the provided factors.
161 * 165 *
162 * Not to be used on the actual jpeg_decompress_struct used for decoding, since it will 166 * Not to be used on the actual jpeg_decompress_struct used for decoding, since it will
163 * incorrectly modify num_components. 167 * incorrectly modify num_components.
164 */ 168 */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; 244 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace;
241 245
242 // Check for valid color types and set the output color space 246 // Check for valid color types and set the output color space
243 switch (dst.colorType()) { 247 switch (dst.colorType()) {
244 case kN32_SkColorType: 248 case kN32_SkColorType:
245 if (isCMYK) { 249 if (isCMYK) {
246 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; 250 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK;
247 } else { 251 } else {
248 // Check the byte ordering of the RGBA color space for the 252 // Check the byte ordering of the RGBA color space for the
249 // current platform 253 // current platform
250 #if defined(SK_PMCOLOR_IS_RGBA) 254 #if defined(GOOGLE3)
255 return false;
256 #else
257 #if defined(SK_PMCOLOR_IS_RGBA)
251 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; 258 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA;
msarett 2015/10/14 19:58:25 RGBA and BGRA aren't a part of libjpeg. We will h
dogben 2015/10/14 23:11:05 It's libjpeg. I'll follow up with you about this.
252 #else 259 #else
253 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA; 260 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA;
261 #endif
254 #endif 262 #endif
255 } 263 }
256 return true; 264 return true;
257 case kRGB_565_SkColorType: 265 case kRGB_565_SkColorType:
258 if (isCMYK) { 266 if (isCMYK) {
259 // FIXME (msarett): We need to support 565 here. It's not hard to do, considering 267 // FIXME (msarett): We need to support 565 here. It's not hard to do, considering
260 // we already convert CMYK to RGBA, I just need to do it. I thi nk it might be 268 // we already convert CMYK to RGBA, I just need to do it. I thi nk it might be
261 // best to do this in SkSwizzler and also move convert_CMYK_to_R GBA into SkSwizzler. 269 // best to do this in SkSwizzler and also move convert_CMYK_to_R GBA into SkSwizzler.
262 return false; 270 return false;
263 } else { 271 } else {
272 #if defined(GOOGLE3)
273 return false;
274 #else
264 fDecoderMgr->dinfo()->dither_mode = JDITHER_NONE; 275 fDecoderMgr->dinfo()->dither_mode = JDITHER_NONE;
265 fDecoderMgr->dinfo()->out_color_space = JCS_RGB565; 276 fDecoderMgr->dinfo()->out_color_space = JCS_RGB565;
277 #endif
266 } 278 }
267 return true; 279 return true;
268 case kGray_8_SkColorType: 280 case kGray_8_SkColorType:
269 if (isCMYK) { 281 if (isCMYK) {
270 return false; 282 return false;
271 } else { 283 } else {
272 // We will enable decodes to gray even if the image is color bec ause this is 284 // We will enable decodes to gray even if the image is color bec ause this is
273 // much faster than decoding to color and then converting 285 // much faster than decoding to color and then converting
274 fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE; 286 fDecoderMgr->dinfo()->out_color_space = JCS_GRAYSCALE;
275 } 287 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 srcConfig = SkSwizzler::kRGBX; 402 srcConfig = SkSwizzler::kRGBX;
391 break; 403 break;
392 case kBGRA_8888_SkColorType: 404 case kBGRA_8888_SkColorType:
393 srcConfig = SkSwizzler::kBGRX; 405 srcConfig = SkSwizzler::kBGRX;
394 break; 406 break;
395 case kRGB_565_SkColorType: 407 case kRGB_565_SkColorType:
396 srcConfig = SkSwizzler::kRGB_565; 408 srcConfig = SkSwizzler::kRGB_565;
397 break; 409 break;
398 default: 410 default:
399 // This function should only be called if the colorType is supported by jpeg 411 // This function should only be called if the colorType is supported by jpeg
412 #if defined(GOOGLE3)
413 SK_CRASH();
414 #else
400 SkASSERT(false); 415 SkASSERT(false);
416 #endif
401 } 417 }
402 418
403 fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, dstInfo, opti ons)); 419 fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, dstInfo, opti ons));
404 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo())); 420 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo()));
405 fSrcRow = static_cast<uint8_t*>(fStorage.get()); 421 fSrcRow = static_cast<uint8_t*>(fStorage.get());
406 } 422 }
407 423
408 SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) { 424 SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) {
409 if (!createIfNecessary || fSwizzler) { 425 if (!createIfNecessary || fSwizzler) {
410 SkASSERT(!fSwizzler || (fSrcRow && static_cast<uint8_t*>(fStorage.get()) == fSrcRow)); 426 SkASSERT(!fSwizzler || (fSrcRow && static_cast<uint8_t*>(fStorage.get()) == fSrcRow));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 jpeg_read_scanlines(dinfo, &storagePtr, 1); \ 512 jpeg_read_scanlines(dinfo, &storagePtr, 1); \
497 } 513 }
498 #endif 514 #endif
499 515
500 bool SkJpegCodec::onSkipScanlines(int count) { 516 bool SkJpegCodec::onSkipScanlines(int count) {
501 // Set the jump location for libjpeg errors 517 // Set the jump location for libjpeg errors
502 if (setjmp(fDecoderMgr->getJmpBuf())) { 518 if (setjmp(fDecoderMgr->getJmpBuf())) {
503 return fDecoderMgr->returnFalse("setjmp"); 519 return fDecoderMgr->returnFalse("setjmp");
504 } 520 }
505 521
522 #ifndef TURBO_HAS_SKIP
523 jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
msarett 2015/10/14 19:58:25 This works for now. I need to clean this up.
dogben 2015/10/14 23:11:05 Cool, thanks!
524 return true;
525 #else
506 return count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count); 526 return count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
527 #endif
507 } 528 }
OLDNEW
« BUILD.public ('K') | « src/codec/SkCodec_wbmp.cpp ('k') | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698