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

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

Issue 2174493002: Add color space xform support to SkJpegCodec (includes F16!) (Closed) Base URL: https://skia.googlesource.com/skia.git@drop
Patch Set: Created 4 years, 5 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 #ifndef SkJpegCodec_DEFINED 8 #ifndef SkJpegCodec_DEFINED
9 #define SkJpegCodec_DEFINED 9 #define SkJpegCodec_DEFINED
10 10
11 #include "SkCodec.h" 11 #include "SkCodec.h"
12 #include "SkColorSpace.h" 12 #include "SkColorSpace.h"
13 #include "SkColorSpaceXform.h"
13 #include "SkImageInfo.h" 14 #include "SkImageInfo.h"
14 #include "SkSwizzler.h" 15 #include "SkSwizzler.h"
15 #include "SkStream.h" 16 #include "SkStream.h"
16 #include "SkTemplates.h" 17 #include "SkTemplates.h"
17 18
18 class JpegDecoderMgr; 19 class JpegDecoderMgr;
19 20
20 /* 21 /*
21 * 22 *
22 * This class implements the decoding for jpeg images 23 * This class implements the decoding for jpeg images
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 * @param stream the encoded image data 93 * @param stream the encoded image data
93 * @param decoderMgr holds decompress struct, src manager, and error manager 94 * @param decoderMgr holds decompress struct, src manager, and error manager
94 * takes ownership 95 * takes ownership
95 */ 96 */
96 SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stre am, 97 SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stre am,
97 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin o rigin, 98 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin o rigin,
98 sk_sp<SkData> iccData); 99 sk_sp<SkData> iccData);
99 100
100 /* 101 /*
101 * Checks if the conversion between the input image and the requested output 102 * Checks if the conversion between the input image and the requested output
102 * image has been implemented 103 * image has been implemented.
103 * Sets the output color space 104 *
105 * Sets the output color space.
104 */ 106 */
105 bool setOutputColorSpace(const SkImageInfo& dst); 107 bool setOutputColorSpace(const SkImageInfo& dst, bool needsColorXform);
106 108
107 // scanline decoding
108 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options); 109 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options);
110 void allocateStorage(const SkImageInfo& dstInfo);
111 int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int cou nt);
112
113 /*
114 * Scanline decoding.
115 */
109 SkSampler* getSampler(bool createIfNecessary) override; 116 SkSampler* getSampler(bool createIfNecessary) override;
110 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons, 117 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons,
111 SkPMColor ctable[], int* ctableCount) override; 118 SkPMColor ctable[], int* ctableCount) override;
112 int onGetScanlines(void* dst, int count, size_t rowBytes) override; 119 int onGetScanlines(void* dst, int count, size_t rowBytes) override;
113 bool onSkipScanlines(int count) override; 120 bool onSkipScanlines(int count) override;
114 121
115 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; 122 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr;
123
116 // We will save the state of the decompress struct after reading the header. 124 // We will save the state of the decompress struct after reading the header.
117 // This allows us to safely call onGetScaledDimensions() at any time. 125 // This allows us to safely call onGetScaledDimensions() at any time.
118 const int fReadyState; 126 const int fReadyState;
119 127
120 // scanline decoding 128
121 SkAutoTMalloc<uint8_t> fStorage; // Only used if sampling is needed 129 SkAutoTMalloc<uint8_t> fStorage;
122 uint8_t* fSrcRow; // Only used if sampling is needed 130 uint8_t* fSwizzleSrcRow;
131 uint32_t* fColorXformSrcRow;
132
123 // libjpeg-turbo provides some subsetting. In the case that libjpeg-turbo 133 // libjpeg-turbo provides some subsetting. In the case that libjpeg-turbo
124 // cannot take the exact the subset that we need, we will use the swizzler 134 // cannot take the exact the subset that we need, we will use the swizzler
125 // to further subset the output from libjpeg-turbo. 135 // to further subset the output from libjpeg-turbo.
126 SkIRect fSwizzlerSubset; 136 SkIRect fSwizzlerSubset;
127 SkAutoTDelete<SkSwizzler> fSwizzler; 137
138 SkAutoTDelete<SkSwizzler> fSwizzler;
139 std::unique_ptr<SkColorSpaceXform> fColorXform;
128 140
129 sk_sp<SkData> fICCData; 141 sk_sp<SkData> fICCData;
130 142
131 typedef SkCodec INHERITED; 143 typedef SkCodec INHERITED;
132 }; 144 };
133 145
134 #endif 146 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698