Flutter Engine
The Flutter Engine
Functions
GrDirectContexts Namespace Reference

Functions

SK_API sk_sp< GrDirectContextMakeGL (sk_sp< const GrGLInterface >, const GrContextOptions &)
 
SK_API sk_sp< GrDirectContextMakeGL (sk_sp< const GrGLInterface >)
 
SK_API sk_sp< GrDirectContextMakeGL (const GrContextOptions &)
 
SK_API sk_sp< GrDirectContextMakeGL ()
 
SK_API sk_sp< GrDirectContextMakeMetal (const GrMtlBackendContext &, const GrContextOptions &)
 
SK_API sk_sp< GrDirectContextMakeMetal (const GrMtlBackendContext &)
 
SK_API sk_sp< GrDirectContextMakeVulkan (const skgpu::VulkanBackendContext &, const GrContextOptions &)
 
SK_API sk_sp< GrDirectContextMakeVulkan (const skgpu::VulkanBackendContext &)
 

Function Documentation

◆ MakeGL() [1/4]

sk_sp< GrDirectContext > GrDirectContexts::MakeGL ( )

Definition at line 48 of file GrGLDirectContext.cpp.

48 {
49 GrContextOptions defaultOptions;
50 return MakeGL(nullptr, defaultOptions);
51}
SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target)

◆ MakeGL() [2/4]

sk_sp< GrDirectContext > GrDirectContexts::MakeGL ( const GrContextOptions options)

Definition at line 44 of file GrGLDirectContext.cpp.

44 {
45 return MakeGL(nullptr, options);
46}
const char * options

◆ MakeGL() [3/4]

sk_sp< GrDirectContext > GrDirectContexts::MakeGL ( sk_sp< const GrGLInterface glInterface)

Definition at line 38 of file GrGLDirectContext.cpp.

38 {
39 GrContextOptions defaultOptions;
40 return MakeGL(std::move(glInterface), defaultOptions);
41}

◆ MakeGL() [4/4]

sk_sp< GrDirectContext > GrDirectContexts::MakeGL ( sk_sp< const GrGLInterface glInterface,
const GrContextOptions options 
)

Creates a GrDirectContext for a backend context. GrGLInterface must be non-null.

Definition at line 83 of file GrGLDirectContext.cpp.

84 {
85#if defined(SK_DISABLE_LEGACY_GL_MAKE_NATIVE_INTERFACE)
86 SkASSERT(glInterface);
87#endif
88 auto direct = GrDirectContextPriv::Make(
90 options,
92#if defined(GR_TEST_UTILS)
93 if (options.fRandomGLOOM) {
94 auto copy = sk_make_sp<GrGLInterface>(*glInterface);
95 copy->fFunctions.fGetError =
96 make_get_error_with_random_oom(glInterface->fFunctions.fGetError);
97#if GR_GL_CHECK_ERROR
98 // Suppress logging GL errors since we'll be synthetically generating them.
99 copy->suppressErrorLogging();
100#endif
101 glInterface = std::move(copy);
102 }
103#endif
105 GrGLGpu::Make(std::move(glInterface), options, direct.get()));
106 if (!GrDirectContextPriv::Init(direct)) {
107 return nullptr;
108 }
109 return direct;
110}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static sk_sp< GrContextThreadSafeProxy > Make(GrBackendApi, const GrContextOptions &)
static void SetGpu(const sk_sp< GrDirectContext > &ctx, std::unique_ptr< GrGpu > gpu)
static bool Init(const sk_sp< GrDirectContext > &ctx)
static sk_sp< GrDirectContext > Make(GrBackendApi backend, const GrContextOptions &options, sk_sp< GrContextThreadSafeProxy > proxy)
static std::unique_ptr< GrGpu > Make(sk_sp< const GrGLInterface >, const GrContextOptions &, GrDirectContext *)
Definition: GrGLGpu.cpp:408
Definition: copy.py:1
GrGLFunction< GrGLGetErrorFn > fGetError
struct GrGLInterface::Functions fFunctions

◆ MakeMetal() [1/2]

sk_sp< GrDirectContext > GrDirectContexts::MakeMetal ( const GrMtlBackendContext backendContext)

Definition at line 16 of file GrMtlDirectContext.mm.

16 {
17 GrContextOptions defaultOptions;
18 return MakeMetal(backendContext, defaultOptions);
19}
SK_API sk_sp< GrDirectContext > MakeMetal(const GrMtlBackendContext &, const GrContextOptions &)

◆ MakeMetal() [2/2]

sk_sp< GrDirectContext > GrDirectContexts::MakeMetal ( const GrMtlBackendContext backendContext,
const GrContextOptions options 
)

Makes a GrDirectContext which uses Metal as the backend. The GrMtlBackendContext contains a MTLDevice and MTLCommandQueue which should be used by the backend. These objects must have their own ref which will be released when the GrMtlBackendContext is destroyed. Ganesh will take its own ref on the objects which will be released when the GrDirectContext is destroyed.

Definition at line 21 of file GrMtlDirectContext.mm.

22 {
25 options,
27
29 GrMtlTrampoline::MakeGpu(backendContext, options, direct.get()));
30 if (!GrDirectContextPriv::Init(direct)) {
31 return nullptr;
32 }
33
34 return direct;
35}
static std::unique_ptr< GrGpu > MakeGpu(const GrMtlBackendContext &, const GrContextOptions &, GrDirectContext *)
T * get() const
Definition: SkRefCnt.h:303

◆ MakeVulkan() [1/2]

sk_sp< GrDirectContext > GrDirectContexts::MakeVulkan ( const skgpu::VulkanBackendContext backendContext)

Definition at line 19 of file GrVkDirectContext.cpp.

19 {
20 GrContextOptions defaultOptions;
21 return MakeVulkan(backendContext, defaultOptions);
22}
SK_API sk_sp< GrDirectContext > MakeVulkan(const skgpu::VulkanBackendContext &, const GrContextOptions &)

◆ MakeVulkan() [2/2]

sk_sp< GrDirectContext > GrDirectContexts::MakeVulkan ( const skgpu::VulkanBackendContext backendContext,
const GrContextOptions options 
)

The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned GrDirectContext is destroyed. This also means that any objects created with this GrDirectContext (e.g. SkSurfaces, SkImages, etc.) must also be released as they may hold refs on the GrDirectContext. Once all these objects and the GrDirectContext are released, then it is safe to delete the vulkan objects.

Definition at line 24 of file GrVkDirectContext.cpp.

25 {
26 auto direct = GrDirectContextPriv::Make(
27 GrBackendApi::kVulkan, options, sk_make_sp<GrVkContextThreadSafeProxy>(options));
28
30 GrVkGpu::Make(backendContext, options, direct.get()));
31 if (!GrDirectContextPriv::Init(direct)) {
32 return nullptr;
33 }
34
35 return direct;
36}
static std::unique_ptr< GrGpu > Make(const skgpu::VulkanBackendContext &, const GrContextOptions &, GrDirectContext *)
Definition: GrVkGpu.cpp:70