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

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

Issue 1862133002: Add whitelist parameter to refEncodedData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make test pass regardless of CTX build flag Created 4 years, 8 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
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 "SkEncodedFormat.h"
13 #include "SkImageInfo.h" 14 #include "SkImageInfo.h"
14 #include "SkYUVSizeInfo.h" 15 #include "SkYUVSizeInfo.h"
15 16
16 class GrContext; 17 class GrContext;
17 class GrTexture; 18 class GrTexture;
18 class GrTextureParams; 19 class GrTextureParams;
19 class SkBitmap; 20 class SkBitmap;
20 class SkData; 21 class SkData;
21 class SkImageGenerator; 22 class SkImageGenerator;
22 class SkMatrix; 23 class SkMatrix;
23 class SkPaint; 24 class SkPaint;
24 class SkPicture; 25 class SkPicture;
25 26
26 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX 27 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
27 #define SK_REFENCODEDDATA_CTXPARAM 28 #define SK_REFENCODEDDATA_CTXPARAM
28 #else 29 #else
29 #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx 30 #define SK_REFENCODEDDATA_CTXPARAM SkEncodedFormatQuery* query
30 #endif 31 #endif
31 32
32 /** 33 /**
33 * Takes ownership of SkImageGenerator. If this method fails for 34 * Takes ownership of SkImageGenerator. If this method fails for
34 * whatever reason, it will return false and immediatetely delete 35 * whatever reason, it will return false and immediatetely delete
35 * the generator. If it succeeds, it will modify destination 36 * the generator. If it succeeds, it will modify destination
36 * bitmap. 37 * bitmap.
37 * 38 *
38 * If generator is NULL, will safely return false. 39 * If generator is NULL, will safely return false.
39 * 40 *
(...skipping 23 matching lines...) Expand all
63 public: 64 public:
64 /** 65 /**
65 * The PixelRef which takes ownership of this SkImageGenerator 66 * The PixelRef which takes ownership of this SkImageGenerator
66 * will call the image generator's destructor. 67 * will call the image generator's destructor.
67 */ 68 */
68 virtual ~SkImageGenerator() { } 69 virtual ~SkImageGenerator() { }
69 70
70 uint32_t uniqueID() const { return fUniqueID; } 71 uint32_t uniqueID() const { return fUniqueID; }
71 72
72 /** 73 /**
73 * Return a ref to the encoded (i.e. compressed) representation, 74 * Return a ref to the encoded (i.e. compressed) representation of the imag e, or null if
74 * of this data. If the GrContext is non-null, then the caller is only inte rested in 75 * no such encoded form is readily available. This is not meant to trigger a full-blown
75 * gpu-specific formats, so the impl may return null even if they have enco ded data, 76 * encoding step, as the caller can always perform that itself. This is mea nt to give the
76 * assuming they know it is not suitable for the gpu. 77 * caller quick access to the encoded version iff it is already available.
77 * 78 *
78 * If non-NULL is returned, the caller is responsible for calling 79 * If query is non-null, then the implementation may choose to query it (mu ltiple times if
79 * unref() on the data when it is finished. 80 * needed) to preflight if a given format is supported. That query takes a snippet from the
81 * beginning of the encoded data. If the generator readily has the encoded data available,
82 * it may ignore the bot and just return it. However, if there is a perform ance or other
reed1 2016/04/07 13:27:31 "bot"?
scroggo_chromium 2016/04/08 18:16:36 Oops, I replaced the first instance of "bot" in yo
scroggo_chromium 2016/04/12 14:41:19 Removed.
83 * constraint on returning the encoded data, calling the bot allows the gen erator to discover
reed1 2016/04/07 13:27:31 Slightly confusing dox, as the first paragraph say
scroggo_chromium 2016/04/08 18:16:36 Acknowledged.
scroggo_chromium 2016/04/12 14:41:19 Agreed. I've updated the comment with an example (
84 * if their format is not supported, in which case the generator should jus t return null.
80 */ 85 */
81 SkData* refEncodedData(GrContext* ctx = nullptr) { 86 SkData* refEncodedData(SkEncodedFormatQuery* query = nullptr) {
82 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX 87 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
83 return this->onRefEncodedData(); 88 return this->onRefEncodedData();
84 #else 89 #else
85 return this->onRefEncodedData(ctx); 90 return this->onRefEncodedData(query);
86 #endif 91 #endif
87 } 92 }
88 93
89 /** 94 /**
90 * Return the ImageInfo associated with this generator. 95 * Return the ImageInfo associated with this generator.
91 */ 96 */
92 const SkImageInfo& getInfo() const { return fInfo; } 97 const SkImageInfo& getInfo() const { return fInfo; }
93 98
94 /** 99 /**
95 * Decode into the given pixels, a block of memory of size at 100 * Decode into the given pixels, a block of memory of size at
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 const SkImageInfo fInfo; 287 const SkImageInfo fInfo;
283 const uint32_t fUniqueID; 288 const uint32_t fUniqueID;
284 289
285 // This is our default impl, which may be different on different platforms. 290 // This is our default impl, which may be different on different platforms.
286 // It is called from NewFromEncoded() after it has checked for any runtime f actory. 291 // It is called from NewFromEncoded() after it has checked for any runtime f actory.
287 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. 292 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded.
288 static SkImageGenerator* NewFromEncodedImpl(SkData*); 293 static SkImageGenerator* NewFromEncodedImpl(SkData*);
289 }; 294 };
290 295
291 #endif // SkImageGenerator_DEFINED 296 #endif // SkImageGenerator_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698