/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// clang-format off
#include
#include
// clang-format on
#include
#include
#include
#include
#include
#include
#include <3d/implementation_uids.h>
#include
#include
#include
#include
#include
#include "ecs_animation.h"
#include "intf_node_private.h"
namespace {
static CORE_NS::IPluginRegister* gPluginRegistry { nullptr };
} // namespace
CORE_BEGIN_NAMESPACE()
IPluginRegister& GetPluginRegister()
{
return *gPluginRegistry;
}
CORE_END_NAMESPACE()
using namespace CORE_NS;
SCENE_BEGIN_NAMESPACE()
template
class PendingRequestImpl : public META_NS::ObjectFwd, Info, META_NS::ClassId::Object,
SCENE_NS::IPendingRequest, SCENE_NS::IPendingRequestData> {
META_IMPLEMENT_EVENT(META_NS::IOnChanged, OnReady)
void Add(const T& data) override
{
data_.push_back(data);
}
void MarkReady() override
{
applicationData_.clear();
META_NS::Invoke(OnReady());
}
const BASE_NS::vector& GetResults() const override
{
return data_;
}
BASE_NS::vector& MutableData() override
{
return data_;
}
BASE_NS::vector& MetaData() override
{
return applicationData_;
}
BASE_NS::vector data_;
BASE_NS::vector applicationData_;
};
void RegisterNodes();
void UnregisterNodes();
void RegisterSceneImpl();
void UnregisterSceneImpl();
void RegisterEcsObject();
void UnregisterEcsObject();
void RegisterNodeHierarchyController();
void UnregisterNodeHierarchyController();
void RegisterEngineAccess();
void UnregisterEngineAccess();
SCENE_END_NAMESPACE()
class SceneBitmap : public META_NS::ObjectFwd {
protected:
META_IMPLEMENT_INTERFACE_PROPERTY(META_NS::INamed, BASE_NS::string, Name)
META_IMPLEMENT_INTERFACE_PROPERTY(SCENE_NS::IBitmap, BASE_NS::string, Uri, {})
META_IMPLEMENT_INTERFACE_READONLY_PROPERTY(SCENE_NS::IBitmap, BASE_NS::Math::UVec2, Size,
BASE_NS::Math::UVec2(0, 0), META_NS::DEFAULT_PROPERTY_FLAGS_NO_SER)
META_IMPLEMENT_INTERFACE_EVENT(SCENE_NS::IBitmap, META_NS::IOnChanged, ResourceChanged)
META_IMPLEMENT_INTERFACE_READONLY_PROPERTY(SCENE_NS::IBitmap, SCENE_NS::IBitmap::BitmapStatus, Status,
SCENE_NS::IBitmap::BitmapStatus::NOT_INITIALIZED, META_NS::DEFAULT_PROPERTY_FLAGS_NO_SER)
bool Build(const IMetadata::Ptr& data) override
{
return true;
}
void SetRenderHandle(RENDER_NS::RenderHandleReference handle, const BASE_NS::Math::UVec2 size) override
{
auto cs = META_ACCESS_PROPERTY_VALUE(Size);
if (size != cs) {
META_ACCESS_PROPERTY(Size)->SetValue(size);
}
handle_ = handle;
if (RENDER_NS::RenderHandleUtil::IsValid(handle.GetHandle())) {
META_ACCESS_PROPERTY(Status)->SetValue(SCENE_NS::IBitmap::BitmapStatus::COMPLETED);
} else {
META_ACCESS_PROPERTY(Status)->SetValue(SCENE_NS::IBitmap::BitmapStatus::NOT_INITIALIZED);
}
META_ACCESS_EVENT(ResourceChanged)->Invoke();
}
RENDER_NS::RenderHandleReference GetRenderHandle() const override
{
return handle_;
}
RENDER_NS::RenderHandleReference handle_;
};
PluginToken RegisterInterfaces(IPluginRegister& pluginRegistry)
{
// Initializing dynamic plugin.
// Pluginregistry access via the provided registry instance which is saved here.
gPluginRegistry = &pluginRegistry;
auto& objreg = META_NS::GetObjectRegistry();
objreg.RegisterObjectType();
SCENE_NS::RegisterEcsObject();
SCENE_NS::RegisterNodes();
SCENE_NS::RegisterSceneImpl();
SCENE_NS::RegisterNodeHierarchyController();
SCENE_NS::RegisterEngineAccess();
SCENE_NS::RegisterEcsAnimationObjectType();
META_NS::GetObjectRegistry()
.RegisterObjectType<
SCENE_NS::PendingRequestImpl>();
META_NS::GetObjectRegistry()
.RegisterObjectType<
SCENE_NS::PendingRequestImpl>();
META_NS::GetObjectRegistry()
.RegisterObjectType>();
return {};
}
void UnregisterInterfaces(PluginToken)
{
/* META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
META_NS::UnRegisterInterfacePropertyType();
*/
SCENE_NS::UnregisterEcsObject();
SCENE_NS::UnregisterNodes();
SCENE_NS::UnregisterSceneImpl();
SCENE_NS::UnregisterNodeHierarchyController();
SCENE_NS::UnregisterEngineAccess();
SCENE_NS::UnregisterEcsAnimationObjectType();
META_NS::GetObjectRegistry()
.UnregisterObjectType<
SCENE_NS::PendingRequestImpl>();
META_NS::GetObjectRegistry()
.UnregisterObjectType<
SCENE_NS::PendingRequestImpl>();
META_NS::GetObjectRegistry()
.UnregisterObjectType<
SCENE_NS::PendingRequestImpl>();
}
const char* VersionString()
{
return "1.0";
}
const BASE_NS::Uid plugin_deps[] { RENDER_NS::UID_RENDER_PLUGIN, CORE3D_NS::UID_3D_PLUGIN,
META_NS::META_OBJECT_PLUGIN_UID };
extern "C" {
#if _MSC_VER
_declspec(dllexport)
#else
__attribute__((visibility("default")))
#endif
CORE_NS::IPlugin gPluginData { IPlugin::UID, "Scene",
/** Version information of the plugin. */
Version { SCENE_NS::UID_SCENE_PLUGIN, VersionString }, RegisterInterfaces, UnregisterInterfaces, plugin_deps };
}