Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / tools / sk_app / GraphiteMetalWindowContext.h
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
10 #include "include/core/SkRefCnt.h"
11 #include "include/ports/SkCFObject.h"
12
13 #include "tools/sk_app/WindowContext.h"
14
15 #import <Metal/Metal.h>
16 #import <QuartzCore/CAMetalLayer.h>
17
18 class SkSurface;
19
20 namespace sk_app {
21
22 class GraphiteMetalWindowContext : public WindowContext {
23 public:
24     sk_sp<SkSurface> getBackbufferSurface() override;
25
26     bool isValid() override { return fValid; }
27
28     void swapBuffers() override;
29
30     void setDisplayParams(const DisplayParams& params) override;
31
32     void activate(bool isActive) override;
33
34 protected:
35     GraphiteMetalWindowContext(const DisplayParams&);
36     // This should be called by subclass constructor. It is also called when window/display
37     // parameters change. This will in turn call onInitializeContext().
38     void initializeContext();
39     virtual bool onInitializeContext() = 0;
40
41     // This should be called by subclass destructor. It is also called when window/display
42     // parameters change prior to initializing a new Metal context. This will in turn call
43     // onDestroyContext().
44     void destroyContext();
45     virtual void onDestroyContext() = 0;
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 sk_app
55
56 #endif