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

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

Issue 1556333004: take gr-context parameter to refEncoded, indicating a desire for only gpu-specific formats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update dox Created 4 years, 11 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/SkImageCacherator.h » ('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 "SkBitmap.h"
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
14 14
15 class GrContext; 15 class GrContext;
16 class GrTexture; 16 class GrTexture;
17 class GrTextureParams; 17 class GrTextureParams;
18 class SkBitmap; 18 class SkBitmap;
19 class SkData; 19 class SkData;
20 class SkImageGenerator; 20 class SkImageGenerator;
21 class SkMatrix; 21 class SkMatrix;
22 class SkPaint; 22 class SkPaint;
23 class SkPicture; 23 class SkPicture;
24 24
25 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
26 #define SK_REFENCODEDDATA_CTXPARAM
27 #else
28 #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx
29 #endif
30
25 /** 31 /**
26 * Takes ownership of SkImageGenerator. If this method fails for 32 * Takes ownership of SkImageGenerator. If this method fails for
27 * whatever reason, it will return false and immediatetely delete 33 * whatever reason, it will return false and immediatetely delete
28 * the generator. If it succeeds, it will modify destination 34 * the generator. If it succeeds, it will modify destination
29 * bitmap. 35 * bitmap.
30 * 36 *
31 * If generator is NULL, will safely return false. 37 * If generator is NULL, will safely return false.
32 * 38 *
33 * If this fails or when the SkDiscardablePixelRef that is 39 * If this fails or when the SkDiscardablePixelRef that is
34 * installed into destination is destroyed, it will 40 * installed into destination is destroyed, it will
(...skipping 22 matching lines...) Expand all
57 /** 63 /**
58 * The PixelRef which takes ownership of this SkImageGenerator 64 * The PixelRef which takes ownership of this SkImageGenerator
59 * will call the image generator's destructor. 65 * will call the image generator's destructor.
60 */ 66 */
61 virtual ~SkImageGenerator() { } 67 virtual ~SkImageGenerator() { }
62 68
63 uint32_t uniqueID() const { return fUniqueID; } 69 uint32_t uniqueID() const { return fUniqueID; }
64 70
65 /** 71 /**
66 * Return a ref to the encoded (i.e. compressed) representation, 72 * Return a ref to the encoded (i.e. compressed) representation,
67 * of this data. 73 * of this data. If the GrContext is non-null, then the caller is only inte rested in
74 * gpu-specific formats, so the impl may return null even if they have enco ded data,
75 * assuming they know it is not suitable for the gpu.
68 * 76 *
69 * If non-NULL is returned, the caller is responsible for calling 77 * If non-NULL is returned, the caller is responsible for calling
70 * unref() on the data when it is finished. 78 * unref() on the data when it is finished.
71 */ 79 */
72 SkData* refEncodedData() { return this->onRefEncodedData(); } 80 SkData* refEncodedData(GrContext* ctx = nullptr) {
81 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
82 return this->onRefEncodedData();
83 #else
84 return this->onRefEncodedData(ctx);
85 #endif
86 }
73 87
74 /** 88 /**
75 * Return the ImageInfo associated with this generator. 89 * Return the ImageInfo associated with this generator.
76 */ 90 */
77 const SkImageInfo& getInfo() const { return fInfo; } 91 const SkImageInfo& getInfo() const { return fInfo; }
78 92
79 /** 93 /**
80 * Decode into the given pixels, a block of memory of size at 94 * Decode into the given pixels, a block of memory of size at
81 * least (info.fHeight - 1) * rowBytes + (info.fWidth * 95 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
82 * bytesPerPixel) 96 * bytesPerPixel)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 237 }
224 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) { 238 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) {
225 if (!this->tryGenerateBitmap(bm, &info, nullptr)) { 239 if (!this->tryGenerateBitmap(bm, &info, nullptr)) {
226 sk_throw(); 240 sk_throw();
227 } 241 }
228 } 242 }
229 243
230 protected: 244 protected:
231 SkImageGenerator(const SkImageInfo& info); 245 SkImageGenerator(const SkImageInfo& info);
232 246
233 virtual SkData* onRefEncodedData(); 247 virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM);
234 248
235 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, 249 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
236 SkPMColor ctable[], int* ctableCount); 250 SkPMColor ctable[], int* ctableCount);
237 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); 251 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]);
238 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 252 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
239 SkYUVColorSpace* colorSpace); 253 SkYUVColorSpace* colorSpace);
240 254
241 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { 255 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) {
242 return nullptr; 256 return nullptr;
243 } 257 }
(...skipping 11 matching lines...) Expand all
255 const SkImageInfo fInfo; 269 const SkImageInfo fInfo;
256 const uint32_t fUniqueID; 270 const uint32_t fUniqueID;
257 271
258 // This is our default impl, which may be different on different platforms. 272 // This is our default impl, which may be different on different platforms.
259 // It is called from NewFromEncoded() after it has checked for any runtime f actory. 273 // It is called from NewFromEncoded() after it has checked for any runtime f actory.
260 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. 274 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded.
261 static SkImageGenerator* NewFromEncodedImpl(SkData*); 275 static SkImageGenerator* NewFromEncodedImpl(SkData*);
262 }; 276 };
263 277
264 #endif // SkImageGenerator_DEFINED 278 #endif // SkImageGenerator_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageCacherator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698