Flutter Engine
The Flutter Engine
GraphiteMetalWindowContext.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 GraphiteMetalWindowContext_DEFINED
8#define GraphiteMetalWindowContext_DEFINED
9
12
14
15#import <Metal/Metal.h>
16#import <QuartzCore/CAMetalLayer.h>
17
18class SkSurface;
19
20namespace skwindow::internal {
21
23public:
25
26 bool isValid() override { return fValid; }
27
28 void setDisplayParams(const DisplayParams& params) override;
29
30 void activate(bool isActive) override;
31
32protected:
34 // This should be called by subclass constructor. It is also called when window/display
35 // parameters change. This will in turn call onInitializeContext().
36 void initializeContext();
37 virtual bool onInitializeContext() = 0;
38
39 // This should be called by subclass destructor. It is also called when window/display
40 // parameters change prior to initializing a new Metal context. This will in turn call
41 // onDestroyContext().
42 void destroyContext();
43 virtual void onDestroyContext() = 0;
44
45 void onSwapBuffers() override;
46
47 bool fValid;
48 sk_cfp<id<MTLDevice>> fDevice;
49 sk_cfp<id<MTLCommandQueue>> fQueue;
50 CAMetalLayer* fMetalLayer;
51 CFTypeRef fDrawableHandle;
52};
53
54} // namespace skwindow::internal
55
56#endif
void setDisplayParams(const DisplayParams &params) override
const EmbeddedViewParams * params