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

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

Issue 1180983002: Switch SkJpegCode to libjpeg-turbo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix xcode builds Created 5 years, 5 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/SkJpegDecoderMgr.h ('k') | src/codec/SkJpegUtility_codec.h » ('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 "SkJpegDecoderMgr.h" 8 #include "SkJpegDecoderMgr.h"
9 #include "SkJpegUtility_codec.h" 9 #include "SkJpegUtility_codec.h"
10 10
(...skipping 21 matching lines...) Expand all
32 return false; 32 return false;
33 } 33 }
34 34
35 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu lt result) { 35 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu lt result) {
36 print_message((j_common_ptr) &fDInfo, caller); 36 print_message((j_common_ptr) &fDInfo, caller);
37 return result; 37 return result;
38 } 38 }
39 39
40 SkColorType JpegDecoderMgr::getColorType() { 40 SkColorType JpegDecoderMgr::getColorType() {
41 switch (fDInfo.jpeg_color_space) { 41 switch (fDInfo.jpeg_color_space) {
42 case JCS_CMYK:
43 case JCS_YCCK:
44 // libjpeg cannot convert from CMYK or YCCK to RGB.
45 // Here, we ask libjpeg to give us CMYK samples back and
46 // we will later manually convert them to RGB.
47 fDInfo.out_color_space = JCS_CMYK;
48 return kN32_SkColorType;
49 case JCS_GRAYSCALE: 42 case JCS_GRAYSCALE:
50 fDInfo.out_color_space = JCS_GRAYSCALE;
51 return kGray_8_SkColorType; 43 return kGray_8_SkColorType;
52 default: 44 default:
53 #ifdef ANDROID_RGB
54 fDInfo.out_color_space = JCS_RGBA_8888;
55 #else
56 fDInfo.out_color_space = JCS_RGB;
57 #endif
58 return kN32_SkColorType; 45 return kN32_SkColorType;
59 } 46 }
60 } 47 }
61 48
62 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) 49 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream)
63 : fSrcMgr(stream) 50 : fSrcMgr(stream)
64 , fInit(false) 51 , fInit(false)
65 { 52 {
66 // Error manager must be set before any calls to libjeg in order to handle f ailures 53 // Error manager must be set before any calls to libjeg in order to handle f ailures
67 fDInfo.err = jpeg_std_error(&fErrorMgr); 54 fDInfo.err = turbo_jpeg_std_error(&fErrorMgr);
68 fErrorMgr.error_exit = skjpeg_err_exit; 55 fErrorMgr.error_exit = skjpeg_err_exit;
69 } 56 }
70 57
71 void JpegDecoderMgr::init() { 58 void JpegDecoderMgr::init() {
72 jpeg_create_decompress(&fDInfo); 59 jpeg_create_decompress(&fDInfo);
73 fInit = true; 60 fInit = true;
74 fDInfo.src = &fSrcMgr; 61 fDInfo.src = &fSrcMgr;
75 fDInfo.err->emit_message = &emit_message; 62 fDInfo.err->emit_message = &emit_message;
76 fDInfo.err->output_message = &output_message; 63 fDInfo.err->output_message = &output_message;
77 } 64 }
78 65
79 JpegDecoderMgr::~JpegDecoderMgr() { 66 JpegDecoderMgr::~JpegDecoderMgr() {
80 if (fInit) { 67 if (fInit) {
81 jpeg_destroy_decompress(&fDInfo); 68 jpeg_destroy_decompress(&fDInfo);
82 } 69 }
83 } 70 }
84 71
85 jmp_buf& JpegDecoderMgr::getJmpBuf() { 72 jmp_buf& JpegDecoderMgr::getJmpBuf() {
86 return fErrorMgr.fJmpBuf; 73 return fErrorMgr.fJmpBuf;
87 } 74 }
88 75
89 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { 76 jpeg_decompress_struct* JpegDecoderMgr::dinfo() {
90 return &fDInfo; 77 return &fDInfo;
91 } 78 }
OLDNEW
« no previous file with comments | « src/codec/SkJpegDecoderMgr.h ('k') | src/codec/SkJpegUtility_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698