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

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

Issue 2009813003: Assign sRGB color space to unmarked jpegs and pngs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | src/codec/SkPngCodec.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 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SkEncodedInfo::Color color; 215 SkEncodedInfo::Color color;
216 if (!decoderMgr->getEncodedColor(&color)) { 216 if (!decoderMgr->getEncodedColor(&color)) {
217 return false; 217 return false;
218 } 218 }
219 219
220 // Create image info object and the codec 220 // Create image info object and the codec
221 SkEncodedInfo info = SkEncodedInfo::Make(color, SkEncodedInfo::kOpaque_A lpha, 8); 221 SkEncodedInfo info = SkEncodedInfo::Make(color, SkEncodedInfo::kOpaque_A lpha, 8);
222 222
223 Origin orientation = get_exif_orientation(decoderMgr->dinfo()); 223 Origin orientation = get_exif_orientation(decoderMgr->dinfo());
224 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo()); 224 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo());
225 if (!colorSpace) {
226 // Treat unmarked jpegs as sRGB.
227 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
228 }
225 229
226 const int width = decoderMgr->dinfo()->image_width; 230 const int width = decoderMgr->dinfo()->image_width;
227 const int height = decoderMgr->dinfo()->image_height; 231 const int height = decoderMgr->dinfo()->image_height;
228 *codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.rele ase(), colorSpace, 232 *codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.rele ase(),
229 orientation); 233 std::move(colorSpace), orientation);
230 } else { 234 } else {
231 SkASSERT(nullptr != decoderMgrOut); 235 SkASSERT(nullptr != decoderMgrOut);
232 *decoderMgrOut = decoderMgr.release(); 236 *decoderMgrOut = decoderMgr.release();
233 } 237 }
234 return true; 238 return true;
235 } 239 }
236 240
237 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) { 241 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
238 SkAutoTDelete<SkStream> streamDeleter(stream); 242 SkAutoTDelete<SkStream> streamDeleter(stream);
239 SkCodec* codec = nullptr; 243 SkCodec* codec = nullptr;
240 if (ReadHeader(stream, &codec, nullptr)) { 244 if (ReadHeader(stream, &codec, nullptr)) {
241 // Codec has taken ownership of the stream, we do not need to delete it 245 // Codec has taken ownership of the stream, we do not need to delete it
242 SkASSERT(codec); 246 SkASSERT(codec);
243 streamDeleter.release(); 247 streamDeleter.release();
244 return codec; 248 return codec;
245 } 249 }
246 return nullptr; 250 return nullptr;
247 } 251 }
248 252
249 SkJpegCodec::SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStr eam* stream, 253 SkJpegCodec::SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStr eam* stream,
250 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n) 254 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n)
251 : INHERITED(width, height, info, stream, colorSpace, origin) 255 : INHERITED(width, height, info, stream, std::move(colorSpace), origin)
252 , fDecoderMgr(decoderMgr) 256 , fDecoderMgr(decoderMgr)
253 , fReadyState(decoderMgr->dinfo()->global_state) 257 , fReadyState(decoderMgr->dinfo()->global_state)
254 , fSwizzlerSubset(SkIRect::MakeEmpty()) 258 , fSwizzlerSubset(SkIRect::MakeEmpty())
255 {} 259 {}
256 260
257 /* 261 /*
258 * Return the row bytes of a particular image type and width 262 * Return the row bytes of a particular image type and width
259 */ 263 */
260 static size_t get_row_bytes(const j_decompress_ptr dinfo) { 264 static size_t get_row_bytes(const j_decompress_ptr dinfo) {
261 #ifdef TURBO_HAS_565 265 #ifdef TURBO_HAS_565
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 894
891 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); 895 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock);
892 if (linesRead < remainingRows) { 896 if (linesRead < remainingRows) {
893 // FIXME: Handle incomplete YUV decodes without signalling an error. 897 // FIXME: Handle incomplete YUV decodes without signalling an error.
894 return kInvalidInput; 898 return kInvalidInput;
895 } 899 }
896 } 900 }
897 901
898 return kSuccess; 902 return kSuccess;
899 } 903 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698