Flutter Engine
The Flutter Engine
GraphiteDawnWindowContext.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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#ifndef GraphiteDawnWindowContext_DEFINED
8#define GraphiteDawnWindowContext_DEFINED
9
11#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE
12#include "dawn/native/DawnNative.h"
13
14namespace skwindow::internal {
15
17public:
18 GraphiteDawnWindowContext(const DisplayParams&, wgpu::TextureFormat swapChainFormat);
21 bool isValid() override { return SkToBool(fDevice.Get()); }
22 void setDisplayParams(const DisplayParams& params) override;
23
24protected:
25 bool isGpuContext() override { return true; }
26 void initializeContext(int width, int height);
28 wgpu::SwapChain createSwapChain();
29 void destroyContext();
30
31 virtual bool onInitializeContext() = 0;
32 virtual void onDestroyContext() = 0;
34
35 void onSwapBuffers() override;
36
37 wgpu::TextureFormat fSwapChainFormat;
38 std::unique_ptr<dawn::native::Instance> fInstance;
39 wgpu::Device fDevice;
40 wgpu::Queue fQueue;
41 wgpu::Surface fSurface;
42 wgpu::SwapChain fSwapChain;
43};
44
45} // namespace skwindow::internal
46
47#endif
GrSurfaceOrigin
Definition: GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
GLenum type
GraphiteDawnWindowContext(const DisplayParams &, wgpu::TextureFormat swapChainFormat)
void setDisplayParams(const DisplayParams &params) override
std::unique_ptr< dawn::native::Instance > fInstance
const EmbeddedViewParams * params
DlSurfaceProvider::BackendType BackendType
Definition: dl_benchmarks.h:33