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

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: Created 7 years, 3 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
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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } else if (JCS_RGB_565 == cinfo.out_color_space) { 580 } else if (JCS_RGB_565 == cinfo.out_color_space) {
581 sc = SkScaledBitmapSampler::kRGB_565; 581 sc = SkScaledBitmapSampler::kRGB_565;
582 #endif 582 #endif
583 } else if (1 == cinfo.out_color_components && 583 } else if (1 == cinfo.out_color_components &&
584 JCS_GRAYSCALE == cinfo.out_color_space) { 584 JCS_GRAYSCALE == cinfo.out_color_space) {
585 sc = SkScaledBitmapSampler::kGray; 585 sc = SkScaledBitmapSampler::kGray;
586 } else { 586 } else {
587 return return_false(cinfo, *bm, "jpeg colorspace"); 587 return return_false(cinfo, *bm, "jpeg colorspace");
588 } 588 }
589 589
590 if (!sampler.begin(bm, sc, this->getDitherImage())) { 590 if (!sampler.begin(bm, sc, *this)) {
591 return return_false(cinfo, *bm, "sampler.begin"); 591 return return_false(cinfo, *bm, "sampler.begin");
592 } 592 }
593 593
594 // The CMYK work-around relies on 4 components per pixel here 594 // The CMYK work-around relies on 4 components per pixel here
595 SkAutoMalloc srcStorage(cinfo.output_width * 4); 595 SkAutoMalloc srcStorage(cinfo.output_width * 4);
596 uint8_t* srcRow = (uint8_t*)srcStorage.get(); 596 uint8_t* srcRow = (uint8_t*)srcStorage.get();
597 597
598 // Possibly skip initial rows [sampler.srcY0] 598 // Possibly skip initial rows [sampler.srcY0]
599 if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) { 599 if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) {
600 return return_false(cinfo, *bm, "skip rows"); 600 return return_false(cinfo, *bm, "skip rows");
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } else if (JCS_RGB_565 == cinfo->out_color_space) { 819 } else if (JCS_RGB_565 == cinfo->out_color_space) {
820 sc = SkScaledBitmapSampler::kRGB_565; 820 sc = SkScaledBitmapSampler::kRGB_565;
821 #endif 821 #endif
822 } else if (1 == cinfo->out_color_components && 822 } else if (1 == cinfo->out_color_components &&
823 JCS_GRAYSCALE == cinfo->out_color_space) { 823 JCS_GRAYSCALE == cinfo->out_color_space) {
824 sc = SkScaledBitmapSampler::kGray; 824 sc = SkScaledBitmapSampler::kGray;
825 } else { 825 } else {
826 return return_false(*cinfo, *bm, "jpeg colorspace"); 826 return return_false(*cinfo, *bm, "jpeg colorspace");
827 } 827 }
828 828
829 if (!sampler.begin(&bitmap, sc, this->getDitherImage())) { 829 if (!sampler.begin(&bitmap, sc, *this)) {
830 return return_false(*cinfo, bitmap, "sampler.begin"); 830 return return_false(*cinfo, bitmap, "sampler.begin");
831 } 831 }
832 832
833 // The CMYK work-around relies on 4 components per pixel here 833 // The CMYK work-around relies on 4 components per pixel here
834 SkAutoMalloc srcStorage(width * 4); 834 SkAutoMalloc srcStorage(width * 4);
835 uint8_t* srcRow = (uint8_t*)srcStorage.get(); 835 uint8_t* srcRow = (uint8_t*)srcStorage.get();
836 836
837 // Possibly skip initial rows [sampler.srcY0] 837 // Possibly skip initial rows [sampler.srcY0]
838 if (!skip_src_rows_tile(cinfo, fImageIndex->huffmanIndex(), srcRow, sampler. srcY0())) { 838 if (!skip_src_rows_tile(cinfo, fImageIndex->huffmanIndex(), srcRow, sampler. srcY0())) {
839 return return_false(*cinfo, bitmap, "skip rows"); 839 return return_false(*cinfo, bitmap, "skip rows");
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 } 1151 }
1152 1152
1153 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1153 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1154 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1154 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1155 } 1155 }
1156 1156
1157 1157
1158 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1158 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1159 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1159 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1160 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1160 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698