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

Side by Side Diff: include/codec/SkCodec.h

Issue 1240143002: Add the ability to decode a subset to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update comment Created 5 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 SkCodec_DEFINED 8 #ifndef SkCodec_DEFINED
9 #define SkCodec_DEFINED 9 #define SkCodec_DEFINED
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 /** 51 /**
52 * Return a size that approximately supports the desired scale factor. 52 * Return a size that approximately supports the desired scale factor.
53 * The codec may not be able to scale efficiently to the exact scale 53 * The codec may not be able to scale efficiently to the exact scale
54 * factor requested, so return a size that approximates that scale. 54 * factor requested, so return a size that approximates that scale.
55 */ 55 */
56 SkISize getScaledDimensions(float desiredScale) const { 56 SkISize getScaledDimensions(float desiredScale) const {
57 return this->onGetScaledDimensions(desiredScale); 57 return this->onGetScaledDimensions(desiredScale);
58 } 58 }
59 59
60 /** 60 /**
61 * Return (via desiredSubset) a subset which can decoded from this codec,
62 * or false if this codec cannot decode subsets or anything similar to
63 * desiredSubset.
64 *
65 * @param desiredSubset In/out parameter. As input, a desired subset of
66 * the original bounds (as specified by getInfo). If true is returned,
67 * desiredSubset may have been modified to a subset which is
68 * supported. Although a particular change may have been made to
69 * desiredSubset to create something supported, it is possible other
70 * changes could result in a valid subset.
71 * If false is returned, desiredSubset's value is undefined.
72 * @return true if this codec supports decoding desiredSubset (as
73 * returned, potentially modified)
74 */
75 bool getValidSubset(SkIRect* desiredSubset) const {
76 return this->onGetValidSubset(desiredSubset);
77 }
78
79 /**
61 * Format of the encoded data. 80 * Format of the encoded data.
62 */ 81 */
63 SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat() ; } 82 SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat() ; }
64 83
65 /** 84 /**
66 * Used to describe the result of a call to getPixels(). 85 * Used to describe the result of a call to getPixels().
67 * 86 *
68 * Result is the union of possible results from subclasses. 87 * Result is the union of possible results from subclasses.
69 */ 88 */
70 enum Result { 89 enum Result {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 * This is the default. It will be used if no Options struct is used. 140 * This is the default. It will be used if no Options struct is used.
122 */ 141 */
123 kNo_ZeroInitialized, 142 kNo_ZeroInitialized,
124 }; 143 };
125 144
126 /** 145 /**
127 * Additional options to pass to getPixels. 146 * Additional options to pass to getPixels.
128 */ 147 */
129 struct Options { 148 struct Options {
130 Options() 149 Options()
131 : fZeroInitialized(kNo_ZeroInitialized) {} 150 : fZeroInitialized(kNo_ZeroInitialized)
151 {
152 fSubset.setEmpty();
153 }
132 154
133 ZeroInitialized fZeroInitialized; 155 ZeroInitialized fZeroInitialized;
156 /**
157 * If not empty, represents a subset of the original image to decode.
158 *
159 * Must intersect with the bounds returned by getInfo().
160 *
161 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which
162 * currently supports subsets), the top and left values must be even.
163 */
164 SkIRect fSubset;
scroggo 2015/07/21 14:53:45 This might be better as a pointer, where NULL mean
msarett 2015/07/21 15:19:37 I would lean towards using a pointer, but I don't
emmaleer 2015/07/21 15:24:55 I think making it a pointer makes more sense. Beca
134 }; 165 };
135 166
136 /** 167 /**
137 * Decode into the given pixels, a block of memory of size at 168 * Decode into the given pixels, a block of memory of size at
138 * least (info.fHeight - 1) * rowBytes + (info.fWidth * 169 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
139 * bytesPerPixel) 170 * bytesPerPixel)
140 * 171 *
141 * Repeated calls to this function should give the same results, 172 * Repeated calls to this function should give the same results,
142 * allowing the PixelRef to be immutable. 173 * allowing the PixelRef to be immutable.
143 * 174 *
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // By default, scaling is not supported. 252 // By default, scaling is not supported.
222 return this->getInfo().dimensions(); 253 return this->getInfo().dimensions();
223 } 254 }
224 255
225 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 256 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
226 257
227 virtual Result onGetPixels(const SkImageInfo& info, 258 virtual Result onGetPixels(const SkImageInfo& info,
228 void* pixels, size_t rowBytes, const Options&, 259 void* pixels, size_t rowBytes, const Options&,
229 SkPMColor ctable[], int* ctableCount) = 0; 260 SkPMColor ctable[], int* ctableCount) = 0;
230 261
262 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const {
263 // By default, subsets are not supported.
264 return false;
265 }
266
231 /** 267 /**
232 * Override if your codec supports scanline decoding. 268 * Override if your codec supports scanline decoding.
233 * 269 *
234 * @param dstInfo Info of the destination. If the dimensions do not match 270 * @param dstInfo Info of the destination. If the dimensions do not match
235 * those of getInfo, this implies a scale. 271 * those of getInfo, this implies a scale.
236 * @param options Contains decoding options, including if memory is zero 272 * @param options Contains decoding options, including if memory is zero
237 * initialized. 273 * initialized.
238 * @param ctable A pointer to a color table. When dstInfo.colorType() is 274 * @param ctable A pointer to a color table. When dstInfo.colorType() is
239 * kIndex8, this should be non-NULL and have enough storage for 256 275 * kIndex8, this should be non-NULL and have enough storage for 256
240 * colors. The color table will be populated after decoding the palett e. 276 * colors. The color table will be populated after decoding the palett e.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 SkStream* stream() { 317 SkStream* stream() {
282 return fStream.get(); 318 return fStream.get();
283 } 319 }
284 320
285 private: 321 private:
286 const SkImageInfo fInfo; 322 const SkImageInfo fInfo;
287 SkAutoTDelete<SkStream> fStream; 323 SkAutoTDelete<SkStream> fStream;
288 bool fNeedsRewind; 324 bool fNeedsRewind;
289 }; 325 };
290 #endif // SkCodec_DEFINED 326 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | src/codec/SkWebpCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698