Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1 | #Topic Image |
| 2 | #Alias Image_Reference |
| 3 | |
| 4 | #Class SkImage |
| 5 | |
| 6 | SkImage is an abstraction for drawing a rectangle of pixels, though the |
| 7 | particular type of image could be actually storing its data on the GPU, or |
| 8 | as drawing commands (picture or PDF or otherwise), ready to be played back |
| 9 | into another canvas. |
| 10 | The content of SkImage is always immutable, though the actual storage may |
| 11 | change, if for example that image can be re-created via encoded data or |
| 12 | other means. |
| 13 | SkImage always has a non-zero dimensions. If there is a request to create a new |
| 14 | image, either directly or via SkSurface, and either of the requested dimensions |
| 15 | are zero, then nullptr will be returned. |
| 16 | |
| 17 | #Topic Overview |
| 18 | |
| 19 | #Subtopic Subtopics |
| 20 | #ToDo manually add subtopics ## |
| 21 | #Table |
| 22 | #Legend |
| 23 | # topics # description ## |
| 24 | #Legend ## |
| 25 | #Table ## |
| 26 | ## |
| 27 | |
| 28 | #Subtopic Structs |
| 29 | #Table |
| 30 | #Legend |
| 31 | # description # struct ## |
| 32 | #Legend ## |
| 33 | # DeferredTextureImageUsageParams # ## |
| 34 | #Table ## |
| 35 | #Subtopic ## |
| 36 | |
| 37 | #Subtopic Member_Functions |
| 38 | #Table |
| 39 | #Legend |
| 40 | # description # function ## |
| 41 | #Legend ## |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 42 | # MakeBackendTextureFromSkImage # Creates GPU texture from Image. ## |
| 43 | # MakeCrossContextFromEncoded # Creates Image from encoded data, and uploads to GPU. ## |
| 44 | # MakeFromAHardwareBuffer # Creates Image from Android hardware buffer. ## |
| 45 | # MakeFromAdoptedTexture # Creates Image from GPU texture, managed internally. ## |
| 46 | # MakeFromBitmap # Creates Image from Bitmap, sharing or copying pixels. ## |
| 47 | # MakeFromDeferredTextureImageData # Creates Image from GPU texture data retrieved earlier. ## |
| 48 | # MakeFromEncoded # Creates Image from encoded data. ## |
| 49 | # MakeFromGenerator # Creates Image from a stream of data. ## |
| 50 | # MakeFromNV12TexturesCopy # Creates Image from YUV_ColorSpace data in two planes. ## |
| 51 | # MakeFromPicture # Creates Image from Picture. ## |
| 52 | # MakeFromRaster # Creates Image from Pixmap, with release. ## |
| 53 | # MakeFromTexture # Creates Image from GPU texture, managed externally. ## |
| 54 | # MakeFromYUVTexturesCopy # Creates Image from YUV_ColorSpace data in three planes. ## |
| 55 | # MakeRasterCopy # Creates Image from Pixmap and copied pixels. ## |
| 56 | # MakeRasterData # Creates Image from Image_Info and shared pixels. ## |
| 57 | # alphaType # Returns Alpha_Type ## |
| 58 | # asLegacyBitmap # Returns as raster Bitmap ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 59 | # bounds # ## |
| 60 | # colorSpace # ## |
| 61 | # dimensions # ## |
| 62 | # encodeToData # ## |
| 63 | # getDeferredTextureImageData # ## |
| 64 | # getTexture # ## |
| 65 | # getTextureHandle # ## |
| 66 | # height # ## |
| 67 | # isAlphaOnly # ## |
| 68 | # isLazyGenerated # ## |
| 69 | # isOpaque # ## |
| 70 | # isTextureBacked # ## |
| 71 | # isValid # ## |
| 72 | # makeColorSpace # ## |
| 73 | # makeNonTextureImage # ## |
| 74 | # makeShader # ## |
| 75 | # makeSubset # ## |
| 76 | # makeTextureImage # ## |
| 77 | # makeWithFilter # ## |
| 78 | # peekPixels # ## |
| 79 | # readPixels # ## |
| 80 | # refColorSpace # ## |
| 81 | # refEncodedData # ## |
| 82 | # scalePixels # ## |
| 83 | # toString # ## |
| 84 | # uniqueID # ## |
| 85 | # width # ## |
| 86 | #Table ## |
| 87 | #Subtopic ## |
| 88 | |
| 89 | #Topic ## |
| 90 | |
| 91 | # ------------------------------------------------------------------------------ |
| 92 | |
| 93 | #Struct DeferredTextureImageUsageParams |
| 94 | |
| 95 | #Code |
| 96 | #ToDo fill this in manually ## |
| 97 | ## |
| 98 | |
| 99 | Drawing parameters for which a deferred texture image data should be optimized. */ |
| 100 | |
| 101 | # ------------------------------------------------------------------------------ |
| 102 | |
| 103 | #Method DeferredTextureImageUsageParams(const SkMatrix matrix, const SkFilterQuality quality, |
| 104 | int preScaleMipLevel) |
| 105 | |
| 106 | #Param matrix incomplete ## |
| 107 | #Param quality incomplete ## |
| 108 | #Param preScaleMipLevel incomplete ## |
| 109 | |
| 110 | #Return incomplete ## |
| 111 | |
| 112 | #Example |
| 113 | // incomplete |
| 114 | ## |
| 115 | |
| 116 | #SeeAlso incomplete |
| 117 | |
| 118 | #Method ## |
| 119 | |
| 120 | #Member SkMatrix fMatrix |
| 121 | ## |
| 122 | |
| 123 | #Member SkFilterQuality fQuality |
| 124 | ## |
| 125 | |
| 126 | #Member int fPreScaleMipLevel |
| 127 | ## |
| 128 | |
| 129 | #Struct DeferredTextureImageUsageParams ## |
| 130 | |
| 131 | #Typedef SkImageInfo Info |
| 132 | |
| 133 | ## |
| 134 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 135 | # ------------------------------------------------------------------------------ |
| 136 | |
| 137 | #Method static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap) |
| 138 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 139 | Creates Image from Pixmap and copy of pixels. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 140 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 141 | Image is returned if Pixmap is valid. Valid Pixmap parameters include: |
| 142 | dimensions are greater than zero; |
| 143 | each dimension fits in 29 bits; |
| 144 | Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; |
| 145 | row bytes are large enough to hold one row of pixels; |
| 146 | pixel address is not nullptr. |
| 147 | |
| 148 | #Param pixmap Image_Info, pixel address, and row bytes ## |
| 149 | |
| 150 | #Return copy of Pixmap pixels, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 151 | |
| 152 | #Example |
| 153 | // incomplete |
| 154 | ## |
| 155 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 156 | #SeeAlso MakeRasterData MakeFromGenerator |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 157 | |
| 158 | #Method ## |
| 159 | |
| 160 | # ------------------------------------------------------------------------------ |
| 161 | |
| 162 | #Method static sk_sp<SkImage> MakeRasterData(const Info& info, sk_sp<SkData> pixels, size_t rowBytes) |
| 163 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 164 | Creates Image from Image_Info, sharing pixels. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 165 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 166 | Image is returned if Image_Info is valid. Valid Image_Info parameters include: |
| 167 | dimensions are greater than zero; |
| 168 | each dimension fits in 29 bits; |
| 169 | Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; |
| 170 | rowBytes are large enough to hold one row of pixels; |
| 171 | pixels is not nullptr, and contains enough data for Image. |
| 172 | |
| 173 | #Param info contains width, height, Alpha_Type, Color_Type, Color_Space ## |
| 174 | #Param pixels address or pixel storage ## |
| 175 | #Param rowBytes size of pixel row or larger ## |
| 176 | |
| 177 | #Return Image sharing pixels, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 178 | |
| 179 | #Example |
| 180 | // incomplete |
| 181 | ## |
| 182 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 183 | #SeeAlso MakeRasterCopy MakeFromGenerator |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 184 | |
| 185 | #Method ## |
| 186 | |
| 187 | # ------------------------------------------------------------------------------ |
| 188 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 189 | #Typedef void* ReleaseContext |
| 190 | |
| 191 | Caller data passed to RasterReleaseProc; may be nullptr. |
| 192 | |
| 193 | #SeeAlso MakeFromRaster RasterReleaseProc |
| 194 | |
| 195 | ## |
| 196 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 197 | #Typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext) |
| 198 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 199 | Function called when Image no longer shares pixels. ReleaseContext is |
| 200 | provided by caller when Image is created, and may be nullptr. |
| 201 | |
| 202 | #SeeAlso ReleaseContext MakeFromRaster |
| 203 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 204 | ## |
| 205 | |
| 206 | #Method static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap, |
| 207 | RasterReleaseProc rasterReleaseProc, |
| 208 | ReleaseContext releaseContext) |
| 209 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 210 | Creates Image from pixmap, sharing pixmap pixels. Pixels must remain valid and |
| 211 | unchanged until rasterReleaseProc is called. rasterReleaseProc is passed |
| 212 | releaseContext when Image is deleted or no longer refers to pixmap pixels. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 213 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 214 | Image is returned if pixmap is valid. Valid Pixmap parameters include: |
| 215 | dimensions are greater than zero; |
| 216 | each dimension fits in 29 bits; |
| 217 | Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; |
| 218 | row bytes are large enough to hold one row of pixels; |
| 219 | pixel address is not nullptr. |
| 220 | |
| 221 | #Param pixmap Image_Info, pixel address, and row bytes ## |
| 222 | #Param rasterReleaseProc function called when pixels can be released ## |
| 223 | #Param releaseContext state passed to rasterReleaseProc ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 224 | |
| 225 | #Return incomplete ## |
| 226 | |
| 227 | #Example |
| 228 | // incomplete |
| 229 | ## |
| 230 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 231 | #SeeAlso MakeRasterCopy MakeRasterData MakeFromGenerator RasterReleaseProc ReleaseContext |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 232 | |
| 233 | #Method ## |
| 234 | |
| 235 | # ------------------------------------------------------------------------------ |
| 236 | |
| 237 | #Method static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap) |
| 238 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 239 | Creates Image from bitmap, sharing or copying bitmap pixels. If the bitmap |
| 240 | is marked immutable, and its pixel memory is shareable, it may be shared |
| 241 | instead of copied. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 242 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 243 | Image is returned if bitmap is valid. Valid Bitmap parameters include: |
| 244 | dimensions are greater than zero; |
| 245 | each dimension fits in 29 bits; |
| 246 | Color_Type and Alpha_Type are valid, and Color_Type is not kUnknown_SkColorType; |
| 247 | row bytes are large enough to hold one row of pixels; |
| 248 | pixel address is not nullptr. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 249 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 250 | #Param bitmap Image_Info, row bytes, and pixels ## |
| 251 | |
| 252 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 253 | |
| 254 | #Example |
| 255 | // incomplete |
| 256 | ## |
| 257 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 258 | #SeeAlso MakeFromRaster MakeRasterCopy MakeFromGenerator MakeRasterData |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 259 | |
| 260 | #Method ## |
| 261 | |
| 262 | # ------------------------------------------------------------------------------ |
| 263 | |
| 264 | #Method static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator, |
| 265 | const SkIRect* subset = nullptr) |
| 266 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 267 | Creates Image based from imageGenerator. |
| 268 | Takes ownership of imageGenerator; it may not be used elsewhere. |
| 269 | If subset is not nullptr, it must be contained within imageGenerator data bounds. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 270 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 271 | Image is returned if generator data is valid. Valid data parameters vary |
| 272 | by type of data and platform. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 273 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 274 | imageGenerator may wrap Picture data, codec data, or custom data. |
| 275 | |
| 276 | #Param imageGenerator stock or custom routines to retrieve Image ## |
| 277 | #Param subset bounds of returned Image; may be nullptr ## |
| 278 | |
| 279 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 280 | |
| 281 | #Example |
| 282 | // incomplete |
| 283 | ## |
| 284 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 285 | #SeeAlso MakeFromEncoded |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 286 | |
| 287 | #Method ## |
| 288 | |
| 289 | # ------------------------------------------------------------------------------ |
| 290 | |
| 291 | #Method static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr) |
| 292 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 293 | Creates Image from encoded data. |
| 294 | If a subset is not nullptr, it must be contained within encoded data bounds. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 295 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 296 | Image is returned if format of the encoded data is recognized and supported. |
| 297 | Recognized formats vary by platfrom. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 298 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 299 | #Param encoded data of Image to decode ## |
| 300 | #Param subset bounds of returned Image; may be nullptr ## |
| 301 | |
| 302 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 303 | |
| 304 | #Example |
| 305 | // incomplete |
| 306 | ## |
| 307 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 308 | #SeeAlso MakeFromGenerator |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 309 | |
| 310 | #Method ## |
| 311 | |
| 312 | # ------------------------------------------------------------------------------ |
| 313 | |
| 314 | #Typedef void (*TextureReleaseProc)(ReleaseContext releaseContext) |
| 315 | |
| 316 | ## |
| 317 | |
| 318 | #Method static sk_sp<SkImage> MakeFromTexture(GrContext* context, |
| 319 | const GrBackendTexture& backendTexture, |
| 320 | GrSurfaceOrigin origin, |
| 321 | SkAlphaType alphaType, |
| 322 | sk_sp<SkColorSpace> colorSpace) |
| 323 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 324 | Creates Image from GPU texture associated with context. Caller is responsible for |
| 325 | managing the lifetime of GPU texture. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 326 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 327 | Image is returned if format of backendTexture is recognized and supported. |
| 328 | Recognized formats vary by GPU back-end. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 329 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 330 | #Param context GPU_Context ## |
| 331 | #Param backendTexture texture residing on GPU ## |
| 332 | #Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## |
| 333 | #Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, |
| 334 | kPremul_SkAlphaType, kUnpremul_SkAlphaType |
| 335 | ## |
| 336 | #Param colorSpace range of colors ## |
| 337 | |
| 338 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 339 | |
| 340 | #Example |
| 341 | // incomplete |
| 342 | ## |
| 343 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 344 | #SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 345 | |
| 346 | #Method ## |
| 347 | |
| 348 | # ------------------------------------------------------------------------------ |
| 349 | |
| 350 | #Method static sk_sp<SkImage> MakeFromTexture(GrContext* context, |
| 351 | const GrBackendTexture& backendTexture, |
| 352 | GrSurfaceOrigin origin, |
| 353 | SkAlphaType alphaType, |
| 354 | sk_sp<SkColorSpace> colorSpace, |
| 355 | TextureReleaseProc textureReleaseProc, |
| 356 | ReleaseContext releaseContext) |
| 357 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 358 | Creates Image from GPU texture associated with context. GPU texture must stay |
| 359 | valid and unchanged until textureReleaseProc is called. textureReleaseProc is |
| 360 | passed releaseContext when Image is deleted or no longer refers to texture. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 361 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 362 | Image is returned if format of backendTexture is recognized and supported. |
| 363 | Recognized formats vary by GPU back-end. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 364 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 365 | #Param context GPU_Context ## |
| 366 | #Param backendTexture texture residing on GPU ## |
| 367 | #Param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## |
| 368 | #Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, |
| 369 | kPremul_SkAlphaType, kUnpremul_SkAlphaType |
| 370 | ## |
| 371 | #Param colorSpace range of colors ## |
| 372 | #Param textureReleaseProc function called when texture can be released ## |
| 373 | #Param releaseContext state passed to textureReleaseProc ## |
| 374 | |
| 375 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 376 | |
| 377 | #Example |
| 378 | // incomplete |
| 379 | ## |
| 380 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 381 | #SeeAlso MakeFromAdoptedTexture SkSurface::MakeFromBackendTexture |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 382 | |
| 383 | #Method ## |
| 384 | |
| 385 | # ------------------------------------------------------------------------------ |
| 386 | |
| 387 | #Method static sk_sp<SkImage> MakeCrossContextFromEncoded(GrContext* context, sk_sp<SkData> data, |
| 388 | bool buildMips, |
| 389 | SkColorSpace* dstColorSpace) |
| 390 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 391 | Creates Image from encoded data. Image is uploaded to GPU back-end using context. |
| 392 | |
| 393 | Created Image is available to other GPU contexts, and is available across thread |
| 394 | boundaries. All contexts must be in the same GPU_Share_Group, or otherwise |
| 395 | share resources. |
| 396 | |
| 397 | When Image is no longer referenced, context releases texture memory |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 398 | asynchronously. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 399 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 400 | Texture decoded from data is uploaded to match Surface created with |
| 401 | dstColorSpace. Color_Space of Image is determined by encoded data. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 402 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 403 | Image is returned if format of data is recognized and supported, and if context |
| 404 | supports moving resources. Recognized formats vary by platform and GPU back-end. |
| 405 | |
| 406 | #Param context GPU_Context ## |
| 407 | #Param data Image to decode ## |
| 408 | #Param buildMips create Image as Mip_Map if true ## |
| 409 | #Param dstColorSpace range of colors of matching Surface on GPU ## |
| 410 | |
| 411 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 412 | |
| 413 | #Example |
| 414 | // incomplete |
| 415 | ## |
| 416 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 417 | #SeeAlso MakeCrossContextFromPixmap |
| 418 | |
| 419 | #Method ## |
| 420 | |
| 421 | # ------------------------------------------------------------------------------ |
| 422 | |
| 423 | #Method static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap, |
| 424 | bool buildMips, |
| 425 | SkColorSpace* dstColorSpace) |
| 426 | |
| 427 | Creates Image from pixmap. Image is uploaded to GPU back-end using context. |
| 428 | |
| 429 | Created Image is available to other GPU contexts, and is available across thread |
| 430 | boundaries. All contexts must be in the same GPU_Share_Group, or otherwise |
| 431 | share resources. |
| 432 | |
| 433 | When Image is no longer referenced, context releases texture memory |
| 434 | asynchronously. |
| 435 | |
| 436 | Texture created from pixmap is uploaded to match Surface created with |
| 437 | dstColorSpace. Color_Space of Image is determined by pixmap.colorSpace(). |
| 438 | |
| 439 | Image is returned referring to GPU back-end if format of data is recognized and |
| 440 | supported, and if context supports moving resources. Otherwise, pixmap pixel |
| 441 | data is copied and Image as returned in raster format if possible; nullptr may |
| 442 | be returned. Recognized GPU formats vary by platform and GPU back-end. |
| 443 | |
| 444 | #Param context GPU_Context ## |
| 445 | #Param pixmap Image_Info, pixel address, and row bytes ## |
| 446 | #Param buildMips create Image as Mip_Map if true ## |
| 447 | #Param dstColorSpace range of colors of matching Surface on GPU ## |
| 448 | |
| 449 | #Return created Image, or nullptr ## |
| 450 | |
| 451 | #Example |
| 452 | // incomplete |
| 453 | ## |
| 454 | |
| 455 | #SeeAlso MakeCrossContextFromEncoded |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 456 | |
| 457 | #Method ## |
| 458 | |
| 459 | # ------------------------------------------------------------------------------ |
| 460 | |
| 461 | #Method static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context, |
| 462 | const GrBackendTexture& backendTexture, |
| 463 | GrSurfaceOrigin surfaceOrigin, |
| 464 | SkAlphaType alphaType = kPremul_SkAlphaType, |
| 465 | sk_sp<SkColorSpace> colorSpace = nullptr) |
| 466 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 467 | Creates Image from backendTexture associated with context. backendTexture and |
| 468 | returned Image are managed internally, and are released when no longer needed. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 469 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 470 | Image is returned if format of backendTexture is recognized and supported. |
| 471 | Recognized formats vary by GPU back-end. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 472 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 473 | #Param context GPU_Context ## |
| 474 | #Param backendTexture texture residing on GPU ## |
| 475 | #Param surfaceOrigin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin ## |
| 476 | #Param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, |
| 477 | kPremul_SkAlphaType, kUnpremul_SkAlphaType |
| 478 | ## |
| 479 | #Param colorSpace range of colors ## |
| 480 | |
| 481 | #Return created Image, or nullptr ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 482 | |
| 483 | #Example |
| 484 | // incomplete |
| 485 | ## |
| 486 | |
| 487 | #SeeAlso incomplete |
| 488 | |
| 489 | #Method ## |
| 490 | |
| 491 | # ------------------------------------------------------------------------------ |
| 492 | |
| 493 | #Method static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace, |
| 494 | const GrBackendObject yuvTextureHandles[3], |
| 495 | const SkISize yuvSizes[3], |
| 496 | GrSurfaceOrigin surfaceOrigin, |
| 497 | sk_sp<SkColorSpace> colorSpace = nullptr) |
| 498 | |
| 499 | Create a new image by copying the pixels from the specified y, u, v textures. The data |
| 500 | from the textures is immediately ingested into the image and the textures can be modified or |
| 501 | deleted after the function returns. The image will have the dimensions of the y texture. |
| 502 | |
| 503 | #Param context incomplete ## |
| 504 | #Param yuvColorSpace incomplete ## |
| 505 | #Param yuvTextureHandles incomplete ## |
| 506 | #Param yuvSizes incomplete ## |
| 507 | #Param surfaceOrigin incomplete ## |
| 508 | #Param colorSpace incomplete ## |
| 509 | |
| 510 | #Return incomplete ## |
| 511 | |
| 512 | #Example |
| 513 | // incomplete |
| 514 | ## |
| 515 | |
| 516 | #SeeAlso incomplete |
| 517 | |
| 518 | #Method ## |
| 519 | |
| 520 | # ------------------------------------------------------------------------------ |
| 521 | |
| 522 | #Method static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext* context, |
| 523 | SkYUVColorSpace yuvColorSpace, |
| 524 | const GrBackendObject nv12TextureHandles[2], |
| 525 | const SkISize nv12Sizes[2], |
| 526 | GrSurfaceOrigin surfaceOrigin, |
| 527 | sk_sp<SkColorSpace> colorSpace = nullptr) |
| 528 | |
| 529 | Create a new image by copying the pixels from the specified y and UV_Mapping. The data |
| 530 | from the textures is immediately ingested into the image and the textures can be modified or |
| 531 | deleted after the function returns. The image will have the dimensions of the y texture. |
| 532 | |
| 533 | #Param context incomplete ## |
| 534 | #Param yuvColorSpace incomplete ## |
| 535 | #Param nv12TextureHandles incomplete ## |
| 536 | #Param nv12Sizes incomplete ## |
| 537 | #Param surfaceOrigin incomplete ## |
| 538 | #Param colorSpace incomplete ## |
| 539 | |
| 540 | #Return incomplete ## |
| 541 | |
| 542 | #Example |
| 543 | // incomplete |
| 544 | ## |
| 545 | |
| 546 | #SeeAlso incomplete |
| 547 | |
| 548 | #Method ## |
| 549 | |
| 550 | # ------------------------------------------------------------------------------ |
| 551 | |
| 552 | #Enum BitDepth |
| 553 | |
| 554 | #Code |
| 555 | enum BitDepth { |
| 556 | kU8, |
| 557 | kF16, |
| 558 | }; |
| 559 | ## |
| 560 | |
| 561 | #Const kU8 0 |
| 562 | ## |
| 563 | #Const kF16 1 |
| 564 | ## |
| 565 | |
| 566 | #Example |
| 567 | // incomplete |
| 568 | ## |
| 569 | |
| 570 | #SeeAlso incomplete |
| 571 | |
| 572 | #Enum ## |
| 573 | |
| 574 | # ------------------------------------------------------------------------------ |
| 575 | |
| 576 | #Method static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions, |
| 577 | const SkMatrix* matrix, const SkPaint* paint, |
| 578 | BitDepth bitDepth, |
| 579 | sk_sp<SkColorSpace> colorSpace) |
| 580 | |
| 581 | Create a new image from the specified picture. |
| 582 | On creation of the SkImage, snap the SkPicture to a particular BitDepth and SkColorSpace. |
| 583 | |
| 584 | #Param picture incomplete ## |
| 585 | #Param dimensions incomplete ## |
| 586 | #Param matrix incomplete ## |
| 587 | #Param paint incomplete ## |
| 588 | #Param bitDepth incomplete ## |
| 589 | #Param colorSpace incomplete ## |
| 590 | |
| 591 | #Return incomplete ## |
| 592 | |
| 593 | #Example |
| 594 | // incomplete |
| 595 | ## |
| 596 | |
| 597 | #SeeAlso incomplete |
| 598 | |
| 599 | #Method ## |
| 600 | |
| 601 | # ------------------------------------------------------------------------------ |
| 602 | |
| 603 | #Method static sk_sp<SkImage> MakeFromAHardwareBuffer(AHardwareBuffer* hardwareBuffer, |
| 604 | SkAlphaType alphaType = kPremul_SkAlphaType, |
| 605 | sk_sp<SkColorSpace> colorSpace = nullptr) |
| 606 | |
| 607 | Create a new image from the an Android hardware buffer. |
| 608 | The new image takes a reference on the buffer. |
| 609 | |
| 610 | Only available on Android, when __ANDROID_API__ is defined to be 26 or greater. |
| 611 | |
| 612 | #Param hardwareBuffer incomplete ## |
| 613 | #Param alphaType incomplete ## |
| 614 | #Param colorSpace incomplete ## |
| 615 | |
| 616 | #Return incomplete ## |
| 617 | |
| 618 | #Example |
| 619 | // incomplete |
| 620 | ## |
| 621 | |
| 622 | #SeeAlso incomplete |
| 623 | |
| 624 | #Method ## |
| 625 | |
| 626 | # ------------------------------------------------------------------------------ |
| 627 | |
| 628 | #Method static sk_sp<SkImage> MakeFromAHardwareBuffer(AHardwareBuffer* hardwareBuffer, |
| 629 | SkAlphaType alphaType = kPremul_SkAlphaType, |
| 630 | sk_sp<SkColorSpace> colorSpace = nullptr) |
| 631 | |
| 632 | Create a new image from the an Android hardware buffer. |
| 633 | The new image takes a reference on the buffer. |
| 634 | |
| 635 | #Param hardwareBuffer incomplete ## |
| 636 | #Param alphaType incomplete ## |
| 637 | #Param colorSpace incomplete ## |
| 638 | |
| 639 | #Return incomplete ## |
| 640 | |
| 641 | #Example |
| 642 | // incomplete |
| 643 | ## |
| 644 | |
| 645 | #SeeAlso incomplete |
| 646 | |
| 647 | #Method ## |
| 648 | |
| 649 | # ------------------------------------------------------------------------------ |
| 650 | |
| 651 | #Method int width() const |
| 652 | |
| 653 | #Return incomplete ## |
| 654 | |
| 655 | #Example |
| 656 | // incomplete |
| 657 | ## |
| 658 | |
| 659 | #SeeAlso incomplete |
| 660 | |
| 661 | #Method ## |
| 662 | |
| 663 | # ------------------------------------------------------------------------------ |
| 664 | |
| 665 | #Method int height() const |
| 666 | |
| 667 | #Return incomplete ## |
| 668 | |
| 669 | #Example |
| 670 | // incomplete |
| 671 | ## |
| 672 | |
| 673 | #SeeAlso incomplete |
| 674 | |
| 675 | #Method ## |
| 676 | |
| 677 | # ------------------------------------------------------------------------------ |
| 678 | |
| 679 | #Method SkISize dimensions() const |
| 680 | |
| 681 | #Return incomplete ## |
| 682 | |
| 683 | #Example |
| 684 | // incomplete |
| 685 | ## |
| 686 | |
| 687 | #SeeAlso incomplete |
| 688 | |
| 689 | #Method ## |
| 690 | |
| 691 | # ------------------------------------------------------------------------------ |
| 692 | |
| 693 | #Method SkIRect bounds() const |
| 694 | |
| 695 | #Return incomplete ## |
| 696 | |
| 697 | #Example |
| 698 | // incomplete |
| 699 | ## |
| 700 | |
| 701 | #SeeAlso incomplete |
| 702 | |
| 703 | #Method ## |
| 704 | |
| 705 | # ------------------------------------------------------------------------------ |
| 706 | |
| 707 | #Method uint32_t uniqueID() const |
| 708 | |
| 709 | #Return incomplete ## |
| 710 | |
| 711 | #Example |
| 712 | // incomplete |
| 713 | ## |
| 714 | |
| 715 | #SeeAlso incomplete |
| 716 | |
| 717 | #Method ## |
| 718 | |
| 719 | # ------------------------------------------------------------------------------ |
| 720 | |
| 721 | #Method SkAlphaType alphaType() const |
| 722 | |
| 723 | #Return incomplete ## |
| 724 | |
| 725 | #Example |
| 726 | // incomplete |
| 727 | ## |
| 728 | |
| 729 | #SeeAlso incomplete |
| 730 | |
| 731 | #Method ## |
| 732 | |
| 733 | # ------------------------------------------------------------------------------ |
| 734 | |
| 735 | #Method SkColorSpace* colorSpace() const |
| 736 | |
| 737 | Returns Color_Space of Image. Color_Space may have been a parameter when |
| 738 | Image was created, or may have been parsed from encoded data. Skia may not be |
| 739 | able to draw image respecting returned Color_Space or draw into Surface with |
| 740 | returned Color_Space. |
| 741 | |
| 742 | #Return Color_Space Image was created with, or nullptr ## |
| 743 | |
| 744 | #Example |
| 745 | // incomplete |
| 746 | ## |
| 747 | |
| 748 | #SeeAlso incomplete |
| 749 | |
| 750 | #Method ## |
| 751 | |
| 752 | # ------------------------------------------------------------------------------ |
| 753 | |
| 754 | #Method sk_sp<SkColorSpace> refColorSpace() const |
| 755 | |
| 756 | #Return incomplete ## |
| 757 | |
| 758 | #Example |
| 759 | // incomplete |
| 760 | ## |
| 761 | |
| 762 | #SeeAlso incomplete |
| 763 | |
| 764 | #Method ## |
| 765 | |
| 766 | # ------------------------------------------------------------------------------ |
| 767 | |
| 768 | #Method bool isAlphaOnly() const |
| 769 | |
| 770 | Returns true fi the image will be drawn as a mask, with no intrinsic color of its own. |
| 771 | |
| 772 | #Return incomplete ## |
| 773 | |
| 774 | #Example |
| 775 | // incomplete |
| 776 | ## |
| 777 | |
| 778 | #SeeAlso incomplete |
| 779 | |
| 780 | #Method ## |
| 781 | |
| 782 | # ------------------------------------------------------------------------------ |
| 783 | |
| 784 | #Method bool isOpaque() const |
| 785 | |
| 786 | #Return incomplete ## |
| 787 | |
| 788 | #Example |
| 789 | // incomplete |
| 790 | ## |
| 791 | |
| 792 | #SeeAlso incomplete |
| 793 | |
| 794 | #Method ## |
| 795 | |
| 796 | # ------------------------------------------------------------------------------ |
| 797 | |
| 798 | #Method sk_sp<SkShader> makeShader(SkShader::TileMode tileMode1, SkShader::TileMode tileMode2, |
| 799 | const SkMatrix* localMatrix = nullptr) const |
| 800 | |
| 801 | #Param tileMode1 incomplete ## |
| 802 | #Param tileMode2 incomplete ## |
| 803 | #Param localMatrix incomplete ## |
| 804 | |
| 805 | #Return incomplete ## |
| 806 | |
| 807 | #Example |
| 808 | // incomplete |
| 809 | ## |
| 810 | |
| 811 | #SeeAlso incomplete |
| 812 | |
| 813 | #Method ## |
| 814 | |
| 815 | # ------------------------------------------------------------------------------ |
| 816 | |
| 817 | #Method sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const |
| 818 | |
| 819 | Helper version of makeShader() that specifies SkShader::kClamp_TileMode. |
| 820 | |
| 821 | #Param localMatrix incomplete ## |
| 822 | |
| 823 | #Return incomplete ## |
| 824 | |
| 825 | #Example |
| 826 | // incomplete |
| 827 | ## |
| 828 | |
| 829 | #SeeAlso incomplete |
| 830 | |
| 831 | #Method ## |
| 832 | |
| 833 | # ------------------------------------------------------------------------------ |
| 834 | |
| 835 | #Method bool peekPixels(SkPixmap* pixmap) const |
| 836 | |
| 837 | If the image has direct access to its pixels (i.e. they are in local RAM) |
| 838 | return true, and if not null, return in the pixmap parameter the info about the |
| 839 | images pixels. |
| 840 | On failure, return false and ignore the pixmap parameter. |
| 841 | |
| 842 | #Param pixmap incomplete ## |
| 843 | |
| 844 | #Return incomplete ## |
| 845 | |
| 846 | #Example |
| 847 | // incomplete |
| 848 | ## |
| 849 | |
| 850 | #SeeAlso incomplete |
| 851 | |
| 852 | #Method ## |
| 853 | |
| 854 | # ------------------------------------------------------------------------------ |
| 855 | |
| 856 | #Method GrTexture* getTexture() const |
| 857 | |
| 858 | DEPRECATED - |
| 859 | #Private |
| 860 | currently used by Canvas2DLayerBridge in Chromium. |
| 861 | ## |
| 862 | |
| 863 | #Return incomplete ## |
| 864 | |
| 865 | #Example |
| 866 | // incomplete |
| 867 | ## |
| 868 | |
| 869 | #SeeAlso incomplete |
| 870 | |
| 871 | #Method ## |
| 872 | |
| 873 | # ------------------------------------------------------------------------------ |
| 874 | |
| 875 | #Method bool isTextureBacked() const |
| 876 | |
| 877 | Returns true if the image is texture backed. |
| 878 | |
| 879 | #Return incomplete ## |
| 880 | |
| 881 | #Example |
| 882 | // incomplete |
| 883 | ## |
| 884 | |
| 885 | #SeeAlso incomplete |
| 886 | |
| 887 | #Method ## |
| 888 | |
| 889 | # ------------------------------------------------------------------------------ |
| 890 | |
| 891 | #Method bool isValid(GrContext* context) const |
| 892 | |
| 893 | Returns true if Image can be drawn. If context |
| 894 | is nullptr, tests if Image draws on Raster_Surface; Otherwise, tests if Image |
| 895 | draws on GPU_Surface associated with context. |
| 896 | |
| 897 | Texture-backed images may become invalid if their underlying GrContext is abandoned. Some |
| 898 | generator-backed images may be invalid for CPU and/or GPU. |
| 899 | |
| 900 | #Param context incomplete ## |
| 901 | |
| 902 | #Return incomplete ## |
| 903 | |
| 904 | #Example |
| 905 | // incomplete |
| 906 | ## |
| 907 | |
| 908 | #SeeAlso incomplete |
| 909 | |
| 910 | #Method ## |
| 911 | |
| 912 | # ------------------------------------------------------------------------------ |
| 913 | |
| 914 | #Method GrBackendObject getTextureHandle(bool flushPendingGrContextIO, |
| 915 | GrSurfaceOrigin* origin = nullptr) const |
| 916 | |
| 917 | Retrieves the back-end API handle of the texture. If flushPendingGrContextIO then the |
| 918 | GrContext will issue to the back-end API any deferred I/O operations on the texture before |
| 919 | returning. |
| 920 | If 'origin' is supplied it will be filled in with the origin of the content drawn |
| 921 | into the image. |
| 922 | |
| 923 | #Param flushPendingGrContextIO incomplete ## |
| 924 | #Param origin incomplete ## |
| 925 | |
| 926 | #Return incomplete ## |
| 927 | |
| 928 | #Example |
| 929 | // incomplete |
| 930 | ## |
| 931 | |
| 932 | #SeeAlso incomplete |
| 933 | |
| 934 | #Method ## |
| 935 | |
| 936 | # ------------------------------------------------------------------------------ |
| 937 | |
| 938 | #Enum CachingHint |
| 939 | |
| 940 | #Code |
| 941 | enum CachingHint { |
| 942 | kAllow_CachingHint, |
| 943 | kDisallow_CachingHint, |
| 944 | }; |
| 945 | ## |
| 946 | |
| 947 | Hints to image calls where the system might cache computed intermediates (e.g. the results |
| 948 | of decoding or a read-back from the GPU. Passing kAllow_CachingHint signals that the system's default |
| 949 | behavior is fine. Passing kDisallow_CachingHint signals that caching should be avoided. |
| 950 | |
| 951 | #Const kAllow_CachingHint 0 |
| 952 | ## |
| 953 | #Const kDisallow_CachingHint 1 |
| 954 | ## |
| 955 | |
| 956 | #Example |
| 957 | // incomplete |
| 958 | ## |
| 959 | |
| 960 | #SeeAlso incomplete |
| 961 | |
| 962 | #Enum ## |
| 963 | |
| 964 | # ------------------------------------------------------------------------------ |
| 965 | |
| 966 | #Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, |
| 967 | int srcX, int srcY, CachingHint cachingHint = kAllow_CachingHint) const |
| 968 | |
| 969 | Copy the pixels from the image into the specified buffer (dstPixels + dstRowBytes), |
| 970 | converting them into the requested format (dstInfo). The image pixels are read |
| 971 | starting at the specified (srcX, srcY) location. |
| 972 | dstInfo and (srcX, srcY) offset specifies a source rectangle: |
| 973 | #Code |
| 974 | SkRect srcR; |
| 975 | srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height()); |
| 976 | ## |
| 977 | |
| 978 | The source rectangle is intersected with the bounds of the image. If this intersection is not empty, |
| 979 | then we have two sets of pixels (of equal size). Replace dstPixels with the |
| 980 | corresponding Image pixels, performing any Color_Type/Alpha_Type transformations needed |
| 981 | (in the case where Image and dstInfo have different Color_Types or Alpha_Types). |
| 982 | This call can fail, returning false, for several reasons: |
| 983 | if source rectangle does not intersect the image bounds; |
| 984 | if the requested Color_Type/Alpha_Type cannot be converted from the image's types. |
| 985 | |
| 986 | #Param dstInfo incomplete ## |
| 987 | #Param dstPixels incomplete ## |
| 988 | #Param dstRowBytes incomplete ## |
| 989 | #Param srcX incomplete ## |
| 990 | #Param srcY incomplete ## |
| 991 | #Param cachingHint incomplete ## |
| 992 | |
| 993 | #Return incomplete ## |
| 994 | |
| 995 | #Example |
| 996 | // incomplete |
| 997 | ## |
| 998 | |
| 999 | #SeeAlso incomplete |
| 1000 | |
| 1001 | #Method ## |
| 1002 | |
| 1003 | # ------------------------------------------------------------------------------ |
| 1004 | |
| 1005 | #Method bool readPixels(const SkPixmap& dst, int srcX, int srcY, |
| 1006 | CachingHint cachingHint = kAllow_CachingHint) const |
| 1007 | |
| 1008 | #Param dst incomplete ## |
| 1009 | #Param srcX incomplete ## |
| 1010 | #Param srcY incomplete ## |
| 1011 | #Param cachingHint incomplete ## |
| 1012 | |
| 1013 | #Return incomplete ## |
| 1014 | |
| 1015 | #Example |
| 1016 | // incomplete |
| 1017 | ## |
| 1018 | |
| 1019 | #SeeAlso incomplete |
| 1020 | |
| 1021 | #Method ## |
| 1022 | |
| 1023 | # ------------------------------------------------------------------------------ |
| 1024 | |
| 1025 | #Method bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality, |
| 1026 | CachingHint cachingHint = kAllow_CachingHint) const |
| 1027 | |
| 1028 | Copies Image pixels into dst, converting to dst Color_Type and Alpha_Type. |
| 1029 | If the conversion cannot be performed, false is returned. |
| 1030 | If dst dimensions differ from Image dimensions, Image is scaled, applying |
| 1031 | filterQuality. |
| 1032 | |
| 1033 | #Param dst incomplete ## |
| 1034 | #Param filterQuality incomplete ## |
| 1035 | #Param cachingHint incomplete ## |
| 1036 | |
| 1037 | #Return incomplete ## |
| 1038 | |
| 1039 | #Example |
| 1040 | // incomplete |
| 1041 | ## |
| 1042 | |
| 1043 | #SeeAlso incomplete |
| 1044 | |
| 1045 | #Method ## |
| 1046 | |
| 1047 | # ------------------------------------------------------------------------------ |
| 1048 | |
| 1049 | #Method sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const |
| 1050 | |
| 1051 | Encode the image's pixels and return the result as SkData. |
| 1052 | If the image type cannot be encoded, or the requested encoder format is |
| 1053 | not supported, this will return nullptr. |
| 1054 | |
| 1055 | #Param encodedImageFormat incomplete ## |
| 1056 | #Param quality incomplete ## |
| 1057 | |
| 1058 | #Return incomplete ## |
| 1059 | |
| 1060 | #Example |
| 1061 | // incomplete |
| 1062 | ## |
| 1063 | |
| 1064 | #SeeAlso incomplete |
| 1065 | |
| 1066 | #Method ## |
| 1067 | |
| 1068 | # ------------------------------------------------------------------------------ |
| 1069 | |
| 1070 | #Method sk_sp<SkData> encodeToData(SkPixelSerializer* pixelSerializer = nullptr) const |
| 1071 | |
| 1072 | Encodes Image and returns result as SkData. Will reuse existing encoded data |
| 1073 | if present, as returned by refEncodedData. pixelSerializer validates existing |
| 1074 | encoded data, and encodes Image when existing encoded data is missing or |
| 1075 | invalid. |
| 1076 | |
| 1077 | Passing nullptr for pixelSerializer selects default serialization which |
| 1078 | accepts all data and encodes to PNG. |
| 1079 | |
| 1080 | Returns nullptr if existing encoded data is missing or invalid and |
| 1081 | encoding fails. |
| 1082 | |
| 1083 | #Param pixelSerializer incomplete ## |
| 1084 | |
| 1085 | #Return incomplete ## |
| 1086 | |
| 1087 | #Example |
| 1088 | // incomplete |
| 1089 | ## |
| 1090 | |
| 1091 | #SeeAlso incomplete |
| 1092 | |
| 1093 | #Method ## |
| 1094 | |
| 1095 | # ------------------------------------------------------------------------------ |
| 1096 | |
| 1097 | #Method sk_sp<SkData> refEncodedData() const |
| 1098 | |
| 1099 | If the image already has its contents in encoded form (e.g. PNG or JPEG), return that |
| 1100 | as SkData. If the image does not already has its contents in encoded form, return nullptr. |
| 1101 | |
| 1102 | To force the image to return its contents as encoded data, call encodeToData. |
| 1103 | |
| 1104 | #Return incomplete ## |
| 1105 | |
| 1106 | #Example |
| 1107 | // incomplete |
| 1108 | ## |
| 1109 | |
| 1110 | #SeeAlso incomplete |
| 1111 | |
| 1112 | #Method ## |
| 1113 | |
| 1114 | # ------------------------------------------------------------------------------ |
| 1115 | |
| 1116 | #Method const char* toString(SkString* string) const |
| 1117 | |
| 1118 | #Param string incomplete ## |
| 1119 | |
| 1120 | #Return incomplete ## |
| 1121 | |
| 1122 | #Example |
| 1123 | // incomplete |
| 1124 | ## |
| 1125 | |
| 1126 | #SeeAlso incomplete |
| 1127 | |
| 1128 | #Method ## |
| 1129 | |
| 1130 | # ------------------------------------------------------------------------------ |
| 1131 | |
| 1132 | #Method sk_sp<SkImage> makeSubset(const SkIRect& subset) const |
| 1133 | |
| 1134 | Return a new image that is a subset of this image. The underlying implementation may |
| 1135 | share the pixels, or it may make a copy. |
| 1136 | If subset does not intersect the bounds of this image, or the copy/share cannot be made, |
| 1137 | nullptr will be returned. |
| 1138 | |
| 1139 | #Param subset incomplete ## |
| 1140 | |
| 1141 | #Return incomplete ## |
| 1142 | |
| 1143 | #Example |
| 1144 | // incomplete |
| 1145 | ## |
| 1146 | |
| 1147 | #SeeAlso incomplete |
| 1148 | |
| 1149 | #Method ## |
| 1150 | |
| 1151 | # ------------------------------------------------------------------------------ |
| 1152 | |
| 1153 | #Method sk_sp<SkImage> makeTextureImage(GrContext* context, SkColorSpace* dstColorSpace) const |
| 1154 | |
| 1155 | Ensures that an image is backed by a texture (when GrContext is non-null), suitable for use |
| 1156 | with surfaces that have the supplied destination color space. If no transformation is |
| 1157 | required, the returned image may be the same as this image. If this image is from a |
| 1158 | different GrContext, this will fail. |
| 1159 | |
| 1160 | #Param context incomplete ## |
| 1161 | #Param dstColorSpace incomplete ## |
| 1162 | |
| 1163 | #Return incomplete ## |
| 1164 | |
| 1165 | #Example |
| 1166 | // incomplete |
| 1167 | ## |
| 1168 | |
| 1169 | #SeeAlso incomplete |
| 1170 | |
| 1171 | #Method ## |
| 1172 | |
| 1173 | # ------------------------------------------------------------------------------ |
| 1174 | |
| 1175 | #Method sk_sp<SkImage> makeNonTextureImage() const |
| 1176 | |
| 1177 | If the image is texture-backed this will make a raster copy of it (or nullptr if reading back |
| 1178 | the pixels fails). Otherwise, it returns the original image. |
| 1179 | |
| 1180 | #Return incomplete ## |
| 1181 | |
| 1182 | #Example |
| 1183 | // incomplete |
| 1184 | ## |
| 1185 | |
| 1186 | #SeeAlso incomplete |
| 1187 | |
| 1188 | #Method ## |
| 1189 | |
| 1190 | # ------------------------------------------------------------------------------ |
| 1191 | |
| 1192 | #Method sk_sp<SkImage> makeWithFilter(const SkImageFilter* filter, const SkIRect& subset, |
| 1193 | const SkIRect& clipBounds, SkIRect* outSubset, |
| 1194 | SkIPoint* offset) const |
| 1195 | |
| 1196 | Apply a given image filter to this image, and return the filtered result. |
| 1197 | The subset represents the active portion of this image. The return value is similarly an |
| 1198 | SkImage, with an active subset (outSubset). This is usually used with texture-backed |
| 1199 | images, where the texture may be approx-match and thus larger than the required size. |
| 1200 | clipBounds constrains the device-space extent of the image, stored in outSubset. |
| 1201 | offset is storage, set to the amount to translate the result when drawn. |
| 1202 | If the result image cannot be created, or the result would be transparent black, null |
| 1203 | is returned, in which case the offset and outSubset parameters should be ignored by the |
| 1204 | caller. |
| 1205 | |
| 1206 | #Param filter incomplete ## |
| 1207 | #Param subset incomplete ## |
| 1208 | #Param clipBounds incomplete ## |
| 1209 | #Param outSubset incomplete ## |
| 1210 | #Param offset incomplete ## |
| 1211 | |
| 1212 | #Return incomplete ## |
| 1213 | |
| 1214 | #Example |
| 1215 | // incomplete |
| 1216 | ## |
| 1217 | |
| 1218 | #SeeAlso incomplete |
| 1219 | |
| 1220 | #Method ## |
| 1221 | |
| 1222 | # ------------------------------------------------------------------------------ |
| 1223 | |
| 1224 | #Method size_t getDeferredTextureImageData(const GrContextThreadSafeProxy& contextThreadSafeProxy, |
| 1225 | const DeferredTextureImageUsageParams deferredTextureImageUsageParams[], |
| 1226 | int paramCnt, |
| 1227 | void* buffer, |
| 1228 | SkColorSpace* dstColorSpace = nullptr, |
| 1229 | SkColorType dstColorType = kN32_SkColorType) const |
| 1230 | |
| 1231 | This method allows clients to capture the data necessary to turn a SkImage into a texture- |
| 1232 | backed image. If the original image is codec-backed this will decode into a format optimized |
| 1233 | for the context represented by the proxy. This method is thread safe with respect to the |
| 1234 | GrContext whence the proxy came. Clients allocate and manage the storage of the deferred |
| 1235 | texture data and control its lifetime. No cleanup is required, thus it is safe to simply free |
| 1236 | the memory out from under the data. |
| 1237 | |
| 1238 | The same method is used both for getting the size necessary for uploading |
| 1239 | and retrieving texture data. The deferredTextureImageUsageParams array represents the set of |
| 1240 | draws over which to optimize the texture data prior to uploading. |
| 1241 | |
| 1242 | When called with a null buffer this returns the size that the client must allocate in order |
| 1243 | to create deferred texture data for this image (or zero if this is an inappropriate |
| 1244 | candidate). The buffer allocated by the client should be 8 byte aligned. |
| 1245 | When buffer is not null this fills in the deferred texture data for this image in the |
| 1246 | provided buffer (assuming this is an appropriate candidate image and the buffer is |
| 1247 | appropriately aligned). Upon success the size written is returned, otherwise 0. |
| 1248 | dstColorSpace is the color space of the surface where this texture will ultimately be used. |
| 1249 | If the method determines that Mip_Maps are needed, this helps determine the correct strategy |
| 1250 | for building them (gamma-correct or not). |
| 1251 | |
| 1252 | dstColorType is the color type of the surface where this texture will ultimately be used. |
| 1253 | This determines the format with which the image will be uploaded to the GPU. If dstColorType |
| 1254 | does not support color spaces (low bit depth types such as kARGB_4444_SkColorType), then dstColorSpace |
| 1255 | must be null. |
| 1256 | |
| 1257 | #Param contextThreadSafeProxy incomplete ## |
| 1258 | #Param deferredTextureImageUsageParams incomplete ## |
| 1259 | #Param paramCnt incomplete ## |
| 1260 | #Param buffer incomplete ## |
| 1261 | #Param dstColorSpace incomplete ## |
| 1262 | #Param dstColorType incomplete ## |
| 1263 | |
| 1264 | #Return incomplete ## |
| 1265 | |
| 1266 | #Example |
| 1267 | // incomplete |
| 1268 | ## |
| 1269 | |
| 1270 | #SeeAlso incomplete |
| 1271 | |
| 1272 | #Method ## |
| 1273 | |
| 1274 | # ------------------------------------------------------------------------------ |
| 1275 | |
| 1276 | #Method static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data, |
| 1277 | SkBudgeted budgeted) |
| 1278 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1279 | Returns a texture-backed image from data produced in getDeferredTextureImageData. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1280 | The context must be the context that provided the proxy passed to |
| 1281 | getDeferredTextureImageData. |
| 1282 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1283 | #Param context GPU_Context ## |
| 1284 | #Param data buffer filled by getDeferredTextureImageData ## |
| 1285 | #Param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1286 | |
| 1287 | #Return incomplete ## |
| 1288 | |
| 1289 | #Example |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1290 | #Image 3 |
| 1291 | #Platform gpu |
| 1292 | GrContext* context = canvas->getGrContext(); |
| 1293 | if (!context) { |
| 1294 | return; |
| 1295 | } |
| 1296 | sk_sp<GrContextThreadSafeProxy> proxy = context->threadSafeProxy(); |
| 1297 | SkImage::DeferredTextureImageUsageParams params = {SkMatrix::I(), kNone_SkFilterQuality, 0}; |
| 1298 | size_t size = image->getDeferredTextureImageData(*proxy, ¶ms, 1, nullptr, |
| 1299 | nullptr, kN32_SkColorType); |
| 1300 | void* buffer = sk_malloc_throw(size); |
| 1301 | if (image->getDeferredTextureImageData(*proxy, ¶ms, 1, buffer, nullptr, kN32_SkColorType)) { |
| 1302 | sk_sp<SkImage> newImage( |
| 1303 | SkImage::MakeFromDeferredTextureImageData(context, buffer, SkBudgeted::kNo)); |
| 1304 | canvas->drawImage(newImage, 0, 0); |
| 1305 | } |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1306 | ## |
| 1307 | |
| 1308 | #SeeAlso incomplete |
| 1309 | |
| 1310 | #Method ## |
| 1311 | |
| 1312 | #Typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc |
| 1313 | |
| 1314 | ## |
| 1315 | |
| 1316 | # ------------------------------------------------------------------------------ |
| 1317 | |
| 1318 | #Method static bool MakeBackendTextureFromSkImage(GrContext* context, |
| 1319 | sk_sp<SkImage> image, |
| 1320 | GrBackendTexture* backendTexture, |
| 1321 | BackendTextureReleaseProc* backendTextureReleaseProc) |
| 1322 | |
| 1323 | Creates a GrBackendTexture from the provided SkImage. Returns true on success. The |
| 1324 | GrBackendTexture and BackendTextureReleaseProc are populated on success. It is the callers |
| 1325 | responsibility to call the BackendTextureReleaseProc once they have deleted the texture. |
| 1326 | Note that the BackendTextureReleaseProc allows Skia to clean up auxiliary data related |
| 1327 | to the GrBackendTexture, and is not a substitute for the client deleting the GrBackendTexture |
| 1328 | themselves. |
| 1329 | |
| 1330 | If image is both texture backed and singly referenced; that is, its only |
| 1331 | reference was transferred using std::move(): image is returned in backendTexture |
| 1332 | without conversion or making a copy. |
| 1333 | |
| 1334 | If the SkImage is not texture backed, this function will generate a texture with the image's |
| 1335 | contents and return that. |
| 1336 | |
| 1337 | #Param context incomplete ## |
| 1338 | #Param image incomplete ## |
| 1339 | #Param backendTexture incomplete ## |
| 1340 | #Param backendTextureReleaseProc incomplete ## |
| 1341 | |
| 1342 | #Return incomplete ## |
| 1343 | |
| 1344 | #Example |
| 1345 | // incomplete |
| 1346 | ## |
| 1347 | |
| 1348 | #SeeAlso incomplete |
| 1349 | |
| 1350 | #Method ## |
| 1351 | |
| 1352 | # ------------------------------------------------------------------------------ |
| 1353 | |
| 1354 | #Enum LegacyBitmapMode |
| 1355 | |
| 1356 | #Code |
| 1357 | enum LegacyBitmapMode { |
| 1358 | kRO_LegacyBitmapMode, |
| 1359 | kRW_LegacyBitmapMode, |
| 1360 | }; |
| 1361 | ## |
| 1362 | |
| 1363 | Helper functions to convert to SkBitmap |
| 1364 | |
| 1365 | #Const kRO_LegacyBitmapMode 0 |
| 1366 | ## |
| 1367 | #Const kRW_LegacyBitmapMode 1 |
| 1368 | ## |
| 1369 | |
| 1370 | #Example |
| 1371 | // incomplete |
| 1372 | ## |
| 1373 | |
| 1374 | #SeeAlso incomplete |
| 1375 | |
| 1376 | #Enum ## |
| 1377 | |
| 1378 | # ------------------------------------------------------------------------------ |
| 1379 | |
| 1380 | #Method bool asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode legacyBitmapMode) const |
| 1381 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1382 | Creates raster Bitmap with same pixels as Image. If legacyBitmapMode is kRO_LegacyBitmapMode, |
| 1383 | returned bitmap is read-only and immutable. |
| 1384 | Returns true if Bitmap is stored in bitmap. Returns false and resets bitmap if Bitmap |
| 1385 | write did not succeed. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1386 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1387 | #Param bitmap storage for legacy Bitmap ## |
| 1388 | #Param legacyBitmapMode one of: kRO_LegacyBitmapMode, kRW_LegacyBitmapMode ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1389 | |
Cary Clark | 3cd22cc | 2017-12-01 11:49:58 -0500 | [diff] [blame^] | 1390 | #Return true if Bitmap was created ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1391 | |
| 1392 | #Example |
| 1393 | // incomplete |
| 1394 | ## |
| 1395 | |
| 1396 | #SeeAlso incomplete |
| 1397 | |
| 1398 | #Method ## |
| 1399 | |
| 1400 | # ------------------------------------------------------------------------------ |
| 1401 | |
| 1402 | #Method bool isLazyGenerated() const |
| 1403 | |
| 1404 | Returns true if Image is backed by an image-generator or other service that creates |
| 1405 | and caches its pixels or texture on-demand. |
| 1406 | |
| 1407 | #Return incomplete ## |
| 1408 | |
| 1409 | #Example |
| 1410 | // incomplete |
| 1411 | ## |
| 1412 | |
| 1413 | #SeeAlso incomplete |
| 1414 | |
| 1415 | #Method ## |
| 1416 | |
| 1417 | # ------------------------------------------------------------------------------ |
| 1418 | |
| 1419 | #Method sk_sp<SkImage> makeColorSpace(sk_sp<SkColorSpace> target, |
| 1420 | SkTransferFunctionBehavior premulBehavior) const |
| 1421 | |
| 1422 | If target is supported, returns an SkImage in target color space. |
| 1423 | Otherwise, returns nullptr. |
| 1424 | This will leave the image as is if it already in target color space. |
| 1425 | Otherwise, it will convert the pixels from Image color space to target |
| 1426 | color space. If this->colorSpace() is nullptr, Image color space will be |
| 1427 | treated as sRGB. |
| 1428 | |
| 1429 | If premulBehavior is SkTransferFunctionBehavior::kRespect: converts Image |
| 1430 | pixels to a linear space before converting to match destination Color_Type |
| 1431 | and Color_Space. |
| 1432 | If premulBehavior is SkTransferFunctionBehavior::kIgnore: Image |
| 1433 | pixels are treated as if they are linear, regardless of how they are encoded. |
| 1434 | |
| 1435 | #Param target incomplete ## |
| 1436 | #Param premulBehavior incomplete ## |
| 1437 | |
| 1438 | #Return incomplete ## |
| 1439 | |
| 1440 | #Example |
| 1441 | // incomplete |
| 1442 | ## |
| 1443 | |
| 1444 | #SeeAlso incomplete |
| 1445 | |
| 1446 | #Method ## |
| 1447 | |
| 1448 | #Class SkImage ## |
| 1449 | |
| 1450 | #Topic Image ## |