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

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

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 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/images/SkImageDecoder.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * to "true". Inside a program that links to skia: 98 * to "true". Inside a program that links to skia:
99 * SK_CONF_SET("images.jpeg.suppressDecoderErrors", true); */ 99 * SK_CONF_SET("images.jpeg.suppressDecoderErrors", true); */
100 if (c_suppressJPEGImageDecoderErrors) { 100 if (c_suppressJPEGImageDecoderErrors) {
101 cinfo->err->output_message = &do_nothing_output_message; 101 cinfo->err->output_message = &do_nothing_output_message;
102 } 102 }
103 } 103 }
104 104
105 #ifdef SK_BUILD_FOR_ANDROID 105 #ifdef SK_BUILD_FOR_ANDROID
106 class SkJPEGImageIndex { 106 class SkJPEGImageIndex {
107 public: 107 public:
108 // Takes ownership of stream.
108 SkJPEGImageIndex(SkStreamRewindable* stream, SkImageDecoder* decoder) 109 SkJPEGImageIndex(SkStreamRewindable* stream, SkImageDecoder* decoder)
109 : fSrcMgr(stream, decoder) 110 : fSrcMgr(stream, decoder)
111 , fStream(stream)
110 , fInfoInitialized(false) 112 , fInfoInitialized(false)
111 , fHuffmanCreated(false) 113 , fHuffmanCreated(false)
112 , fDecompressStarted(false) 114 , fDecompressStarted(false)
113 { 115 {
114 SkDEBUGCODE(fReadHeaderSucceeded = false;) 116 SkDEBUGCODE(fReadHeaderSucceeded = false;)
115 } 117 }
116 118
117 ~SkJPEGImageIndex() { 119 ~SkJPEGImageIndex() {
118 if (fHuffmanCreated) { 120 if (fHuffmanCreated) {
119 // Set to false before calling the libjpeg function, in case 121 // Set to false before calling the libjpeg function, in case
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 SkASSERT(!fDecompressStarted); 201 SkASSERT(!fDecompressStarted);
200 if (jpeg_start_tile_decompress(&fCInfo)) { 202 if (jpeg_start_tile_decompress(&fCInfo)) {
201 fDecompressStarted = true; 203 fDecompressStarted = true;
202 return true; 204 return true;
203 } 205 }
204 return false; 206 return false;
205 } 207 }
206 208
207 private: 209 private:
208 skjpeg_source_mgr fSrcMgr; 210 skjpeg_source_mgr fSrcMgr;
211 SkAutoTDelete<SkStream> fStream;
209 jpeg_decompress_struct fCInfo; 212 jpeg_decompress_struct fCInfo;
210 huffman_index fHuffmanIndex; 213 huffman_index fHuffmanIndex;
211 bool fInfoInitialized; 214 bool fInfoInitialized;
212 bool fHuffmanCreated; 215 bool fHuffmanCreated;
213 bool fDecompressStarted; 216 bool fDecompressStarted;
214 SkDEBUGCODE(bool fReadHeaderSucceeded;) 217 SkDEBUGCODE(bool fReadHeaderSucceeded;)
215 }; 218 };
216 #endif 219 #endif
217 220
218 class SkJPEGImageDecoder : public SkImageDecoder { 221 class SkJPEGImageDecoder : public SkImageDecoder {
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 return SkImageDecoder::kUnknown_Format; 1442 return SkImageDecoder::kUnknown_Format;
1440 } 1443 }
1441 1444
1442 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1445 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1443 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1446 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1444 } 1447 }
1445 1448
1446 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1449 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1447 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1450 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1448 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1451 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698