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

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

Issue 1820073002: Add SkEncodedInfo to report properties of encoded image data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkMSAN.h" 9 #include "SkMSAN.h"
10 #include "SkJpegCodec.h" 10 #include "SkJpegCodec.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 jpeg_save_markers(decoderMgr->dinfo(), kICCMarker, 0xFFFF); 205 jpeg_save_markers(decoderMgr->dinfo(), kICCMarker, 0xFFFF);
206 } 206 }
207 207
208 // Read the jpeg header 208 // Read the jpeg header
209 if (JPEG_HEADER_OK != jpeg_read_header(decoderMgr->dinfo(), true)) { 209 if (JPEG_HEADER_OK != jpeg_read_header(decoderMgr->dinfo(), true)) {
210 return decoderMgr->returnFalse("read_header"); 210 return decoderMgr->returnFalse("read_header");
211 } 211 }
212 212
213 if (codecOut) { 213 if (codecOut) {
214 // Recommend the color type to decode to 214 // Recommend the color type to decode to
215 const SkColorType colorType = decoderMgr->getColorType(); 215 const SkEncodedInfo::Color color = decoderMgr->getEncodedColor();
216 216
217 // Create image info object and the codec 217 // Create image info object and the codec
218 const SkImageInfo& imageInfo = SkImageInfo::Make(decoderMgr->dinfo()->im age_width, 218 SkEncodedInfo info = SkEncodedInfo::Make(decoderMgr->dinfo()->image_widt h,
219 decoderMgr->dinfo()->image_height, colorType, kOpaque_SkAlphaTyp e); 219 decoderMgr->dinfo()->image_height, color, SkEncodedInfo::kOpaque _Alpha, 8);
220 220
221 Origin orientation = get_exif_orientation(decoderMgr->dinfo()); 221 Origin orientation = get_exif_orientation(decoderMgr->dinfo());
222 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo()); 222 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo());
223 223
224 *codecOut = new SkJpegCodec(imageInfo, stream, decoderMgr.release(), col orSpace, 224 *codecOut = new SkJpegCodec(info, stream, decoderMgr.release(), colorSpa ce,
225 orientation); 225 orientation);
226 } else { 226 } else {
227 SkASSERT(nullptr != decoderMgrOut); 227 SkASSERT(nullptr != decoderMgrOut);
228 *decoderMgrOut = decoderMgr.release(); 228 *decoderMgrOut = decoderMgr.release();
229 } 229 }
230 return true; 230 return true;
231 } 231 }
232 232
233 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) { 233 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
234 SkAutoTDelete<SkStream> streamDeleter(stream); 234 SkAutoTDelete<SkStream> streamDeleter(stream);
235 SkCodec* codec = nullptr; 235 SkCodec* codec = nullptr;
236 if (ReadHeader(stream, &codec, nullptr)) { 236 if (ReadHeader(stream, &codec, nullptr)) {
237 // Codec has taken ownership of the stream, we do not need to delete it 237 // Codec has taken ownership of the stream, we do not need to delete it
238 SkASSERT(codec); 238 SkASSERT(codec);
239 streamDeleter.release(); 239 streamDeleter.release();
240 return codec; 240 return codec;
241 } 241 }
242 return nullptr; 242 return nullptr;
243 } 243 }
244 244
245 SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, 245 SkJpegCodec::SkJpegCodec(const SkEncodedInfo& info, SkStream* stream,
246 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n) 246 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n)
247 : INHERITED(srcInfo, stream, colorSpace, origin) 247 : INHERITED(info, stream, colorSpace, origin)
248 , fDecoderMgr(decoderMgr) 248 , fDecoderMgr(decoderMgr)
249 , fReadyState(decoderMgr->dinfo()->global_state) 249 , fReadyState(decoderMgr->dinfo()->global_state)
250 , fSwizzlerSubset(SkIRect::MakeEmpty()) 250 , fSwizzlerSubset(SkIRect::MakeEmpty())
251 {} 251 {}
252 252
253 /* 253 /*
254 * Return the row bytes of a particular image type and width 254 * Return the row bytes of a particular image type and width
255 */ 255 */
256 static size_t get_row_bytes(const j_decompress_ptr dinfo) { 256 static size_t get_row_bytes(const j_decompress_ptr dinfo) {
257 #ifdef TURBO_HAS_565 257 #ifdef TURBO_HAS_565
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 896
897 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); 897 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock);
898 if (linesRead < remainingRows) { 898 if (linesRead < remainingRows) {
899 // FIXME: Handle incomplete YUV decodes without signalling an error. 899 // FIXME: Handle incomplete YUV decodes without signalling an error.
900 return kInvalidInput; 900 return kInvalidInput;
901 } 901 }
902 } 902 }
903 903
904 return kSuccess; 904 return kSuccess;
905 } 905 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698