• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SCENE_SRC_RENDER_RESOURCE_H
17 #define SCENE_SRC_RENDER_RESOURCE_H
18 
19 #include <scene/ext/intf_render_resource.h>
20 #include <scene/interface/intf_render_context.h>
21 #include <shared_mutex>
22 
23 #include <meta/ext/implementation_macros.h>
24 #include <meta/ext/object.h>
25 #include <meta/ext/resource/resource.h>
26 #include <meta/interface/intf_named.h>
27 #include <meta/interface/resource/intf_dynamic_resource.h>
28 
SCENE_BEGIN_NAMESPACE()29 SCENE_BEGIN_NAMESPACE()
30 
31 class RenderResource : public META_NS::IntroduceInterfaces<META_NS::MetaObject, META_NS::Resource, IRenderResource,
32                            META_NS::IDynamicResource> {
33     META_OBJECT_NO_CLASSINFO(RenderResource, IntroduceInterfaces)
34 public:
35     META_BEGIN_STATIC_DATA()
36     META_STATIC_EVENT_DATA(META_NS::IDynamicResource, META_NS::IOnChanged, OnResourceChanged)
37     META_END_STATIC_DATA()
38 
39     META_IMPLEMENT_EVENT(META_NS::IOnChanged, OnResourceChanged)
40 
41     bool Build(const META_NS::IMetadata::Ptr&) override;
42 
43     RENDER_NS::RenderHandleReference GetRenderHandle() const override;
44 
45 protected:
46     mutable std::shared_mutex mutex_;
47     IRenderContext::WeakPtr context_;
48     RENDER_NS::RenderHandleReference handle_;
49 };
50 
51 SCENE_END_NAMESPACE()
52 
53 #endif