• 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_BITMAP_H
17 #define SCENE_SRC_BITMAP_H
18 
19 #include <scene/ext/intf_ecs_object.h>
20 #include <scene/ext/intf_internal_scene.h>
21 #include <scene/ext/intf_render_resource.h>
22 #include <scene/interface/intf_bitmap.h>
23 #include <shared_mutex>
24 
25 #include <render/device/intf_gpu_resource_manager.h>
26 
27 #include <meta/ext/implementation_macros.h>
28 #include <meta/ext/object.h>
29 #include <meta/interface/intf_named.h>
30 #include <meta/interface/resource/intf_dynamic_resource.h>
31 
SCENE_BEGIN_NAMESPACE()32 SCENE_BEGIN_NAMESPACE()
33 
34 class Bitmap : public META_NS::IntroduceInterfaces<META_NS::MetaObject, IBitmap, IRenderTarget, IRenderResource,
35                    IEcsResource, META_NS::IDynamicResource, META_NS::INamed> {
36     META_OBJECT(Bitmap, ClassId::Bitmap, IntroduceInterfaces)
37 public:
38     META_BEGIN_STATIC_DATA()
39     META_STATIC_PROPERTY_DATA(META_NS::INamed, BASE_NS::string, Name)
40     META_STATIC_PROPERTY_DATA(SCENE_NS::IBitmap, BASE_NS::Math::UVec2, Size, BASE_NS::Math::UVec2(0, 0),
41         META_NS::DEFAULT_PROPERTY_FLAGS_NO_SER)
42     META_STATIC_EVENT_DATA(META_NS::IDynamicResource, META_NS::IOnChanged, OnResourceChanged)
43     META_END_STATIC_DATA()
44 
45     META_IMPLEMENT_PROPERTY(BASE_NS::string, Name)
46     META_IMPLEMENT_READONLY_PROPERTY(BASE_NS::Math::UVec2, Size)
47     META_IMPLEMENT_EVENT(META_NS::IOnChanged, OnResourceChanged)
48 
49     bool SetRenderHandle(const IInternalScene::Ptr& scene, RENDER_NS::RenderHandleReference handle,
50         CORE_NS::EntityReference ent) override;
51     RENDER_NS::RenderHandleReference GetRenderHandle() const override;
52     CORE_NS::Entity GetEntity() const override;
53 
54     void Refresh() override {}
55 
56     BASE_NS::string GetName() const override
57     {
58         return META_NS::GetValue(Name());
59     }
60 
61 private:
62     mutable std::shared_mutex mutex_;
63     RENDER_NS::RenderHandleReference handle_;
64     CORE_NS::EntityReference entity_;
65 };
66 
67 SCENE_END_NAMESPACE()
68 
69 #endif