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