Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Private Member Functions | Friends | List of all members
GrContextThreadSafeProxy Class Reference

#include <GrContextThreadSafeProxy.h>

Inheritance diagram for GrContextThreadSafeProxy:
SkNVRefCnt< GrContextThreadSafeProxy > GrVkContextThreadSafeProxy

Public Member Functions

virtual ~GrContextThreadSafeProxy ()
 
GrSurfaceCharacterization createCharacterization (size_t cacheMaxResourceBytes, const SkImageInfo &ii, const GrBackendFormat &backendFormat, int sampleCount, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, skgpu::Mipmapped isMipmapped, bool willUseGLFBO0=false, bool isTextureable=true, skgpu::Protected isProtected=GrProtected::kNo, bool vkRTSupportsInputAttachment=false, bool forVulkanSecondaryCommandBuffer=false)
 
GrBackendFormat defaultBackendFormat (SkColorType ct, GrRenderable renderable) const
 
GrBackendFormat compressedBackendFormat (SkTextureCompressionType c) const
 
int maxSurfaceSampleCountForColorType (SkColorType colorType) const
 
bool isValid () const
 
bool operator== (const GrContextThreadSafeProxy &that) const
 
bool operator!= (const GrContextThreadSafeProxy &that) const
 
GrContextThreadSafeProxyPriv priv ()
 
const GrContextThreadSafeProxyPriv priv () const
 
- Public Member Functions inherited from SkNVRefCnt< GrContextThreadSafeProxy >
 SkNVRefCnt ()
 
 ~SkNVRefCnt ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
void deref () const
 
bool refCntGreaterThan (int32_t threadIsolatedTestCnt) const
 

Protected Member Functions

 GrContextThreadSafeProxy (GrBackendApi, const GrContextOptions &)
 

Private Member Functions

virtual bool isValidCharacterizationForVulkan (sk_sp< const GrCaps >, bool isTextureable, skgpu::Mipmapped isMipmapped, skgpu::Protected isProtected, bool vkRTSupportsInputAttachment, bool forVulkanSecondaryCommandBuffer)
 

Friends

class GrContextThreadSafeProxyPriv
 

Detailed Description

Can be used to perform actions related to the generating GrContext in a thread safe manner. The proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext.

Definition at line 34 of file GrContextThreadSafeProxy.h.

Constructor & Destructor Documentation

◆ ~GrContextThreadSafeProxy()

GrContextThreadSafeProxy::~GrContextThreadSafeProxy ( )
virtualdefault

◆ GrContextThreadSafeProxy()

GrContextThreadSafeProxy::GrContextThreadSafeProxy ( GrBackendApi  backend,
const GrContextOptions options 
)
protected

Definition at line 31 of file GrContextThreadSafeProxy.cpp.

33 : fBackend(backend), fOptions(options), fContextID(next_id()) {
34}
const char * options
const char * backend
static uint32_t next_id()

Member Function Documentation

◆ compressedBackendFormat()

GrBackendFormat GrContextThreadSafeProxy::compressedBackendFormat ( SkTextureCompressionType  c) const

Retrieve the GrBackendFormat for a given SkTextureCompressionType. This is guaranteed to match the backend format used by the following createCompressedBackendTexture methods that take a CompressionType.

The caller should check that the returned format is valid.

Definition at line 163 of file GrContextThreadSafeProxy.cpp.

163 {
164 SkASSERT(fCaps);
165
167
169 return format;
170}
#define SkASSERT(cond)
Definition: SkAssert.h:116
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
virtual GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const =0
uint32_t uint32_t * format

◆ createCharacterization()

GrSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization ( size_t  cacheMaxResourceBytes,
const SkImageInfo ii,
const GrBackendFormat backendFormat,
int  sampleCount,
GrSurfaceOrigin  origin,
const SkSurfaceProps surfaceProps,
skgpu::Mipmapped  isMipmapped,
bool  willUseGLFBO0 = false,
bool  isTextureable = true,
skgpu::Protected  isProtected = GrProtected::kNo,
bool  vkRTSupportsInputAttachment = false,
bool  forVulkanSecondaryCommandBuffer = false 
)

Create a surface characterization for a DDL that will be replayed into the GrContext that created this proxy. On failure the resulting characterization will be invalid (i.e., "!c.isValid()").

Parameters
cacheMaxResourceBytesThe max resource bytes limit that will be in effect when the DDL created with this characterization is replayed. Note: the contract here is that the DDL will be created as if it had a full 'cacheMaxResourceBytes' to use. If replayed into a GrContext that already has locked GPU memory, the replay can exceed the budget. To rephrase, all resource allocation decisions are made at record time and at playback time the budget limits will be ignored.
iiThe image info specifying properties of the SkSurface that the DDL created with this characterization will be replayed into. Note: Ganesh doesn't make use of the SkImageInfo's alphaType
backendFormatInformation about the format of the GPU surface that will back the SkSurface upon replay
sampleCountThe sample count of the SkSurface that the DDL created with this characterization will be replayed into
originThe origin of the SkSurface that the DDL created with this characterization will be replayed into
surfacePropsThe surface properties of the SkSurface that the DDL created with this characterization will be replayed into
isMipmappedWill the surface the DDL will be replayed into have space allocated for mipmaps?
willUseGLFBO0Will the surface the DDL will be replayed into be backed by GL FBO 0. This flag is only valid if using an GL backend.
isTextureableWill the surface be able to act as a texture?
isProtectedWill the (Vulkan) surface be DRM protected?
vkRTSupportsInputAttachmentCan the vulkan surface be used as in input attachment?
forVulkanSecondaryCommandBufferWill the surface be wrapping a vulkan secondary command buffer via a GrVkSecondaryCBDrawContext? If this is true then the following is required: isTexureable = false isMipmapped = false willUseGLFBO0 = false vkRTSupportsInputAttachment = false

Definition at line 47 of file GrContextThreadSafeProxy.cpp.

59 {
60 SkASSERT(fCaps);
61 if (!backendFormat.isValid()) {
62 return {};
63 }
64
65 SkASSERT(isTextureable || isMipmapped == skgpu::Mipmapped::kNo);
66
67 if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) {
68 // The willUseGLFBO0 flags can only be used for a GL backend.
69 return {};
70 }
71
72 if (GrBackendApi::kVulkan != backendFormat.backend() &&
73 (vkRTSupportsInputAttachment || forVulkanSecondaryCommandBuffer)) {
74 // The vkRTSupportsInputAttachment and forVulkanSecondaryCommandBuffer flags can only be
75 // used for a Vulkan backend.
76 return {};
77 }
78
79 if (!fCaps->mipmapSupport()) {
80 isMipmapped = skgpu::Mipmapped::kNo;
81 }
82
83 if (ii.width() < 1 || ii.width() > fCaps->maxRenderTargetSize() ||
84 ii.height() < 1 || ii.height() > fCaps->maxRenderTargetSize()) {
85 return {};
86 }
87
89
90 if (!fCaps->areColorTypeAndFormatCompatible(grColorType, backendFormat)) {
91 return {};
92 }
93
94 if (!fCaps->isFormatAsColorTypeRenderable(grColorType, backendFormat, sampleCnt)) {
95 return {};
96 }
97
98 sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, backendFormat);
99 SkASSERT(sampleCnt);
100
101 if (willUseGLFBO0 && isTextureable) {
102 return {};
103 }
104
105 if (isTextureable && !fCaps->isFormatTexturable(backendFormat, backendFormat.textureType())) {
106 // Skia doesn't agree that this is textureable.
107 return {};
108 }
109
110 if (GrBackendApi::kVulkan == backendFormat.backend()) {
112 isTextureable,
113 isMipmapped,
114 isProtected,
115 vkRTSupportsInputAttachment,
116 forVulkanSecondaryCommandBuffer)) {
117 return {};
118 }
119 }
120
122 sk_ref_sp<GrContextThreadSafeProxy>(this),
123 cacheMaxResourceBytes,
124 ii,
125 backendFormat,
126 origin,
127 sampleCnt,
129 isMipmapped,
132 GrSurfaceCharacterization::VulkanSecondaryCBCompatible(forVulkanSecondaryCommandBuffer),
133 isProtected,
134 surfaceProps);
135}
GrColorType
Definition: GrTypesPriv.h:540
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
Definition: GrTypesPriv.h:629
GrBackendApi backend() const
bool isValid() const
GrTextureType textureType() const
bool mipmapSupport() const
Definition: GrCaps.h:72
int maxRenderTargetSize() const
Definition: GrCaps.h:223
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
Definition: GrCaps.cpp:428
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
virtual bool isValidCharacterizationForVulkan(sk_sp< const GrCaps >, bool isTextureable, skgpu::Mipmapped isMipmapped, skgpu::Protected isProtected, bool vkRTSupportsInputAttachment, bool forVulkanSecondaryCommandBuffer)
int width() const
Definition: SkImageInfo.h:365
SkColorType colorType() const
Definition: SkImageInfo.h:373
int height() const
Definition: SkImageInfo.h:371

◆ defaultBackendFormat()

GrBackendFormat GrContextThreadSafeProxy::defaultBackendFormat ( SkColorType  ct,
GrRenderable  renderable 
) const

Definition at line 147 of file GrContextThreadSafeProxy.cpp.

148 {
149 SkASSERT(fCaps);
150 GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
151
152 GrBackendFormat format = fCaps->getDefaultBackendFormat(grColorType, renderable);
153 if (!format.isValid()) {
154 return GrBackendFormat();
155 }
156
157 SkASSERT(renderable == GrRenderable::kNo ||
158 fCaps->isFormatAsColorTypeRenderable(grColorType, format));
159
160 return format;
161}
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400

◆ isValid()

bool GrContextThreadSafeProxy::isValid ( ) const
inline

Definition at line 124 of file GrContextThreadSafeProxy.h.

124{ return nullptr != fCaps; }

◆ isValidCharacterizationForVulkan()

bool GrContextThreadSafeProxy::isValidCharacterizationForVulkan ( sk_sp< const GrCaps ,
bool  isTextureable,
skgpu::Mipmapped  isMipmapped,
skgpu::Protected  isProtected,
bool  vkRTSupportsInputAttachment,
bool  forVulkanSecondaryCommandBuffer 
)
privatevirtual

Reimplemented in GrVkContextThreadSafeProxy.

Definition at line 137 of file GrContextThreadSafeProxy.cpp.

143 {
144 return false; // handled by a subclass
145}

◆ maxSurfaceSampleCountForColorType()

int GrContextThreadSafeProxy::maxSurfaceSampleCountForColorType ( SkColorType  colorType) const

Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA rendering is supported for the color type. 0 is returned if rendering to this color type is not supported at all.

Definition at line 172 of file GrContextThreadSafeProxy.cpp.

172 {
173 SkASSERT(fCaps);
174
177 return fCaps->maxRenderTargetSampleCount(format);
178}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
virtual int maxRenderTargetSampleCount(const GrBackendFormat &) const =0

◆ operator!=()

bool GrContextThreadSafeProxy::operator!= ( const GrContextThreadSafeProxy that) const
inline

Definition at line 132 of file GrContextThreadSafeProxy.h.

132{ return !(*this == that); }

◆ operator==()

bool GrContextThreadSafeProxy::operator== ( const GrContextThreadSafeProxy that) const
inline

Definition at line 126 of file GrContextThreadSafeProxy.h.

126 {
127 // Each GrContext should only ever have a single thread-safe proxy.
128 SkASSERT((this == &that) == (this->fContextID == that.fContextID));
129 return this == &that;
130 }

◆ priv() [1/2]

GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv ( )
inline

Definition at line 66 of file GrContextThreadSafeProxyPriv.h.

66 {
68}

◆ priv() [2/2]

const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv ( ) const
inline

Definition at line 70 of file GrContextThreadSafeProxyPriv.h.

70 { // NOLINT(readability-const-return-type)
72}

Friends And Related Function Documentation

◆ GrContextThreadSafeProxyPriv

friend class GrContextThreadSafeProxyPriv
friend

Definition at line 143 of file GrContextThreadSafeProxy.h.


The documentation for this class was generated from the following files: