blob: 6f04a5fc7b5292447620c058a8016148d9b4d4ea [file] [log] [blame]
Robert Phillipsa3457b82018-03-08 11:30:12 -05001/*
2 * Copyright 2018 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
Greg Daniel54bfb182018-11-20 17:12:36 -05008
Robert Phillipsb7bfbc22020-07-01 12:55:01 -04009#include "include/gpu/GrDirectContext.h"
Robert Phillipsa3457b82018-03-08 11:30:12 -050010
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrContextThreadSafeProxy.h"
12#include "src/gpu/GrContextPriv.h"
13#include "src/gpu/GrContextThreadSafeProxyPriv.h"
14#include "src/gpu/GrGpu.h"
Robert Phillipsa3457b82018-03-08 11:30:12 -050015
Mike Kleinc0bd9f92019-04-23 12:05:21 -050016#include "src/gpu/effects/GrSkSLFP.h"
17#include "src/gpu/gl/GrGLGpu.h"
18#include "src/gpu/mock/GrMockGpu.h"
Robert Phillips5edf5102020-08-10 16:30:36 -040019#include "src/gpu/ops/GrSmallPathAtlasMgr.h"
Robert Phillipse19babf2020-04-06 13:57:30 -040020#include "src/gpu/text/GrAtlasManager.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050021#include "src/gpu/text/GrStrikeCache.h"
Robert Phillipsa3457b82018-03-08 11:30:12 -050022#ifdef SK_METAL
Mike Kleinc0bd9f92019-04-23 12:05:21 -050023#include "src/gpu/mtl/GrMtlTrampoline.h"
Robert Phillipsa3457b82018-03-08 11:30:12 -050024#endif
25#ifdef SK_VULKAN
Mike Kleinc0bd9f92019-04-23 12:05:21 -050026#include "src/gpu/vk/GrVkGpu.h"
Robert Phillipsa3457b82018-03-08 11:30:12 -050027#endif
Jim Van Verthd2d4c5e2020-02-19 14:57:58 -050028#ifdef SK_DIRECT3D
29#include "src/gpu/d3d/GrD3DGpu.h"
30#endif
Stephen White985741a2019-07-18 11:43:45 -040031#ifdef SK_DAWN
Mike Klein52337de2019-07-25 09:00:52 -050032#include "src/gpu/dawn/GrDawnGpu.h"
Stephen White985741a2019-07-18 11:43:45 -040033#endif
Robert Phillipsa3457b82018-03-08 11:30:12 -050034
Brian Salomon24069eb2020-06-24 10:19:52 -040035#if GR_TEST_UTILS
36# include "include/utils/SkRandom.h"
37# if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
38# include <sanitizer/lsan_interface.h>
39# endif
40#endif
41
Robert Phillips6db27c22019-05-01 10:43:56 -040042#ifdef SK_DISABLE_REDUCE_OPLIST_SPLITTING
Greg Danielf41b2bd2019-08-22 16:19:24 -040043static const bool kDefaultReduceOpsTaskSplitting = false;
Robert Phillips6db27c22019-05-01 10:43:56 -040044#else
Greg Danielf41b2bd2019-08-22 16:19:24 -040045static const bool kDefaultReduceOpsTaskSplitting = false;
Robert Phillips6db27c22019-05-01 10:43:56 -040046#endif
47
Robert Phillipsad248452020-06-30 09:27:52 -040048GrDirectContext::GrDirectContext(GrBackendApi backend, const GrContextOptions& options)
Robert Phillips3262bc82020-08-10 12:11:58 -040049 : INHERITED(GrContextThreadSafeProxyPriv::Make(backend, options)) {
Robert Phillipsad248452020-06-30 09:27:52 -040050}
Robert Phillipsa3457b82018-03-08 11:30:12 -050051
Robert Phillipsad248452020-06-30 09:27:52 -040052GrDirectContext::~GrDirectContext() {
53 // this if-test protects against the case where the context is being destroyed
54 // before having been fully created
55 if (this->priv().getGpu()) {
Greg Daniel0a2464f2020-05-14 15:45:44 -040056 this->flushAndSubmit();
Robert Phillipsa3457b82018-03-08 11:30:12 -050057 }
Robert Phillipsad248452020-06-30 09:27:52 -040058}
Robert Phillipsa3457b82018-03-08 11:30:12 -050059
Robert Phillipsad248452020-06-30 09:27:52 -040060void GrDirectContext::abandonContext() {
61 INHERITED::abandonContext();
Robert Phillips079455c2020-08-11 15:18:46 -040062 if (fSmallPathAtlasMgr) {
63 fSmallPathAtlasMgr->reset();
64 }
Robert Phillipsad248452020-06-30 09:27:52 -040065 fAtlasManager->freeAll();
66}
Robert Phillipsa3457b82018-03-08 11:30:12 -050067
Robert Phillipsad248452020-06-30 09:27:52 -040068void GrDirectContext::releaseResourcesAndAbandonContext() {
69 INHERITED::releaseResourcesAndAbandonContext();
Robert Phillips079455c2020-08-11 15:18:46 -040070 if (fSmallPathAtlasMgr) {
71 fSmallPathAtlasMgr->reset();
72 }
Robert Phillipsad248452020-06-30 09:27:52 -040073 fAtlasManager->freeAll();
74}
Robert Phillips6db27c22019-05-01 10:43:56 -040075
Robert Phillipsad248452020-06-30 09:27:52 -040076void GrDirectContext::freeGpuResources() {
77 this->flushAndSubmit();
Robert Phillips079455c2020-08-11 15:18:46 -040078 if (fSmallPathAtlasMgr) {
79 fSmallPathAtlasMgr->reset();
80 }
Robert Phillipsad248452020-06-30 09:27:52 -040081 fAtlasManager->freeAll();
Robert Phillips56181ba2019-03-08 12:00:45 -050082
Robert Phillipsad248452020-06-30 09:27:52 -040083 INHERITED::freeGpuResources();
84}
Robert Phillipsa3457b82018-03-08 11:30:12 -050085
Robert Phillipsad248452020-06-30 09:27:52 -040086bool GrDirectContext::init() {
87 const GrGpu* gpu = this->priv().getGpu();
88 if (!gpu) {
89 return false;
Robert Phillipsa3457b82018-03-08 11:30:12 -050090 }
91
Robert Phillipsad248452020-06-30 09:27:52 -040092 fThreadSafeProxy->priv().init(gpu->refCaps());
93 if (!INHERITED::init()) {
94 return false;
95 }
Robert Phillipsa3457b82018-03-08 11:30:12 -050096
Robert Phillipsad248452020-06-30 09:27:52 -040097 bool reduceOpsTaskSplitting = kDefaultReduceOpsTaskSplitting;
98 if (GrContextOptions::Enable::kNo == this->options().fReduceOpsTaskSplitting) {
99 reduceOpsTaskSplitting = false;
100 } else if (GrContextOptions::Enable::kYes == this->options().fReduceOpsTaskSplitting) {
101 reduceOpsTaskSplitting = true;
102 }
Robert Phillipsa3457b82018-03-08 11:30:12 -0500103
Robert Phillipsad248452020-06-30 09:27:52 -0400104 this->setupDrawingManager(true, reduceOpsTaskSplitting);
105
106 GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
107 if (GrContextOptions::Enable::kNo == this->options().fAllowMultipleGlyphCacheTextures ||
108 // multitexturing supported only if range can represent the index + texcoords fully
109 !(this->caps()->shaderCaps()->floatIs32Bits() ||
110 this->caps()->shaderCaps()->integerSupport())) {
111 allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
112 } else {
113 allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
114 }
115
116 GrProxyProvider* proxyProvider = this->priv().proxyProvider();
117
Robert Phillips3262bc82020-08-10 12:11:58 -0400118 fAtlasManager = std::make_unique<GrAtlasManager>(proxyProvider,
119 this->options().fGlyphCacheTextureMaximumBytes,
120 allowMultitexturing);
121 this->priv().addOnFlushCallbackObject(fAtlasManager.get());
Robert Phillipsad248452020-06-30 09:27:52 -0400122
123 return true;
124}
Robert Phillipsa3457b82018-03-08 11:30:12 -0500125
Robert Phillips5edf5102020-08-10 16:30:36 -0400126GrSmallPathAtlasMgr* GrDirectContext::onGetSmallPathAtlasMgr() {
Robert Phillips079455c2020-08-11 15:18:46 -0400127 if (!fSmallPathAtlasMgr) {
128 fSmallPathAtlasMgr = std::make_unique<GrSmallPathAtlasMgr>();
129
130 this->priv().addOnFlushCallbackObject(fSmallPathAtlasMgr.get());
131 }
132
133 if (!fSmallPathAtlasMgr->initAtlas(this->proxyProvider(), this->caps())) {
134 return nullptr;
135 }
136
137 return fSmallPathAtlasMgr.get();
Robert Phillips5edf5102020-08-10 16:30:36 -0400138}
139
John Rosascoa9b348f2019-11-08 13:18:15 -0800140#ifdef SK_GL
Robert Phillipsf4f80112020-07-13 16:13:31 -0400141/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400142#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
143
Jim Van Verth03b8ab22020-02-24 11:36:15 -0500144sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> glInterface) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400145 return GrDirectContext::MakeGL(std::move(glInterface));
146}
147
148sk_sp<GrContext> GrContext::MakeGL(const GrContextOptions& options) {
149 return GrDirectContext::MakeGL(options);
150}
151
152sk_sp<GrContext> GrContext::MakeGL() {
153 return GrDirectContext::MakeGL();
154}
155
156sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> glInterface,
157 const GrContextOptions& options) {
158 return GrDirectContext::MakeGL(std::move(glInterface), options);
159}
160
Robert Phillipsc7228c62020-07-14 12:57:39 -0400161#endif
162
Robert Phillipsf4f80112020-07-13 16:13:31 -0400163/*************************************************************************************************/
164sk_sp<GrDirectContext> GrDirectContext::MakeGL(sk_sp<const GrGLInterface> glInterface) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500165 GrContextOptions defaultOptions;
Jim Van Verth03b8ab22020-02-24 11:36:15 -0500166 return MakeGL(std::move(glInterface), defaultOptions);
Robert Phillipsa3457b82018-03-08 11:30:12 -0500167}
168
Robert Phillipsf4f80112020-07-13 16:13:31 -0400169sk_sp<GrDirectContext> GrDirectContext::MakeGL(const GrContextOptions& options) {
Brian Salomonc1b9c102018-04-06 09:18:00 -0400170 return MakeGL(nullptr, options);
171}
172
Robert Phillipsf4f80112020-07-13 16:13:31 -0400173sk_sp<GrDirectContext> GrDirectContext::MakeGL() {
Brian Salomonc1b9c102018-04-06 09:18:00 -0400174 GrContextOptions defaultOptions;
175 return MakeGL(nullptr, defaultOptions);
176}
177
Brian Salomon24069eb2020-06-24 10:19:52 -0400178#if GR_TEST_UTILS
179GrGLFunction<GrGLGetErrorFn> make_get_error_with_random_oom(GrGLFunction<GrGLGetErrorFn> original) {
180 // A SkRandom and a GrGLFunction<GrGLGetErrorFn> are too big to be captured by a
181 // GrGLFunction<GrGLGetError> (surprise, surprise). So we make a context object and
182 // capture that by pointer. However, GrGLFunction doesn't support calling a destructor
183 // on the thing it captures. So we leak the context.
184 struct GetErrorContext {
185 SkRandom fRandom;
186 GrGLFunction<GrGLGetErrorFn> fGetError;
187 };
188
189 auto errorContext = new GetErrorContext;
190
191#if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
192 __lsan_ignore_object(errorContext);
193#endif
194
195 errorContext->fGetError = original;
196
197 return GrGLFunction<GrGLGetErrorFn>([errorContext]() {
198 GrGLenum error = errorContext->fGetError();
199 if (error == GR_GL_NO_ERROR && (errorContext->fRandom.nextU() % 300) == 0) {
200 error = GR_GL_OUT_OF_MEMORY;
201 }
202 return error;
203 });
204}
205#endif
206
Robert Phillipsf4f80112020-07-13 16:13:31 -0400207sk_sp<GrDirectContext> GrDirectContext::MakeGL(sk_sp<const GrGLInterface> glInterface,
208 const GrContextOptions& options) {
209 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kOpenGL, options));
Brian Salomon24069eb2020-06-24 10:19:52 -0400210#if GR_TEST_UTILS
211 if (options.fRandomGLOOM) {
212 auto copy = sk_make_sp<GrGLInterface>(*glInterface);
213 copy->fFunctions.fGetError =
214 make_get_error_with_random_oom(glInterface->fFunctions.fGetError);
215#if GR_GL_CHECK_ERROR
216 // Suppress logging GL errors since we'll be synthetically generating them.
217 copy->suppressErrorLogging();
218#endif
219 glInterface = std::move(copy);
220 }
221#endif
Robert Phillipsf4f80112020-07-13 16:13:31 -0400222 direct->fGpu = GrGLGpu::Make(std::move(glInterface), options, direct.get());
223 if (!direct->init()) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500224 return nullptr;
225 }
Robert Phillipsf4f80112020-07-13 16:13:31 -0400226 return direct;
Robert Phillipsa3457b82018-03-08 11:30:12 -0500227}
John Rosascoa9b348f2019-11-08 13:18:15 -0800228#endif
Robert Phillipsa3457b82018-03-08 11:30:12 -0500229
Robert Phillipsf4f80112020-07-13 16:13:31 -0400230/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400231#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
232
Robert Phillipsa3457b82018-03-08 11:30:12 -0500233sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400234 return GrDirectContext::MakeMock(mockOptions);
Robert Phillipsa3457b82018-03-08 11:30:12 -0500235}
236
237sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
238 const GrContextOptions& options) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400239 return GrDirectContext::MakeMock(mockOptions, options);
240}
Robert Phillipsa3457b82018-03-08 11:30:12 -0500241
Robert Phillipsc7228c62020-07-14 12:57:39 -0400242#endif
243
Robert Phillipsf4f80112020-07-13 16:13:31 -0400244/*************************************************************************************************/
245sk_sp<GrDirectContext> GrDirectContext::MakeMock(const GrMockOptions* mockOptions) {
246 GrContextOptions defaultOptions;
247 return MakeMock(mockOptions, defaultOptions);
248}
249
250sk_sp<GrDirectContext> GrDirectContext::MakeMock(const GrMockOptions* mockOptions,
251 const GrContextOptions& options) {
252 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kMock, options));
253
254 direct->fGpu = GrMockGpu::Make(mockOptions, options, direct.get());
255 if (!direct->init()) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500256 return nullptr;
257 }
Chris Daltona378b452019-12-11 13:24:11 -0500258
Robert Phillipsf4f80112020-07-13 16:13:31 -0400259 return direct;
Robert Phillipsa3457b82018-03-08 11:30:12 -0500260}
261
Greg Danielb4d89562018-10-03 18:44:49 +0000262#ifdef SK_VULKAN
Robert Phillipsf4f80112020-07-13 16:13:31 -0400263/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400264#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
265
Robert Phillipsf4f80112020-07-13 16:13:31 -0400266sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext) {
267 return GrDirectContext::MakeVulkan(backendContext);
Greg Daniel10a83da2018-06-14 09:31:11 -0400268}
269
270sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
271 const GrContextOptions& options) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400272 return GrDirectContext::MakeVulkan(backendContext, options);
273}
Greg Daniel10a83da2018-06-14 09:31:11 -0400274
Robert Phillipsc7228c62020-07-14 12:57:39 -0400275#endif
276
Robert Phillipsf4f80112020-07-13 16:13:31 -0400277/*************************************************************************************************/
278sk_sp<GrDirectContext> GrDirectContext::MakeVulkan(const GrVkBackendContext& backendContext) {
279 GrContextOptions defaultOptions;
280 return MakeVulkan(backendContext, defaultOptions);
281}
282
283sk_sp<GrDirectContext> GrDirectContext::MakeVulkan(const GrVkBackendContext& backendContext,
284 const GrContextOptions& options) {
285 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kVulkan, options));
286
287 direct->fGpu = GrVkGpu::Make(backendContext, options, direct.get());
288 if (!direct->init()) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500289 return nullptr;
290 }
291
Robert Phillipsf4f80112020-07-13 16:13:31 -0400292 return direct;
Greg Danielb4d89562018-10-03 18:44:49 +0000293}
Robert Phillipsf4f80112020-07-13 16:13:31 -0400294#endif
Robert Phillipsa3457b82018-03-08 11:30:12 -0500295
296#ifdef SK_METAL
Robert Phillipsf4f80112020-07-13 16:13:31 -0400297/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400298#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
299
Robert Phillipsa3457b82018-03-08 11:30:12 -0500300sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400301 return GrDirectContext::MakeMetal(device, queue);
302}
303
304sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
305 return GrDirectContext::MakeMetal(device, queue, options);
306}
307
Robert Phillipsc7228c62020-07-14 12:57:39 -0400308#endif
309
Robert Phillipsf4f80112020-07-13 16:13:31 -0400310/*************************************************************************************************/
311sk_sp<GrDirectContext> GrDirectContext::MakeMetal(void* device, void* queue) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500312 GrContextOptions defaultOptions;
313 return MakeMetal(device, queue, defaultOptions);
314}
315
Robert Phillipsf4f80112020-07-13 16:13:31 -0400316sk_sp<GrDirectContext> GrDirectContext::MakeMetal(void* device, void* queue,
317 const GrContextOptions& options) {
318 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kMetal, options));
Robert Phillipsa3457b82018-03-08 11:30:12 -0500319
Robert Phillipsf4f80112020-07-13 16:13:31 -0400320 direct->fGpu = GrMtlTrampoline::MakeGpu(direct.get(), options, device, queue);
321 if (!direct->init()) {
Robert Phillipsa3457b82018-03-08 11:30:12 -0500322 return nullptr;
323 }
Timothy Liang4e85e802018-06-28 16:37:18 -0400324
Robert Phillipsf4f80112020-07-13 16:13:31 -0400325 return direct;
Robert Phillipsa3457b82018-03-08 11:30:12 -0500326}
327#endif
328
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500329#ifdef SK_DIRECT3D
Robert Phillipsf4f80112020-07-13 16:13:31 -0400330/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400331#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
332
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500333sk_sp<GrContext> GrContext::MakeDirect3D(const GrD3DBackendContext& backendContext) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400334 return GrDirectContext::MakeDirect3D(backendContext);
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500335}
336
337sk_sp<GrContext> GrContext::MakeDirect3D(const GrD3DBackendContext& backendContext,
338 const GrContextOptions& options) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400339 return GrDirectContext::MakeDirect3D(backendContext, options);
340}
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500341
Robert Phillipsc7228c62020-07-14 12:57:39 -0400342#endif
343
Robert Phillipsf4f80112020-07-13 16:13:31 -0400344/*************************************************************************************************/
345sk_sp<GrDirectContext> GrDirectContext::MakeDirect3D(const GrD3DBackendContext& backendContext) {
346 GrContextOptions defaultOptions;
347 return MakeDirect3D(backendContext, defaultOptions);
348}
349
350sk_sp<GrDirectContext> GrDirectContext::MakeDirect3D(const GrD3DBackendContext& backendContext,
351 const GrContextOptions& options) {
352 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kDirect3D, options));
353
354 direct->fGpu = GrD3DGpu::Make(backendContext, options, direct.get());
355 if (!direct->init()) {
Jim Van Verthd2d4c5e2020-02-19 14:57:58 -0500356 return nullptr;
357 }
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500358
Robert Phillipsf4f80112020-07-13 16:13:31 -0400359 return direct;
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500360}
361#endif
362
Stephen White985741a2019-07-18 11:43:45 -0400363#ifdef SK_DAWN
Robert Phillipsf4f80112020-07-13 16:13:31 -0400364/*************************************************************************************************/
Robert Phillipsc7228c62020-07-14 12:57:39 -0400365#ifndef SK_DISABLE_LEGACY_CONTEXT_FACTORIES
366
Stephen Whitea521c962019-12-04 09:57:48 -0500367sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device) {
Robert Phillipsf4f80112020-07-13 16:13:31 -0400368 return GrDirectContext::MakeDawn(device);
369}
370
371sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) {
372 return GrDirectContext::MakeDawn(device, options);
373}
374
Robert Phillipsc7228c62020-07-14 12:57:39 -0400375#endif
376
Robert Phillipsf4f80112020-07-13 16:13:31 -0400377/*************************************************************************************************/
378sk_sp<GrDirectContext> GrDirectContext::MakeDawn(const wgpu::Device& device) {
Stephen White985741a2019-07-18 11:43:45 -0400379 GrContextOptions defaultOptions;
380 return MakeDawn(device, defaultOptions);
381}
382
Robert Phillipsf4f80112020-07-13 16:13:31 -0400383sk_sp<GrDirectContext> GrDirectContext::MakeDawn(const wgpu::Device& device,
384 const GrContextOptions& options) {
385 sk_sp<GrDirectContext> direct(new GrDirectContext(GrBackendApi::kDawn, options));
Stephen White985741a2019-07-18 11:43:45 -0400386
Robert Phillipsf4f80112020-07-13 16:13:31 -0400387 direct->fGpu = GrDawnGpu::Make(device, options, direct.get());
388 if (!direct->init()) {
Stephen White985741a2019-07-18 11:43:45 -0400389 return nullptr;
390 }
391
Robert Phillipsf4f80112020-07-13 16:13:31 -0400392 return direct;
Stephen White985741a2019-07-18 11:43:45 -0400393}
Robert Phillipsf4f80112020-07-13 16:13:31 -0400394
Stephen White985741a2019-07-18 11:43:45 -0400395#endif