Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkImageChromium.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkImageChromium_DEFINED
9#define SkImageChromium_DEFINED
10
13
14class GrBackendFormat;
17class GrDirectContext;
19class SkColorSpace;
20class SkImage;
21enum SkAlphaType : int;
22enum SkColorType : int;
23enum GrSurfaceOrigin : int;
24namespace skgpu {
25enum class Mipmapped : bool;
26}
27struct SkISize;
28
29/**
30 * These functions expose features that are only for external use in Chromium.
31 */
32
33namespace SkImages {
34
38
39/** Create a new GPU-backed SkImage that is very similar to an SkImage created by BorrowTextureFrom.
40 The difference is that the caller need not have created the texture nor populated it with the
41 image pixel data. Moreover, the SkImage may be created on a thread as the creation of the
42 image does not require access to the backend API or GrDirectContext. Instead of passing a
43 GrBackendTexture the client supplies a description of the texture consisting of
44 GrBackendFormat, width, height, and skgpu::Mipmapped state. The resulting SkImage can be drawn
45 to a GrDeferredDisplayListRecorder or directly to a GPU-backed SkSurface.
46 When the actual texture is required to perform a backend API draw, textureFulfillProc will
47 be called to receive a GrBackendTexture. The properties of the GrBackendTexture must match
48 those set during the SkImage creation, and it must refer to a valid existing texture in the
49 backend API context/device, and be populated with the image pixel data. The texture cannot
50 be deleted until textureReleaseProc is called.
51 There is at most one call to each of textureFulfillProc and textureReleaseProc.
52 textureReleaseProc is always called even if image creation fails or if the
53 image is never fulfilled (e.g. it is never drawn or all draws are clipped out)
54 @param gpuContextProxy the thread-safe proxy of the gpu context. required.
55 @param backendFormat format of promised gpu texture
56 @param dimensions width & height of promised gpu texture
57 @param mipmapped mip mapped state of promised gpu texture
58 @param origin surface origin of promised gpu texture
59 @param colorType color type of promised gpu texture
60 @param alphaType alpha type of promised gpu texture
61 @param colorSpace range of colors; may be nullptr
62 @param textureFulfillProc function called to get actual gpu texture
63 @param textureReleaseProc function called when texture can be deleted
64 @param textureContext state passed to textureFulfillProc and textureReleaseProc
65 @return created SkImage, or nullptr
66*/
68 const GrBackendFormat& backendFormat,
69 SkISize dimensions,
70 skgpu::Mipmapped mipmapped,
71 GrSurfaceOrigin origin,
73 SkAlphaType alphaType,
74 sk_sp<SkColorSpace> colorSpace,
75 PromiseImageTextureFulfillProc textureFulfillProc,
76 PromiseImageTextureReleaseProc textureReleaseProc,
77 PromiseImageTextureContext textureContext);
78
79/** This is similar to 'PromiseTextureFrom' but it creates a GPU-backed SkImage from YUV[A] data.
80 The source data may be planar (i.e. spread across multiple textures). In
81 the extreme Y, U, V, and A are all in different planes and thus the image is specified by
82 four textures. 'backendTextureInfo' describes the planar arrangement, texture formats,
83 conversion to RGB, and origin of the textures. Separate 'textureFulfillProc' and
84 'textureReleaseProc' calls are made for each texture. Each texture has its own
85 PromiseImageTextureContext. If 'backendTextureInfo' is not valid then no release proc
86 calls are made. Otherwise, the calls will be made even on failure. 'textureContexts' has one
87 entry for each of the up to four textures, as indicated by 'backendTextureInfo'.
88 Currently the mip mapped property of 'backendTextureInfo' is ignored. However, in the
89 near future it will be required that if it is kYes then textureFulfillProc must return
90 a mip mapped texture for each plane in order to successfully draw the image.
91 @param gpuContextProxy the thread-safe proxy of the gpu context. required.
92 @param backendTextureInfo info about the promised yuva gpu texture
93 @param imageColorSpace range of colors; may be nullptr
94 @param textureFulfillProc function called to get actual gpu texture
95 @param textureReleaseProc function called when texture can be deleted
96 @param textureContexts state passed to textureFulfillProc and textureReleaseProc
97 @return created SkImage, or nullptr
98*/
100 const GrYUVABackendTextureInfo& backendTextureInfo,
101 sk_sp<SkColorSpace> imageColorSpace,
102 PromiseImageTextureFulfillProc textureFulfillProc,
103 PromiseImageTextureReleaseProc textureReleaseProc,
104 PromiseImageTextureContext textureContexts[]);
105
106/** Returns the GPU context associated with this image or nullptr if the image is not Ganesh-backed.
107 We expose this only to help transition certain API calls and do not intend for this to stick
108 around forever.
109*/
112 return GetContext(src.get());
113}
114
115} // namespace SkImages
116
117#endif
GrSurfaceOrigin
Definition GrTypes.h:147
#define SK_API
Definition SkAPI.h:35
SkAlphaType
Definition SkAlphaType.h:26
SkColorType
Definition SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
Type::kYUV Type::kRGBA() int(0.7 *637)
void * PromiseImageTextureContext
SK_API sk_sp< SkImage > PromiseTextureFromYUVA(skgpu::graphite::Recorder *, const skgpu::graphite::YUVABackendTextureInfo &, sk_sp< SkColorSpace > imageColorSpace, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext imageContext, GraphitePromiseTextureFulfillContext planeContexts[])
void(*)(PromiseImageTextureContext) PromiseImageTextureReleaseProc
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext)
SK_API GrDirectContext * GetContext(const SkImage *src)
Mipmapped
Definition GpuTypes.h:53