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

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

Issue 1351453004: use allocator (if present) when we allocate our cache bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fission out test change to separate CL Created 5 years, 3 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 | « include/core/SkColorTable.h ('k') | src/core/SkImageCacherator.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
11 #include "SkBitmap.h"
11 #include "SkColor.h" 12 #include "SkColor.h"
12 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
13 14
14 class GrContext; 15 class GrContext;
15 class SkBitmap; 16 class SkBitmap;
16 class SkData; 17 class SkData;
17 class GrTexture; 18 class GrTexture;
18 class SkImageGenerator; 19 class SkImageGenerator;
19 class SkMatrix; 20 class SkMatrix;
20 class SkPaint; 21 class SkPaint;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 /** Return a new image generator backed by the specified picture. If the si ze is empty or 161 /** Return a new image generator backed by the specified picture. If the si ze is empty or
161 * the picture is NULL, this returns NULL. 162 * the picture is NULL, this returns NULL.
162 * The optional matrix and paint arguments are passed to drawPicture() at r asterization 163 * The optional matrix and paint arguments are passed to drawPicture() at r asterization
163 * time. 164 * time.
164 */ 165 */
165 static SkImageGenerator* NewFromPicture(const SkISize&, const SkPicture*, co nst SkMatrix*, 166 static SkImageGenerator* NewFromPicture(const SkISize&, const SkPicture*, co nst SkMatrix*,
166 const SkPaint*); 167 const SkPaint*);
167 168
168 bool tryGenerateBitmap(SkBitmap* bm) { 169 bool tryGenerateBitmap(SkBitmap* bm) {
169 return this->tryGenerateBitmap(bm, nullptr); 170 return this->tryGenerateBitmap(bm, nullptr, nullptr);
170 } 171 }
171 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo& info) { 172 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo& info, SkBitmap::Allo cator* allocator) {
172 return this->tryGenerateBitmap(bm, &info); 173 return this->tryGenerateBitmap(bm, &info, allocator);
173 } 174 }
174 void generateBitmap(SkBitmap* bm) { 175 void generateBitmap(SkBitmap* bm) {
175 if (!this->tryGenerateBitmap(bm, nullptr)) { 176 if (!this->tryGenerateBitmap(bm, nullptr, nullptr)) {
176 sk_throw(); 177 sk_throw();
177 } 178 }
178 } 179 }
179 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) { 180 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) {
180 if (!this->tryGenerateBitmap(bm, &info)) { 181 if (!this->tryGenerateBitmap(bm, &info, nullptr)) {
181 sk_throw(); 182 sk_throw();
182 } 183 }
183 } 184 }
184 185
185 protected: 186 protected:
186 SkImageGenerator(const SkImageInfo& info); 187 SkImageGenerator(const SkImageInfo& info);
187 188
188 virtual SkData* onRefEncodedData(); 189 virtual SkData* onRefEncodedData();
189 190
190 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, 191 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
191 SkPMColor ctable[], int* ctableCount); 192 SkPMColor ctable[], int* ctableCount);
192 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); 193 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]);
193 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
194 SkYUVColorSpace* colorSpace); 195 SkYUVColorSpace* colorSpace);
195 196
196 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI Rect*) { 197 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI Rect*) {
197 return nullptr; 198 return nullptr;
198 } 199 }
199 200
200 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo); 201 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*);
201 202
202 private: 203 private:
203 const SkImageInfo fInfo; 204 const SkImageInfo fInfo;
204 const uint32_t fUniqueID; 205 const uint32_t fUniqueID;
205 206
206 // This is our default impl, which may be different on different platforms. 207 // This is our default impl, which may be different on different platforms.
207 // It is called from NewFromEncoded() after it has checked for any runtime f actory. 208 // It is called from NewFromEncoded() after it has checked for any runtime f actory.
208 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. 209 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded.
209 static SkImageGenerator* NewFromEncodedImpl(SkData*); 210 static SkImageGenerator* NewFromEncodedImpl(SkData*);
210 }; 211 };
211 212
212 #endif // SkImageGenerator_DEFINED 213 #endif // SkImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkColorTable.h ('k') | src/core/SkImageCacherator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698