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

Side by Side Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 19726012: all in the gyp (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: forgot this Created 7 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 | Annotate | Revision Log
« no previous file with comments | « gyp/common_conditions.gypi ('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 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 } 910 }
911 } 911 }
912 912
913 class SkJPEGImageEncoder : public SkImageEncoder { 913 class SkJPEGImageEncoder : public SkImageEncoder {
914 protected: 914 protected:
915 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) { 915 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) {
916 #ifdef TIME_ENCODE 916 #ifdef TIME_ENCODE
917 SkAutoTime atm("JPEG Encode"); 917 SkAutoTime atm("JPEG Encode");
918 #endif 918 #endif
919 919
920 const WriteScanline writer = ChooseWriter(bm);
921 if (NULL == writer) {
922 return false;
923 }
924
925 SkAutoLockPixels alp(bm); 920 SkAutoLockPixels alp(bm);
926 if (NULL == bm.getPixels()) { 921 if (NULL == bm.getPixels()) {
927 return false; 922 return false;
928 } 923 }
929 924
930 jpeg_compress_struct cinfo; 925 jpeg_compress_struct cinfo;
931 skjpeg_error_mgr sk_err; 926 skjpeg_error_mgr sk_err;
932 skjpeg_destination_mgr sk_wstream(stream); 927 skjpeg_destination_mgr sk_wstream(stream);
933 928
934 // allocate these before set call setjmp 929 // allocate these before set call setjmp
935 SkAutoMalloc oneRow; 930 SkAutoMalloc oneRow;
936 SkAutoLockColors ctLocker; 931 SkAutoLockColors ctLocker;
937 932
938 cinfo.err = jpeg_std_error(&sk_err); 933 cinfo.err = jpeg_std_error(&sk_err);
939 sk_err.error_exit = skjpeg_error_exit; 934 sk_err.error_exit = skjpeg_error_exit;
940 if (setjmp(sk_err.fJmpBuf)) { 935 if (setjmp(sk_err.fJmpBuf)) {
941 return false; 936 return false;
942 } 937 }
938
939 // Keep after setjmp or mark volatile.
940 const WriteScanline writer = ChooseWriter(bm);
941 if (NULL == writer) {
942 return false;
943 }
944
943 jpeg_create_compress(&cinfo); 945 jpeg_create_compress(&cinfo);
944
945 cinfo.dest = &sk_wstream; 946 cinfo.dest = &sk_wstream;
946 cinfo.image_width = bm.width(); 947 cinfo.image_width = bm.width();
947 cinfo.image_height = bm.height(); 948 cinfo.image_height = bm.height();
948 cinfo.input_components = 3; 949 cinfo.input_components = 3;
949 #ifdef WE_CONVERT_TO_YUV 950 #ifdef WE_CONVERT_TO_YUV
950 cinfo.in_color_space = JCS_YCbCr; 951 cinfo.in_color_space = JCS_YCbCr;
951 #else 952 #else
952 cinfo.in_color_space = JCS_RGB; 953 cinfo.in_color_space = JCS_RGB;
953 #endif 954 #endif
954 cinfo.input_gamma = 1; 955 cinfo.input_gamma = 1;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 } 1022 }
1022 1023
1023 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1024 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1024 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1025 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1025 } 1026 }
1026 1027
1027 1028
1028 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); 1029 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory);
1029 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_jpeg ); 1030 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_jpeg );
1030 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact ory); 1031 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact ory);
OLDNEW
« no previous file with comments | « gyp/common_conditions.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698