Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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) {
15 case skgpu::ContextType::kGL:
16 return "OpenGL";
17 case skgpu::ContextType::kGLES:
18 return "OpenGLES";
19 case skgpu::ContextType::kANGLE_D3D9_ES2:
20 return "ANGLE D3D9 ES2";
21 case skgpu::ContextType::kANGLE_D3D11_ES2:
22 return "ANGLE D3D11 ES2";
23 case skgpu::ContextType::kANGLE_D3D11_ES3:
24 return "ANGLE D3D11 ES3";
25 case skgpu::ContextType::kANGLE_GL_ES2:
26 return "ANGLE GL ES2";
27 case skgpu::ContextType::kANGLE_GL_ES3:
28 return "ANGLE GL ES3";
29 case skgpu::ContextType::kANGLE_Metal_ES2:
30 return "ANGLE Metal ES2";
31 case skgpu::ContextType::kANGLE_Metal_ES3:
32 return "ANGLE Metal ES3";
33 case skgpu::ContextType::kVulkan:
34 return "Vulkan";
35 case skgpu::ContextType::kMetal:
36 return "Metal";
37 case skgpu::ContextType::kDirect3D:
38 return "Direct3D";
39 case skgpu::ContextType::kDawn_D3D11:
40 return "Dawn D3D11";
41 case skgpu::ContextType::kDawn_D3D12:
42 return "Dawn D3D12";
43 case skgpu::ContextType::kDawn_Metal:
44 return "Dawn Metal";
45 case skgpu::ContextType::kDawn_Vulkan:
46 return "Dawn Vulkan";
47 case skgpu::ContextType::kDawn_OpenGL:
48 return "Dawn OpenGL";
49 case skgpu::ContextType::kDawn_OpenGLES:
50 return "Dawn OpenGLES";
51 case skgpu::ContextType::kMock:
52 return "Mock";
53 }
55}
56
58 switch (type) {
59 case ContextType::kDirect3D:
60 case ContextType::kGL:
61 case ContextType::kGLES:
62 case ContextType::kMetal:
63 case ContextType::kVulkan:
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) {
94 case skgpu::ContextType::kGL:
95 case skgpu::ContextType::kGLES:
96 case skgpu::ContextType::kANGLE_D3D9_ES2:
97 case skgpu::ContextType::kANGLE_D3D11_ES2:
98 case skgpu::ContextType::kANGLE_D3D11_ES3:
99 case skgpu::ContextType::kANGLE_GL_ES2:
100 case skgpu::ContextType::kANGLE_GL_ES3:
101 case skgpu::ContextType::kANGLE_Metal_ES2:
102 case skgpu::ContextType::kANGLE_Metal_ES3:
104
105 case ContextType::kVulkan:
107
108 case ContextType::kMetal:
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) {
130 case skgpu::ContextType::kGL:
131 case skgpu::ContextType::kGLES:
132 case skgpu::ContextType::kANGLE_D3D9_ES2:
133 case skgpu::ContextType::kANGLE_D3D11_ES2:
134 case skgpu::ContextType::kANGLE_D3D11_ES3:
135 case skgpu::ContextType::kANGLE_GL_ES2:
136 case skgpu::ContextType::kANGLE_GL_ES3:
137 case skgpu::ContextType::kANGLE_Metal_ES2:
138 case skgpu::ContextType::kANGLE_Metal_ES3:
139 case skgpu::ContextType::kDirect3D:
140 return BackendApi::kUnsupported;
141
142 case ContextType::kVulkan:
143 return BackendApi::kVulkan;
144
145 case ContextType::kMetal:
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
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
skgpu::BackendApi ContextTypeBackend(skgpu::ContextType type)
bool IsDawnBackend(skgpu::ContextType type)
BackendApi
Definition GpuTypes.h:22
bool IsNativeBackend(skgpu::ContextType type)
const char * ContextTypeName(skgpu::ContextType type)
bool IsRenderingContext(skgpu::ContextType type)