Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Variables
GrTypes.h File Reference
#include "include/core/SkTypes.h"
#include "include/private/base/SkTo.h"
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Classes

class  GrTFlagsMask< TFlags >
 
struct  GrFlushInfo
 

Namespaces

namespace  skgpu
 

Macros

#define GR_MAKE_BITFIELD_CLASS_OPS(X)
 
#define GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(X)
 

Typedefs

typedef GrBackendApi GrBackend
 
using GrRenderable = skgpu::Renderable
 
using GrProtected = skgpu::Protected
 
typedef void * GrGpuFinishedContext
 
typedef void(* GrGpuFinishedProc) (GrGpuFinishedContext finishedContext)
 
typedef void * GrGpuSubmittedContext
 
typedef void(* GrGpuSubmittedProc) (GrGpuSubmittedContext submittedContext, bool success)
 
typedef void * GrDirectContextDestroyedContext
 
typedef void(* GrDirectContextDestroyedProc) (GrDirectContextDestroyedContext destroyedContext)
 

Enumerations

enum class  GrBackendApi : unsigned {
  kOpenGL , kVulkan , kMetal , kDirect3D ,
  kMock , kUnsupported , kOpenGL_GrBackend = kOpenGL
}
 
enum  GrSurfaceOrigin : int { kTopLeft_GrSurfaceOrigin , kBottomLeft_GrSurfaceOrigin }
 
enum  GrGLBackendState {
  kRenderTarget_GrGLBackendState = 1 << 0 , kTextureBinding_GrGLBackendState = 1 << 1 , kView_GrGLBackendState = 1 << 2 , kBlend_GrGLBackendState = 1 << 3 ,
  kMSAAEnable_GrGLBackendState = 1 << 4 , kVertex_GrGLBackendState = 1 << 5 , kStencil_GrGLBackendState = 1 << 6 , kPixelStore_GrGLBackendState = 1 << 7 ,
  kProgram_GrGLBackendState = 1 << 8 , kFixedFunction_GrGLBackendState = 1 << 9 , kMisc_GrGLBackendState = 1 << 10 , kALL_GrGLBackendState = 0xffff
}
 
enum class  GrSemaphoresSubmitted : bool { kNo = false , kYes = true }
 
enum class  GrPurgeResourceOptions { kAllResources , kScratchResourcesOnly }
 
enum class  GrSyncCpu : bool { kNo = false , kYes = true }
 

Variables

static constexpr GrBackendApi kMetal_GrBackend = GrBackendApi::kMetal
 
static constexpr GrBackendApi kVulkan_GrBackend = GrBackendApi::kVulkan
 
static constexpr GrBackendApi kMock_GrBackend = GrBackendApi::kMock
 
static const uint32_t kAll_GrBackendState = 0xffffffff
 

Macro Definition Documentation

◆ GR_DECL_BITFIELD_CLASS_OPS_FRIENDS

#define GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (   X)
Value:
friend constexpr GrTFlagsMask<X> operator ~(X); \
friend constexpr X operator |(X, X); \
friend X& operator |=(X&, X); \
friend constexpr bool operator &(X, X); \
friend constexpr X operator&(GrTFlagsMask<X>, X); \
friend constexpr X operator&(X, GrTFlagsMask<X>); \
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator&(E l, E r)
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E & > constexpr operator&=(E &l, E r)
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator~(E e)
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator|(E l, E r)
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E & > constexpr operator|=(E &l, E r)
static const SkScalar X

Definition at line 77 of file GrTypes.h.

94 : unsigned {
95 kOpenGL,
96 kVulkan,
97 kMetal,
99
100 /**
101 * Mock is a backend that does not draw anything. It is used for unit tests
102 * and to measure CPU overhead.
103 */
104 kMock,
105
106 /**
107 * Ganesh doesn't support some context types (e.g. Dawn) and will return Unsupported.
108 */
110
111 /**
112 * Added here to support the legacy GrBackend enum value and clients who referenced it using
113 * GrBackend::kOpenGL_GrBackend.
114 */
116};
117
118/**
119 * Previously the above enum was not an enum class but a normal enum. To support the legacy use of
120 * the enum values we define them below so that no clients break.
121 */
122typedef GrBackendApi GrBackend;
123
127
128///////////////////////////////////////////////////////////////////////////////
129
130/*
131 * Can a GrBackendObject be rendered to?
132 */
134
135/*
136 * Used to say whether texture is backed by protected memory.
137 */
139
140///////////////////////////////////////////////////////////////////////////////
141
142/**
143 * GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to
144 * either the top-left or bottom-left content pixel.
145 */
146enum GrSurfaceOrigin : int {
149};
150
151/**
152 * A GrContext's cache of backend context state can be partially invalidated.
153 * These enums are specific to the GL backend and we'd add a new set for an alternative backend.
154 */
155enum GrGLBackendState {
157 // Also includes samplers bound to texture units.
159 // View state stands for scissor and viewport
160 kView_GrGLBackendState = 1 << 2,
168 kMisc_GrGLBackendState = 1 << 10,
169 kALL_GrGLBackendState = 0xffff
170};
171
172/**
173 * This value translates to reseting all the context state for any backend.
174 */
175static const uint32_t kAll_GrBackendState = 0xffffffff;
176
177typedef void* GrGpuFinishedContext;
178typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext);
179
180typedef void* GrGpuSubmittedContext;
181typedef void (*GrGpuSubmittedProc)(GrGpuSubmittedContext submittedContext, bool success);
182
184typedef void (*GrDirectContextDestroyedProc)(GrDirectContextDestroyedContext destroyedContext);
185
186/**
187 * Struct to supply options to flush calls.
188 *
189 * After issuing all commands, fNumSemaphore semaphores will be signaled by the gpu. The client
190 * passes in an array of fNumSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's
191 * can be either initialized or not. If they are initialized, the backend uses the passed in
192 * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore
193 * object is initialized with that semaphore. The semaphores are not sent to the GPU until the next
194 * GrContext::submit call is made. See the GrContext::submit for more information.
195 *
196 * The client will own and be responsible for deleting the underlying semaphores that are stored
197 * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects
198 * themselves can be deleted as soon as this function returns.
199 *
200 * If a finishedProc is provided, the finishedProc will be called when all work submitted to the gpu
201 * from this flush call and all previous flush calls has finished on the GPU. If the flush call
202 * fails due to an error and nothing ends up getting sent to the GPU, the finished proc is called
203 * immediately.
204 *
205 * If a submittedProc is provided, the submittedProc will be called when all work from this flush
206 * call is submitted to the GPU. If the flush call fails due to an error and nothing will get sent
207 * to the GPU, the submitted proc is called immediately. It is possibly that when work is finally
208 * submitted, that the submission actual fails. In this case we will not reattempt to do the
209 * submission. Skia notifies the client of these via the success bool passed into the submittedProc.
210 * The submittedProc is useful to the client to know when semaphores that were sent with the flush
211 * have actually been submitted to the GPU so that they can be waited on (or deleted if the submit
212 * fails).
213 * GrBackendSemaphores are not supported for the GL backend and will be ignored if set.
214 */
215struct GrFlushInfo {
216 size_t fNumSemaphores = 0;
222};
223
224/**
225 * Enum used as return value when flush with semaphores so the client knows whether the valid
226 * semaphores will be submitted on the next GrContext::submit call.
227 */
228enum class GrSemaphoresSubmitted : bool {
229 kNo = false,
230 kYes = true
231};
232
233enum class GrPurgeResourceOptions {
236};
237
238enum class GrSyncCpu : bool {
239 kNo = false,
240 kYes = true,
241};
242
243#endif
GrPurgeResourceOptions
Definition GrTypes.h:234
GrSurfaceOrigin
Definition GrTypes.h:147
@ kBottomLeft_GrSurfaceOrigin
Definition GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
static const uint32_t kAll_GrBackendState
Definition GrTypes.h:176
static constexpr GrBackendApi kVulkan_GrBackend
Definition GrTypes.h:126
GrBackendApi
Definition GrTypes.h:95
static constexpr GrBackendApi kMock_GrBackend
Definition GrTypes.h:127
void * GrDirectContextDestroyedContext
Definition GrTypes.h:184
GrSemaphoresSubmitted
Definition GrTypes.h:229
void * GrGpuSubmittedContext
Definition GrTypes.h:181
void * GrGpuFinishedContext
Definition GrTypes.h:178
void(* GrGpuSubmittedProc)(GrGpuSubmittedContext submittedContext, bool success)
Definition GrTypes.h:182
void(* GrDirectContextDestroyedProc)(GrDirectContextDestroyedContext destroyedContext)
Definition GrTypes.h:185
void(* GrGpuFinishedProc)(GrGpuFinishedContext finishedContext)
Definition GrTypes.h:179
GrSyncCpu
Definition GrTypes.h:239
GrGLBackendState
Definition GrTypes.h:156
@ kProgram_GrGLBackendState
Definition GrTypes.h:167
@ kView_GrGLBackendState
Definition GrTypes.h:161
@ kTextureBinding_GrGLBackendState
Definition GrTypes.h:159
@ kVertex_GrGLBackendState
Definition GrTypes.h:164
@ kBlend_GrGLBackendState
Definition GrTypes.h:162
@ kMisc_GrGLBackendState
Definition GrTypes.h:169
@ kMSAAEnable_GrGLBackendState
Definition GrTypes.h:163
@ kALL_GrGLBackendState
Definition GrTypes.h:170
@ kFixedFunction_GrGLBackendState
Definition GrTypes.h:168
@ kPixelStore_GrGLBackendState
Definition GrTypes.h:166
@ kStencil_GrGLBackendState
Definition GrTypes.h:165
@ kRenderTarget_GrGLBackendState
Definition GrTypes.h:157
GrBackendApi GrBackend
Definition GrTypes.h:123
static constexpr GrBackendApi kMetal_GrBackend
Definition GrTypes.h:125
Renderable
Definition GpuTypes.h:69
Protected
Definition GpuTypes.h:61
GrGpuFinishedContext fFinishedContext
Definition GrTypes.h:220
GrBackendSemaphore * fSignalSemaphores
Definition GrTypes.h:218
GrGpuFinishedProc fFinishedProc
Definition GrTypes.h:219
GrGpuSubmittedContext fSubmittedContext
Definition GrTypes.h:222
GrGpuSubmittedProc fSubmittedProc
Definition GrTypes.h:221
size_t fNumSemaphores
Definition GrTypes.h:217

◆ GR_MAKE_BITFIELD_CLASS_OPS

#define GR_MAKE_BITFIELD_CLASS_OPS (   X)

Defines bitwise operators that make it possible to use an enum class as a basic bitfield.

Definition at line 42 of file GrTypes.h.

43 { \
44 return GrTFlagsMask<X>(~static_cast<int>(a)); \
45 } \
46 [[maybe_unused]] constexpr X operator|(X a, X b) { \
47 return static_cast<X>(static_cast<int>(a) | static_cast<int>(b)); \
48 } \
49 [[maybe_unused]] inline X& operator|=(X& a, X b) { \
50 return (a = a | b); \
51 } \
52 [[maybe_unused]] constexpr bool operator&(X a, X b) { \
53 return SkToBool(static_cast<int>(a) & static_cast<int>(b)); \
54 } \
55 [[maybe_unused]] constexpr GrTFlagsMask<X> operator|(GrTFlagsMask<X> a, GrTFlagsMask<X> b) { \
56 return GrTFlagsMask<X>(a.value() | b.value()); \
57 } \
58 [[maybe_unused]] constexpr GrTFlagsMask<X> operator|(GrTFlagsMask<X> a, X b) { \
59 return GrTFlagsMask<X>(a.value() | static_cast<int>(b)); \
60 } \
61 [[maybe_unused]] constexpr GrTFlagsMask<X> operator|(X a, GrTFlagsMask<X> b) { \
62 return GrTFlagsMask<X>(static_cast<int>(a) | b.value()); \
63 } \
64 [[maybe_unused]] constexpr X operator&(GrTFlagsMask<X> a, GrTFlagsMask<X> b) { \
65 return static_cast<X>(a.value() & b.value()); \
66 } \
67 [[maybe_unused]] constexpr X operator&(GrTFlagsMask<X> a, X b) { \
68 return static_cast<X>(a.value() & static_cast<int>(b)); \
69 } \
70 [[maybe_unused]] constexpr X operator&(X a, GrTFlagsMask<X> b) { \
71 return static_cast<X>(static_cast<int>(a) & b.value()); \
72 } \
73 [[maybe_unused]] inline X& operator&=(X& a, GrTFlagsMask<X> b) { \
74 return (a = a & b); \
75 } \
76
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
static bool b
struct MyStruct a[10]

Typedef Documentation

◆ GrBackend

Previously the above enum was not an enum class but a normal enum. To support the legacy use of the enum values we define them below so that no clients break.

Definition at line 123 of file GrTypes.h.

◆ GrDirectContextDestroyedContext

Definition at line 184 of file GrTypes.h.

◆ GrDirectContextDestroyedProc

typedef void(* GrDirectContextDestroyedProc) (GrDirectContextDestroyedContext destroyedContext)

Definition at line 185 of file GrTypes.h.

◆ GrGpuFinishedContext

typedef void* GrGpuFinishedContext

Definition at line 178 of file GrTypes.h.

◆ GrGpuFinishedProc

typedef void(* GrGpuFinishedProc) (GrGpuFinishedContext finishedContext)

Definition at line 179 of file GrTypes.h.

◆ GrGpuSubmittedContext

typedef void* GrGpuSubmittedContext

Definition at line 181 of file GrTypes.h.

◆ GrGpuSubmittedProc

typedef void(* GrGpuSubmittedProc) (GrGpuSubmittedContext submittedContext, bool success)

Definition at line 182 of file GrTypes.h.

◆ GrProtected

Definition at line 139 of file GrTypes.h.

◆ GrRenderable

Definition at line 134 of file GrTypes.h.

Enumeration Type Documentation

◆ GrBackendApi

enum class GrBackendApi : unsigned
strong

Possible 3D APIs that may be used by Ganesh.

Enumerator
kOpenGL 
kVulkan 
kMetal 
kDirect3D 
kMock 

Mock is a backend that does not draw anything. It is used for unit tests and to measure CPU overhead.

kUnsupported 

Ganesh doesn't support some context types (e.g. Dawn) and will return Unsupported.

kOpenGL_GrBackend 

Added here to support the legacy GrBackend enum value and clients who referenced it using GrBackend::kOpenGL_GrBackend.

Definition at line 95 of file GrTypes.h.

95 : unsigned {
96 kOpenGL,
97 kVulkan,
98 kMetal,
100
101 /**
102 * Mock is a backend that does not draw anything. It is used for unit tests
103 * and to measure CPU overhead.
104 */
105 kMock,
106
107 /**
108 * Ganesh doesn't support some context types (e.g. Dawn) and will return Unsupported.
109 */
111
112 /**
113 * Added here to support the legacy GrBackend enum value and clients who referenced it using
114 * GrBackend::kOpenGL_GrBackend.
115 */
117};

◆ GrGLBackendState

A GrContext's cache of backend context state can be partially invalidated. These enums are specific to the GL backend and we'd add a new set for an alternative backend.

Enumerator
kRenderTarget_GrGLBackendState 
kTextureBinding_GrGLBackendState 
kView_GrGLBackendState 
kBlend_GrGLBackendState 
kMSAAEnable_GrGLBackendState 
kVertex_GrGLBackendState 
kStencil_GrGLBackendState 
kPixelStore_GrGLBackendState 
kProgram_GrGLBackendState 
kFixedFunction_GrGLBackendState 
kMisc_GrGLBackendState 
kALL_GrGLBackendState 

Definition at line 156 of file GrTypes.h.

156 {
158 // Also includes samplers bound to texture units.
160 // View state stands for scissor and viewport
161 kView_GrGLBackendState = 1 << 2,
169 kMisc_GrGLBackendState = 1 << 10,
170 kALL_GrGLBackendState = 0xffff
171};

◆ GrPurgeResourceOptions

enum class GrPurgeResourceOptions
strong
Enumerator
kAllResources 
kScratchResourcesOnly 

Definition at line 234 of file GrTypes.h.

234 {
237};

◆ GrSemaphoresSubmitted

enum class GrSemaphoresSubmitted : bool
strong

Enum used as return value when flush with semaphores so the client knows whether the valid semaphores will be submitted on the next GrContext::submit call.

Enumerator
kNo 
kYes 

Definition at line 229 of file GrTypes.h.

229 : bool {
230 kNo = false,
231 kYes = true
232};

◆ GrSurfaceOrigin

GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either the top-left or bottom-left content pixel.

Enumerator
kTopLeft_GrSurfaceOrigin 
kBottomLeft_GrSurfaceOrigin 

Definition at line 147 of file GrTypes.h.

◆ GrSyncCpu

enum class GrSyncCpu : bool
strong
Enumerator
kNo 
kYes 

Definition at line 239 of file GrTypes.h.

239 : bool {
240 kNo = false,
241 kYes = true,
242};

Variable Documentation

◆ kAll_GrBackendState

const uint32_t kAll_GrBackendState = 0xffffffff
static

This value translates to reseting all the context state for any backend.

Definition at line 176 of file GrTypes.h.

◆ kMetal_GrBackend

constexpr GrBackendApi kMetal_GrBackend = GrBackendApi::kMetal
staticconstexpr

Definition at line 125 of file GrTypes.h.

◆ kMock_GrBackend

constexpr GrBackendApi kMock_GrBackend = GrBackendApi::kMock
staticconstexpr

Definition at line 127 of file GrTypes.h.

◆ kVulkan_GrBackend

constexpr GrBackendApi kVulkan_GrBackend = GrBackendApi::kVulkan
staticconstexpr

Definition at line 126 of file GrTypes.h.