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

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

Issue 24269006: Add an option on SkImageDecoder to skip writing 0s. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebase, plus update the benchmark Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkImageDecoder_libpng.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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } else if (JCS_RGB_565 == cinfo.out_color_space) { 581 } else if (JCS_RGB_565 == cinfo.out_color_space) {
582 sc = SkScaledBitmapSampler::kRGB_565; 582 sc = SkScaledBitmapSampler::kRGB_565;
583 #endif 583 #endif
584 } else if (1 == cinfo.out_color_components && 584 } else if (1 == cinfo.out_color_components &&
585 JCS_GRAYSCALE == cinfo.out_color_space) { 585 JCS_GRAYSCALE == cinfo.out_color_space) {
586 sc = SkScaledBitmapSampler::kGray; 586 sc = SkScaledBitmapSampler::kGray;
587 } else { 587 } else {
588 return return_false(cinfo, *bm, "jpeg colorspace"); 588 return return_false(cinfo, *bm, "jpeg colorspace");
589 } 589 }
590 590
591 if (!sampler.begin(bm, sc, this->getDitherImage())) { 591 if (!sampler.begin(bm, sc, *this)) {
592 return return_false(cinfo, *bm, "sampler.begin"); 592 return return_false(cinfo, *bm, "sampler.begin");
593 } 593 }
594 594
595 // The CMYK work-around relies on 4 components per pixel here 595 // The CMYK work-around relies on 4 components per pixel here
596 SkAutoMalloc srcStorage(cinfo.output_width * 4); 596 SkAutoMalloc srcStorage(cinfo.output_width * 4);
597 uint8_t* srcRow = (uint8_t*)srcStorage.get(); 597 uint8_t* srcRow = (uint8_t*)srcStorage.get();
598 598
599 // Possibly skip initial rows [sampler.srcY0] 599 // Possibly skip initial rows [sampler.srcY0]
600 if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) { 600 if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) {
601 return return_false(cinfo, *bm, "skip rows"); 601 return return_false(cinfo, *bm, "skip rows");
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } else if (JCS_RGB_565 == cinfo->out_color_space) { 820 } else if (JCS_RGB_565 == cinfo->out_color_space) {
821 sc = SkScaledBitmapSampler::kRGB_565; 821 sc = SkScaledBitmapSampler::kRGB_565;
822 #endif 822 #endif
823 } else if (1 == cinfo->out_color_components && 823 } else if (1 == cinfo->out_color_components &&
824 JCS_GRAYSCALE == cinfo->out_color_space) { 824 JCS_GRAYSCALE == cinfo->out_color_space) {
825 sc = SkScaledBitmapSampler::kGray; 825 sc = SkScaledBitmapSampler::kGray;
826 } else { 826 } else {
827 return return_false(*cinfo, *bm, "jpeg colorspace"); 827 return return_false(*cinfo, *bm, "jpeg colorspace");
828 } 828 }
829 829
830 if (!sampler.begin(&bitmap, sc, this->getDitherImage())) { 830 if (!sampler.begin(&bitmap, sc, *this)) {
831 return return_false(*cinfo, bitmap, "sampler.begin"); 831 return return_false(*cinfo, bitmap, "sampler.begin");
832 } 832 }
833 833
834 // The CMYK work-around relies on 4 components per pixel here 834 // The CMYK work-around relies on 4 components per pixel here
835 SkAutoMalloc srcStorage(width * 4); 835 SkAutoMalloc srcStorage(width * 4);
836 uint8_t* srcRow = (uint8_t*)srcStorage.get(); 836 uint8_t* srcRow = (uint8_t*)srcStorage.get();
837 837
838 // Possibly skip initial rows [sampler.srcY0] 838 // Possibly skip initial rows [sampler.srcY0]
839 if (!skip_src_rows_tile(cinfo, fImageIndex->huffmanIndex(), srcRow, sampler. srcY0())) { 839 if (!skip_src_rows_tile(cinfo, fImageIndex->huffmanIndex(), srcRow, sampler. srcY0())) {
840 return return_false(*cinfo, bitmap, "skip rows"); 840 return return_false(*cinfo, bitmap, "skip rows");
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 return SkImageDecoder::kUnknown_Format; 1152 return SkImageDecoder::kUnknown_Format;
1153 } 1153 }
1154 1154
1155 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1155 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1156 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1156 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1157 } 1157 }
1158 1158
1159 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1159 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1160 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1160 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1161 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1161 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698