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

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

Issue 1412423008: Handling large jpegs in CPU raster - downsample to display res and 565 Base URL: https://chromium.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 | src/core/SkDevice.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 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
109 SkPMColor ctable[], int* ctableCount); 109 SkPMColor ctable[], int* ctableCount);
110 110
111 /** 111 /**
112 * Used to describe the result of a call to canDecodeAndScale().
113 */
114 enum Result {
115 /**
116 * Cannot decode neither scale.
117 */
118 kNotAvailable = 0,
119 /**
120 * Can scale with color type defined in getInfo.
121 */
122 kScale,
123 /**
124 * Can convert to requested colorType, but cannot scale.
125 */
126 kDecode,
127 /**
128 * The generator can scale and decode to requested.
129 */
130 kAvailable = kScale | kDecode,
131 };
132
133 /**
134 * Some generators can efficiently scale their contents and provide multipl e
135 * different pixel formats while decoding.
136 * If scaling is supported, the generator may only support certain scaled d imensions.
137 * Call this with the desired scale and color type, and it will return true if scaling
138 * and specified color type is supported.
139 *
140 * @param colorType A description of the color type expected by the caller.
141 * Returns true if it is the same as getInfo() or if decoder impleme ntations
142 * support this output.
143 *
144 * @param scale Vale larger than 0 and less or equal to 1.
145 *
146 * @param availableSize If specified colorType and scale on decode is suppo rted,
147 * this holds a value of equal or nearest larger possible decode out put.
148 * Can be NULL, in which case caller specifies no interest in gettin g the value.
149 *
150 * @param lowerSize If specified colorType and scale on decode is supported ,
151 * this holds a value of nearest lower possible decode output.
152 * Can be NULL, in which case caller specifies no interest in gettin g the value.
153 *
154 * Disclaimer: This method was added later to this class and it is possible
155 * that some of the SkImageGenerator implementations are not overriding it to
156 * precisely declare supported decoding. Purpose of this call is an attempt to prevent
157 * fruitless memory allocations (from within Skia) before calling getPixels - it is
158 * still OK to call getPixels even this method is not overridden in generat or implementation.
159 */
160 Result canDecodeAndScale(const SkColorType colorType, const SkScalar scale = SK_Scalar1,
161 SkISize* availableSize = nullptr, SkISize* lowerSiz e = nullptr);
162
163 /**
112 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and 164 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and
113 * uses the default Options. 165 * uses the default Options.
114 */ 166 */
115 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); 167 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
116 168
117 /** 169 /**
118 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes 170 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes
119 * is 0, this imagegenerator should output the sizes and return true if it can efficiently 171 * is 0, this imagegenerator should output the sizes and return true if it can efficiently
120 * return YUV planar data. If it cannot, it should return false. Note that either planes and 172 * return YUV planar data. If it cannot, it should return false. Note that either planes and
121 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL or have NULL or 0 173 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL or have NULL or 0
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, 244 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
193 SkPMColor ctable[], int* ctableCount); 245 SkPMColor ctable[], int* ctableCount);
194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); 246 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], 247 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
196 SkYUVColorSpace* colorSpace); 248 SkYUVColorSpace* colorSpace);
197 249
198 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { 250 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) {
199 return nullptr; 251 return nullptr;
200 } 252 }
201 253
254 virtual Result onCanDecodeAndScale(const SkColorType colorType, const SkScal ar scale,
255 SkISize* availableSize, SkISize* lowerSiz e);
256
202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); 257 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*);
203 258
204 private: 259 private:
205 const SkImageInfo fInfo; 260 const SkImageInfo fInfo;
206 const uint32_t fUniqueID; 261 const uint32_t fUniqueID;
207 262
208 // This is our default impl, which may be different on different platforms. 263 // 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. 264 // 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. 265 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded.
211 static SkImageGenerator* NewFromEncodedImpl(SkData*); 266 static SkImageGenerator* NewFromEncodedImpl(SkData*);
212 }; 267 };
213 268
214 #endif // SkImageGenerator_DEFINED 269 #endif // SkImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698