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

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: Fix some conversion warning/errors. 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
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | src/codec/SkCodec_libbmp.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 #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 , fSubset(NULL)
152 {}
132 153
133 ZeroInitialized fZeroInitialized; 154 ZeroInitialized fZeroInitialized;
155 /**
156 * If not NULL, represents a subset of the original image to decode.
157 *
158 * Must be within the bounds returned by getInfo().
159 *
160 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which
161 * currently supports subsets), the top and left values must be even.
162 */
163 SkIRect* fSubset;
134 }; 164 };
135 165
136 /** 166 /**
137 * Decode into the given pixels, a block of memory of size at 167 * Decode into the given pixels, a block of memory of size at
138 * least (info.fHeight - 1) * rowBytes + (info.fWidth * 168 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
139 * bytesPerPixel) 169 * bytesPerPixel)
140 * 170 *
141 * Repeated calls to this function should give the same results, 171 * Repeated calls to this function should give the same results,
142 * allowing the PixelRef to be immutable. 172 * allowing the PixelRef to be immutable.
143 * 173 *
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // By default, scaling is not supported. 251 // By default, scaling is not supported.
222 return this->getInfo().dimensions(); 252 return this->getInfo().dimensions();
223 } 253 }
224 254
225 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 255 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
226 256
227 virtual Result onGetPixels(const SkImageInfo& info, 257 virtual Result onGetPixels(const SkImageInfo& info,
228 void* pixels, size_t rowBytes, const Options&, 258 void* pixels, size_t rowBytes, const Options&,
229 SkPMColor ctable[], int* ctableCount) = 0; 259 SkPMColor ctable[], int* ctableCount) = 0;
230 260
261 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const {
262 // By default, subsets are not supported.
263 return false;
264 }
265
231 /** 266 /**
232 * Override if your codec supports scanline decoding. 267 * Override if your codec supports scanline decoding.
233 * 268 *
234 * @param dstInfo Info of the destination. If the dimensions do not match 269 * @param dstInfo Info of the destination. If the dimensions do not match
235 * those of getInfo, this implies a scale. 270 * those of getInfo, this implies a scale.
236 * @param options Contains decoding options, including if memory is zero 271 * @param options Contains decoding options, including if memory is zero
237 * initialized. 272 * initialized.
238 * @param ctable A pointer to a color table. When dstInfo.colorType() is 273 * @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 274 * 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. 275 * 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() { 316 SkStream* stream() {
282 return fStream.get(); 317 return fStream.get();
283 } 318 }
284 319
285 private: 320 private:
286 const SkImageInfo fInfo; 321 const SkImageInfo fInfo;
287 SkAutoTDelete<SkStream> fStream; 322 SkAutoTDelete<SkStream> fStream;
288 bool fNeedsRewind; 323 bool fNeedsRewind;
289 }; 324 };
290 #endif // SkCodec_DEFINED 325 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698