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

Side by Side Diff: include/core/SkImageGenerator.h

Issue 1396323007: API to support native scaling by image-generator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 SkImageGenerator_DEFINED 8 #ifndef SkImageGenerator_DEFINED
9 #define SkImageGenerator_DEFINED 9 #define SkImageGenerator_DEFINED
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * 98 *
99 * If info is kIndex8_SkColorType, then the caller must provide storage for up to 256 99 * If info is kIndex8_SkColorType, then the caller must provide storage for up to 256
100 * SkPMColor values in ctable. On success the generator must copy N colors into that storage, 100 * SkPMColor values in ctable. On success the generator must copy N colors into that storage,
101 * (where N is the logical number of table entries) and set ctableCount to N. 101 * (where N is the logical number of table entries) and set ctableCount to N.
102 * 102 *
103 * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount 103 * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount
104 * is not null, it will be set to 0. 104 * is not null, it will be set to 0.
105 * 105 *
106 * @return true on success. 106 * @return true on success.
107 */ 107 */
108 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, 108 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
aleksandar.stojiljkovic 2015/10/14 15:32:35 I think this existing method (getPixels - based on
109 SkPMColor ctable[], int* ctableCount); 109 SkPMColor ctable[], int* ctableCount);
110 110
111 /** 111 /**
112 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and 112 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and
113 * uses the default Options. 113 * uses the default Options.
114 */ 114 */
115 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); 115 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
116 116
117 /** 117 /**
118 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes 118 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes
(...skipping 27 matching lines...) Expand all
146 * Regarding the GrTextureParams parameter: 146 * Regarding the GrTextureParams parameter:
147 * 147 *
148 * If the context (the provided one or the generator's intrinsic one) deter mines that to 148 * If the context (the provided one or the generator's intrinsic one) deter mines that to
149 * support the specified usage, it must return a different sized texture it may, 149 * support the specified usage, it must return a different sized texture it may,
150 * so the caller must inspect the texture's width/height and compare them t o the generator's 150 * so the caller must inspect the texture's width/height and compare them t o the generator's
151 * getInfo() width/height. For readback usage use GrTextureParams::ClampNoF ilter() 151 * getInfo() width/height. For readback usage use GrTextureParams::ClampNoF ilter()
152 */ 152 */
153 GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect * subset = nullptr); 153 GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect * subset = nullptr);
154 154
155 /** 155 /**
156 * Some generators can efficiently scale their contents. If this is support ed, the generator
157 * may only support certain scaled dimensions. Call this with the desired s cale factor,
158 * and it will return true if scaling is supported, and in supportedSizes[] it will return
159 * the two nearest supported dimensions. If scaling is not supported, or sc ale is invalid
msarett 2015/10/13 21:43:22 Would we want to return one supportedSize that is
aleksandar.stojiljkovic 2015/10/14 15:32:35 Another option would be to always return equal or
reed1 2015/10/15 18:21:28 Yea, I like the idea of having the results be sort
reed1 2015/10/28 18:01:51 Your last suggestion makes sense to me. I'll updat
msarett 2015/10/28 18:27:19 I'm not sure I see an update to the comment?
160 * this will return false, and supportedSizes[] will be undefined.
msarett 2015/10/13 21:43:22 Can we define an "invalid scale" as <= 0.0f or > 1
reed1 2015/10/15 18:21:28 Done.
161 */
162 bool computeScaledDimensions(SkScalar scale, SkISize supportedSizes[2]);
aleksandar.stojiljkovic 2015/10/14 15:32:35 since getPixels could be already (implicitly thoug
reed1 2015/10/28 18:01:51 Perhaps we do want more query methods, but this on
163
164 /**
165 * Request the pixels, scaled to fit into the specified scaledInfo dimensio ns.
166 * If scaledSubset is not null, it specifies the subset of the scaled pixel s that should
msarett 2015/10/13 21:43:23 nit: scaledClip
reed1 2015/10/28 18:01:51 Done.
167 * be returned. It will be in the scaled coordinate system (not the origina l), and is only
168 * valid if it is entire contained inside the scaled dimensions...
msarett 2015/10/13 21:43:23 nit: entirely
reed1 2015/10/28 18:01:51 Done.
169 *
170 * SkIRect scaledBounds = SkIRect::MakeWH(0, 0, scaledInfo.width(), scaledI nfo.height());
171 * bool valid = scaledBounds.contains(scaledClip);
172 *
173 * If the requested scaledInfo is not supported by the generator, it it enc ounters an error,
msarett 2015/10/13 21:43:23 nit: it it
reed1 2015/10/28 18:01:51 Done.
174 * or the scaledClip is invalid, this returns false and the contents of pix els is undefined.
msarett 2015/10/13 21:50:31 In the case of an incomplete image, will this retu
reed1 2015/10/28 18:01:51 Good question. I *think* at the image-generator le
msarett 2015/10/28 18:27:19 From what I've seen, *most* of the incomplete imag
175 */
176 bool generateScaledPixels(const SkImageInfo& scaledInfo, void* pixels, size_ t rowBytes,
msarett 2015/10/13 21:43:23 I have one concern about this that I thought of af
scroggo 2015/10/14 14:11:28 Agreed. I thought the conclusion we came to was th
aleksandar.stojiljkovic 2015/10/27 13:42:25 Related to 1412423008 and 1403393004 (downsample &
reed1 2015/10/28 18:01:51 Ah, I had a different idea. I think one of the ke
reed1 2015/10/28 18:01:52 The older android decoders (SkImageDecoder) follow
msarett 2015/10/28 18:27:19 I think whatever decision is made here should and
177 const SkIRect* scaledClip);
178
179 /**
156 * If the default image decoder system can interpret the specified (encoded ) data, then 180 * If the default image decoder system can interpret the specified (encoded ) data, then
157 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E ither way 181 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E ither way
158 * the caller is still responsible for managing their ownership of the data . 182 * the caller is still responsible for managing their ownership of the data .
159 */ 183 */
160 static SkImageGenerator* NewFromEncoded(SkData*); 184 static SkImageGenerator* NewFromEncoded(SkData*);
161 185
162 /** Return a new image generator backed by the specified picture. If the si ze is empty or 186 /** Return a new image generator backed by the specified picture. If the si ze is empty or
163 * the picture is NULL, this returns NULL. 187 * the picture is NULL, this returns NULL.
164 * The optional matrix and paint arguments are passed to drawPicture() at r asterization 188 * The optional matrix and paint arguments are passed to drawPicture() at r asterization
165 * time. 189 * time.
(...skipping 26 matching lines...) Expand all
192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, 216 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
193 SkPMColor ctable[], int* ctableCount); 217 SkPMColor ctable[], int* ctableCount);
194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); 218 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]);
195 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 219 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
196 SkYUVColorSpace* colorSpace); 220 SkYUVColorSpace* colorSpace);
197 221
198 virtual GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, con st SkIRect*) { 222 virtual GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, con st SkIRect*) {
199 return nullptr; 223 return nullptr;
200 } 224 }
201 225
226 virtual bool onComputeScaledDimensions(SkScalar scale, SkISize supportedSize s[2]) {
227 return false;
228 }
229 virtual bool onGenerateScaledPixels(const SkImageInfo& info, void* pixels, s ize_t rowBytes,
230 const SkIRect* subset) {
231 return false;
232 }
233
202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); 234 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*);
203 235
204 private: 236 private:
205 const SkImageInfo fInfo; 237 const SkImageInfo fInfo;
206 const uint32_t fUniqueID; 238 const uint32_t fUniqueID;
207 239
208 // This is our default impl, which may be different on different platforms. 240 // This is our default impl, which may be different on different platforms.
209 // It is called from NewFromEncoded() after it has checked for any runtime f actory. 241 // It is called from NewFromEncoded() after it has checked for any runtime f actory.
210 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. 242 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded.
211 static SkImageGenerator* NewFromEncodedImpl(SkData*); 243 static SkImageGenerator* NewFromEncodedImpl(SkData*);
212 }; 244 };
213 245
214 #endif // SkImageGenerator_DEFINED 246 #endif // SkImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698