OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... | |
37 * | 37 * |
38 * SkImage always has a non-zero dimensions. If there is a request to create a new image, either | 38 * SkImage always has a non-zero dimensions. If there is a request to create a new image, either |
39 * directly or via SkSurface, and either of the requested dimensions are zero, then NULL will be | 39 * directly or via SkSurface, and either of the requested dimensions are zero, then NULL will be |
40 * returned. | 40 * returned. |
41 */ | 41 */ |
42 class SK_API SkImage : public SkRefCnt { | 42 class SK_API SkImage : public SkRefCnt { |
43 public: | 43 public: |
44 SK_DECLARE_INST_COUNT(SkImage) | 44 SK_DECLARE_INST_COUNT(SkImage) |
45 | 45 |
46 typedef SkImageInfo Info; | 46 typedef SkImageInfo Info; |
47 typedef void* ReleaseContext; | |
47 | 48 |
48 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es); | 49 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es); |
49 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); | 50 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); |
50 | 51 |
52 typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext); | |
53 | |
54 /** | |
robertphillips
2015/06/05 15:57:06
especified?
reed1
2015/06/17 13:25:34
Done.
| |
55 * Return a new Image referencing th especified pixels. These must remain v alid and unchanged | |
56 * until the specified release-proc is called, indicating that Skia no long er has a reference | |
57 * to the pixels. | |
58 * | |
59 * Returns NULL if the requested Info is unsupported. | |
60 */ | |
61 static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowByt es, | |
62 RasterReleaseProc, ReleaseContext); | |
63 | |
51 /** | 64 /** |
52 * Construct a new SkImage based on the given ImageGenerator. | 65 * Construct a new SkImage based on the given ImageGenerator. |
53 * This function will always take ownership of the passed | 66 * This function will always take ownership of the passed |
54 * ImageGenerator. Returns NULL on error. | 67 * ImageGenerator. Returns NULL on error. |
55 */ | 68 */ |
56 static SkImage* NewFromGenerator(SkImageGenerator*); | 69 static SkImage* NewFromGenerator(SkImageGenerator*); |
57 | 70 |
58 /** | 71 /** |
59 * Construct a new SkImage based on the specified encoded data. Returns NUL L on failure, | 72 * Construct a new SkImage based on the specified encoded data. Returns NUL L on failure, |
60 * which can mean that the format of the encoded data was not recognized/su pported. | 73 * which can mean that the format of the encoded data was not recognized/su pported. |
61 * | 74 * |
62 * Regardless of success or failure, the caller is responsible for managing their ownership | 75 * Regardless of success or failure, the caller is responsible for managing their ownership |
63 * of the data. | 76 * of the data. |
64 */ | 77 */ |
65 static SkImage* NewFromData(SkData* data); | 78 static SkImage* NewFromData(SkData* data); |
66 | 79 |
67 /** | 80 /** |
68 * Create a new image from the specified descriptor. Note - the caller is r esponsible for | 81 * Create a new image from the specified descriptor. Note - the caller is r esponsible for |
69 * managing the lifetime of the underlying platform texture. | 82 * managing the lifetime of the underlying platform texture. |
70 * | 83 * |
71 * Will return NULL if the specified descriptor is unsupported. | 84 * Will return NULL if the specified descriptor is unsupported. |
72 */ | 85 */ |
73 static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, | 86 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d esc) { |
74 SkAlphaType = kPremul_SkAlphaType); | 87 return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL); |
88 } | |
89 | |
90 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d e, SkAlphaType at) { | |
91 return NewFromTexture(ctx, de, at, NULL, NULL); | |
92 } | |
93 | |
94 typedef void (*TextureReleaseProc)(GrBackendObject, ReleaseContext); | |
95 | |
96 /** | |
97 * Create a new image from the specified descriptor. The underlying platfor m texture must stay | |
98 * valid and unaltered until the specified release-proc is invoked, indicat ing that Skia | |
99 * nolonger is holding a reference to it. | |
100 * | |
101 * Will return NULL if the specified descriptor is unsupported. | |
102 */ | |
103 static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAl phaType, | |
104 TextureReleaseProc, ReleaseContext); | |
75 | 105 |
76 /** | 106 /** |
77 * Create a new image by copying the pixels from the specified descriptor. No reference is | 107 * Create a new image by copying the pixels from the specified descriptor. No reference is |
78 * kept to the original platform texture. | 108 * kept to the original platform texture. |
79 * | 109 * |
80 * Will return NULL if the specified descriptor is unsupported. | 110 * Will return NULL if the specified descriptor is unsupported. |
81 */ | 111 */ |
82 static SkImage* NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, | 112 static SkImage* NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, |
83 SkAlphaType = kPremul_SkAlphaType); | 113 SkAlphaType = kPremul_SkAlphaType); |
84 | 114 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 const int fWidth; | 226 const int fWidth; |
197 const int fHeight; | 227 const int fHeight; |
198 const uint32_t fUniqueID; | 228 const uint32_t fUniqueID; |
199 | 229 |
200 static uint32_t NextUniqueID(); | 230 static uint32_t NextUniqueID(); |
201 | 231 |
202 typedef SkRefCnt INHERITED; | 232 typedef SkRefCnt INHERITED; |
203 }; | 233 }; |
204 | 234 |
205 #endif | 235 #endif |
OLD | NEW |