Flutter Engine
The Flutter Engine
ContextType.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google Inc.
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
10#include "include/gpu/GrTypes.h"
12
14 switch (type) {
16 return "OpenGL";
18 return "OpenGLES";
20 return "ANGLE D3D9 ES2";
22 return "ANGLE D3D11 ES2";
24 return "ANGLE D3D11 ES3";
26 return "ANGLE GL ES2";
28 return "ANGLE GL ES3";
30 return "ANGLE Metal ES2";
32 return "ANGLE Metal ES3";
34 return "Vulkan";
36 return "Metal";
38 return "Direct3D";
40 return "Dawn D3D11";
42 return "Dawn D3D12";
44 return "Dawn Metal";
46 return "Dawn Vulkan";
48 return "Dawn OpenGL";
50 return "Dawn OpenGLES";
52 return "Mock";
53 }
55}
56
58 switch (type) {
59 case ContextType::kDirect3D:
60 case ContextType::kGL:
61 case ContextType::kGLES:
64 return true;
65
66 default:
67 // Mock doesn't use the GPU, and Dawn and ANGLE add a layer between Skia and the native
68 // GPU backend.
69 return false;
70 }
71}
72
74 switch (type) {
75 case ContextType::kDawn_D3D11:
76 case ContextType::kDawn_D3D12:
77 case ContextType::kDawn_Metal:
78 case ContextType::kDawn_OpenGL:
79 case ContextType::kDawn_OpenGLES:
80 case ContextType::kDawn_Vulkan:
81 return true;
82
83 default:
84 return false;
85 }
86}
87
89 return type != ContextType::kMock;
90}
91
93 switch (type) {
104
107
110
111 case ContextType::kDirect3D:
113
114 case ContextType::kDawn_D3D11:
115 case ContextType::kDawn_D3D12:
116 case ContextType::kDawn_Metal:
117 case ContextType::kDawn_Vulkan:
118 case ContextType::kDawn_OpenGL:
119 case ContextType::kDawn_OpenGLES:
121
122 case ContextType::kMock:
123 return GrBackendApi::kMock;
124 }
126}
127
129 switch (type) {
140 return BackendApi::kUnsupported;
141
143 return BackendApi::kVulkan;
144
146 return BackendApi::kMetal;
147
148 case ContextType::kDawn_D3D11:
149 case ContextType::kDawn_D3D12:
150 case ContextType::kDawn_Metal:
151 case ContextType::kDawn_Vulkan:
152 case ContextType::kDawn_OpenGL:
153 case ContextType::kDawn_OpenGLES:
154 return BackendApi::kDawn;
155
156 case ContextType::kMock:
157 return BackendApi::kMock;
158 }
160}
GrBackendApi
Definition: GrTypes.h:95
#define SkUNREACHABLE
Definition: SkAssert.h:135
GLenum type
@ kVulkan
Definition: embedder.h:86
@ kMetal
Definition: embedder.h:85
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
Definition: ContextType.cpp:92
skgpu::BackendApi ContextTypeBackend(skgpu::ContextType type)
bool IsDawnBackend(skgpu::ContextType type)
Definition: ContextType.cpp:73
BackendApi
Definition: GpuTypes.h:22
bool IsNativeBackend(skgpu::ContextType type)
Definition: ContextType.cpp:57
ContextType
Definition: ContextType.h:19
@ kDawn_OpenGLES
Dawn on OpenGL.
@ kDawn_Metal
Dawn on Direct3D12.
@ kGLES
OpenGL context.
@ kANGLE_GL_ES2
ANGLE on Direct3D11 OpenGL ES 3 context.
@ kDawn_D3D12
Dawn on Direct3D11.
@ kANGLE_GL_ES3
ANGLE on OpenGL OpenGL ES 2 context.
@ kANGLE_D3D11_ES2
ANGLE on Direct3D9 OpenGL ES 2 context.
@ kDawn_Vulkan
Dawn on Metal.
@ kVulkan
ANGLE on Metal ES 3 context.
@ kDawn_OpenGL
Dawn on Vulkan.
@ kDawn_D3D11
Direct3D 12.
@ kANGLE_D3D11_ES3
ANGLE on Direct3D11 OpenGL ES 2 context.
@ kANGLE_D3D9_ES2
OpenGL ES context.
@ kANGLE_Metal_ES2
ANGLE on OpenGL OpenGL ES 3 context.
@ kANGLE_Metal_ES3
ANGLE on Metal ES 2 context.
@ kMock
Dawn on OpenGL ES.
const char * ContextTypeName(skgpu::ContextType type)
Definition: ContextType.cpp:13
bool IsRenderingContext(skgpu::ContextType type)
Definition: ContextType.cpp:88