Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / include / gpu / graphite / Context.h
1 /*
2  * Copyright 2021 Google LLC
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
8 #ifndef skgpu_graphite_Context_DEFINED
9 #define skgpu_graphite_Context_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkShader.h"
13 #include "include/gpu/graphite/GraphiteTypes.h"
14
15 class SkBlenderID;
16 class SkCombinationBuilder;
17 class SkRuntimeEffect;
18
19 namespace skgpu::graphite {
20
21 class BackendTexture;
22 class CommandBuffer;
23 class Context;
24 class ContextPriv;
25 class GlobalCache;
26 class Gpu;
27 struct MtlBackendContext;
28 class Recorder;
29 class Recording;
30 class TextureInfo;
31
32 class Context final {
33 public:
34     Context(const Context&) = delete;
35     Context(Context&&) = delete;
36     Context& operator=(const Context&) = delete;
37     Context& operator=(Context&&) = delete;
38
39     ~Context();
40
41 #ifdef SK_METAL
42     static std::unique_ptr<Context> MakeMetal(const skgpu::graphite::MtlBackendContext&);
43 #endif
44
45     BackendApi backend() const { return fBackend; }
46
47     std::unique_ptr<Recorder> makeRecorder();
48
49     void insertRecording(const InsertRecordingInfo&);
50     void submit(SyncToCpu = SyncToCpu::kNo);
51
52     /**
53      * Checks whether any asynchronous work is complete and if so calls related callbacks.
54      */
55     void checkAsyncWorkCompletion();
56
57     // TODO: add "SkShaderID addUserDefinedShader(sk_sp<SkRuntimeEffect>)" here
58     // TODO: add "SkColorFilterID addUserDefinedColorFilter(sk_sp<SkRuntimeEffect>)" here
59     SkBlenderID addUserDefinedBlender(sk_sp<SkRuntimeEffect>);
60
61     void preCompile(const SkCombinationBuilder&);
62
63     /**
64      * Creates a new backend gpu texture matching the dimensinos and TextureInfo. If an invalid
65      * TextureInfo or a TextureInfo Skia can't support is passed in, this will return an invalid
66      * BackendTexture. Thus the client should check isValid on the returned BackendTexture to know
67      * if it succeeded or not.
68      *
69      * If this does return a valid BackendTexture, the caller is required to use
70      * Context::deleteBackendTexture to delete that texture.
71      */
72     BackendTexture createBackendTexture(SkISize dimensions, const TextureInfo&);
73
74     /**
75      * Called to delete the passed in BackendTexture. This should only be called if the
76      * BackendTexture was created by calling Context::createBackendTexture. If the BackendTexture is
77      * not valid or does not match the BackendApi of the Context then nothing happens.
78      *
79      * Otherwise this will delete/release the backend object that is wrapped in the BackendTexture.
80      * The BackendTexture will be reset to an invalid state and should not be used again.
81      */
82     void deleteBackendTexture(BackendTexture&);
83
84     // Provides access to functions that aren't part of the public API.
85     ContextPriv priv();
86     const ContextPriv priv() const;  // NOLINT(readability-const-return-type)
87
88 protected:
89     Context(sk_sp<Gpu>, BackendApi);
90
91 private:
92     friend class ContextPriv;
93
94     sk_sp<CommandBuffer> fCurrentCommandBuffer;
95
96     sk_sp<Gpu> fGpu;
97     sk_sp<GlobalCache> fGlobalCache;
98     BackendApi fBackend;
99 };
100
101 } // namespace skgpu::graphite
102
103 #endif // skgpu_graphite_Context_DEFINED