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 /** |
| 55 * Return a new Image referencing the specified 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)(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 from the specified descriptor. Note - Skia will delet
e or recycle the | 107 * Create a new image from the specified descriptor. Note - Skia will delet
e or recycle the |
78 * texture when the image is released. | 108 * texture when the image is released. |
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* NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc
&, | 112 static SkImage* NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc
&, |
83 SkAlphaType = kPremul_SkAlphaType); | 113 SkAlphaType = kPremul_SkAlphaType); |
84 | 114 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const int fWidth; | 243 const int fWidth; |
214 const int fHeight; | 244 const int fHeight; |
215 const uint32_t fUniqueID; | 245 const uint32_t fUniqueID; |
216 | 246 |
217 static uint32_t NextUniqueID(); | 247 static uint32_t NextUniqueID(); |
218 | 248 |
219 typedef SkRefCnt INHERITED; | 249 typedef SkRefCnt INHERITED; |
220 }; | 250 }; |
221 | 251 |
222 #endif | 252 #endif |
OLD | NEW |