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

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

Issue 1820413002: Workaround to set the sRGB flag on SkImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix jpeg 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
« no previous file with comments | « no previous file | src/codec/SkCodecPriv.h » ('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 "SkCodecImageGenerator.h" 8 #include "SkCodecImageGenerator.h"
9 9
10 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { 10 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) {
11 SkCodec* codec = SkCodec::NewFromData(data); 11 SkCodec* codec = SkCodec::NewFromData(data);
12 if (nullptr == codec) { 12 if (nullptr == codec) {
13 return nullptr; 13 return nullptr;
14 } 14 }
15 15
16 return new SkCodecImageGenerator(codec, data); 16 return new SkCodecImageGenerator(codec, data);
17 } 17 }
18 18
19 static SkImageInfo make_premul(const SkImageInfo& info) { 19 // FIXME: We should expose information about the encoded format on the
20 if (kUnpremul_SkAlphaType == info.alphaType()) { 20 // SkImageGenerator, so the client can interpret the encoded
21 return info.makeAlphaType(kPremul_SkAlphaType); 21 // format and request an output format. For now, as a workaround,
22 } 22 // we guess what output format the client wants.
23 static SkImageInfo fix_info(const SkCodec& codec) {
24 const SkImageInfo& info = codec.getInfo();
25 SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremu l_SkAlphaType :
26 info.alphaType();
23 27
24 return info; 28 // Crudely guess that the presence of a color space means sRGB.
29 SkColorProfileType profileType = (codec.getColorSpace()) ? kSRGB_SkColorProf ileType :
30 kLinear_SkColorProfileType;
31
32 return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alph aType, profileType);
25 } 33 }
26 34
27 SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) 35 SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data)
28 : INHERITED(make_premul(codec->getInfo())) 36 : INHERITED(fix_info(*codec))
29 , fCodec(codec) 37 , fCodec(codec)
30 , fData(SkRef(data)) 38 , fData(SkRef(data))
31 {} 39 {}
32 40
33 SkData* SkCodecImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) { 41 SkData* SkCodecImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) {
34 return SkRef(fData.get()); 42 return SkRef(fData.get());
35 } 43 }
36 44
37 bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s ize_t rowBytes, 45 bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s ize_t rowBytes,
38 SkPMColor ctable[], int* ctableCount) { 46 SkPMColor ctable[], int* ctableCount) {
(...skipping 18 matching lines...) Expand all
57 SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes); 65 SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes);
58 66
59 switch (result) { 67 switch (result) {
60 case SkCodec::kSuccess: 68 case SkCodec::kSuccess:
61 case SkCodec::kIncompleteInput: 69 case SkCodec::kIncompleteInput:
62 return true; 70 return true;
63 default: 71 default:
64 return false; 72 return false;
65 } 73 }
66 } 74 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkCodecPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698