return false;
}
- auto self = Self();
+ auto self = Self();
auto oldHighlightedActor = GetCurrentlyHighlightedActor();
if(self == oldHighlightedActor)
{
SetCurrentlyHighlightedActor(self);
- auto window = Dali::DevelWindow::Get(self);
+ auto window = Dali::DevelWindow::Get(self);
Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
windowImpl.EmitAccessibilityHighlightSignal(true);
SetCurrentlyHighlightedActor({});
- auto window = Dali::DevelWindow::Get(self);
+ auto window = Dali::DevelWindow::Get(self);
Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
windowImpl.EmitAccessibilityHighlightSignal(false);
if(mRoot)
{
- Dali::Window window = Dali::DevelWindow::Get(Self());
+ Dali::Window window = Dali::DevelWindow::Get(Self());
Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
attributes["resID"] = windowImpl.GetNativeResourceId();
}
using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::unique_ptr<AdaptorAccessible> >;
// Save RefObject from an Actor in Accessible::Get()
-AdaptorAccessiblesType gAdaptorAccessibles;
+AdaptorAccessiblesType& GetAdaptorAccessibles()
+{
+ static AdaptorAccessiblesType gAdaptorAccessibles;
+ return gAdaptorAccessibles;
+}
std::function<Accessible*(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> Accessible* {
return nullptr;
{
objectRegistry = registry;
objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) {
- gAdaptorAccessibles.erase(obj);
+ GetAdaptorAccessibles().erase(obj);
});
}
auto accessible = convertingFunctor(actor);
if(!accessible)
{
- auto pair = gAdaptorAccessibles.emplace(&actor.GetBaseObject(), nullptr);
+ auto pair = GetAdaptorAccessibles().emplace(&actor.GetBaseObject(), nullptr);
if(pair.second)
{
- bool isRoot = false;
- Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
+ bool isRoot = false;
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
if(scene)
{
isRoot = (actor == scene.GetRootLayer());
else
connectionState->connection = conn;
-
- if (!connectionState->connection)
+ if(!connectionState->connection)
{
DALI_LOG_ERROR("DBusClient connection is not ready\n");
return;
}
auto p = eldbus_connection_get(eldbusType);
- if (!p)
+ if(!p)
{
DALI_LOG_ERROR("cannot get dbus connection\n");
return NULL;
DBusWrapper::ConnectionWeakPtr connection;
};
- static std::unordered_map<const Eldbus_Service_Interface*, std::unique_ptr<Implementation>> globalEntries;
- static std::mutex globalEntriesMutex;
-
-#undef EINA_FALSE
-#undef EINA_TRUE
-#define EINA_FALSE static_cast<Eina_Bool>(0)
-#define EINA_TRUE static_cast<Eina_Bool>(1)
-
- static Eina_Bool property_get_callback(const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter, const Eldbus_Message* message, Eldbus_Message** error)
+ struct GlobalEntries
{
- Implementation* impl = nullptr;
+ static GlobalEntries& Get()
+ {
+ static GlobalEntries instance;
+ return instance;
+ }
+
+ Implementation* Find(const Eldbus_Service_Interface* iface)
{
+ Implementation* impl = nullptr;
std::lock_guard<std::mutex> lock(globalEntriesMutex);
auto it = globalEntries.find(iface);
if(it != globalEntries.end())
{
impl = it->second.get();
}
+ return impl;
}
+
+ void Add(const Eldbus_Service_Interface* iface, std::unique_ptr<Implementation> impl)
+ {
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ globalEntries[iface] = std::move(impl);
+ }
+
+ void Erase(const Eldbus_Service_Interface* iface)
+ {
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ globalEntries.erase(iface);
+ }
+
+ private:
+ std::unordered_map<const Eldbus_Service_Interface*, std::unique_ptr<Implementation>> globalEntries;
+ std::mutex globalEntriesMutex;
+ };
+
+#undef EINA_FALSE
+#undef EINA_TRUE
+#define EINA_FALSE static_cast<Eina_Bool>(0)
+#define EINA_TRUE static_cast<Eina_Bool>(1)
+
+ static Eina_Bool property_get_callback(const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter, const Eldbus_Message* message, Eldbus_Message** error)
+ {
+ Implementation* impl = GlobalEntries::Get().Find(iface);
if(!impl)
{
return EINA_FALSE;
static Eldbus_Message* property_set_callback(const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter, const Eldbus_Message* message)
{
- Implementation* impl = nullptr;
- {
- std::lock_guard<std::mutex> lock(globalEntriesMutex);
- auto it = globalEntries.find(iface);
- if(it != globalEntries.end())
- {
- impl = it->second.get();
- }
- }
+ Implementation* impl = GlobalEntries::Get().Find(iface);
if(!impl)
{
auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown interface");
static Eldbus_Message* method_callback(const Eldbus_Service_Interface* iface, const Eldbus_Message* message)
{
- Implementation* impl = nullptr;
- {
- std::lock_guard<std::mutex> lock(globalEntriesMutex);
- auto it = globalEntries.find(iface);
- if(it != globalEntries.end())
- impl = it->second.get();
- }
+ Implementation* impl = GlobalEntries::Get().Find(iface);
if(!impl)
{
auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown interface");
std::move(signalsMap),
connection});
- {
- std::lock_guard<std::mutex> lock(globalEntriesMutex);
- auto v = fallback ? eldbus_service_interface_fallback_register(get(connection), pathName.c_str(), &impl->dsc) : eldbus_service_interface_register(get(connection), pathName.c_str(), &impl->dsc);
- assert(v);
- globalEntries[v] = std::move(impl);
- DBUS_DEBUG("registering interface %p (%d)", v, fallback ? 1 : 0);
- destructors.push_back([=]() {
- DBUS_DEBUG("unregistering interface %p", v);
- {
- std::lock_guard<std::mutex> lock(globalEntriesMutex);
- globalEntries.erase(v);
- }
- eldbus_service_interface_unregister(v);
- });
- }
+ auto v = fallback ? eldbus_service_interface_fallback_register(get(connection), pathName.c_str(), &impl->dsc) : eldbus_service_interface_register(get(connection), pathName.c_str(), &impl->dsc);
+ DALI_ASSERT_ALWAYS(v && "Eldbus register failed!");
+ GlobalEntries::Get().Add(v, std::move(impl));
+ DBUS_DEBUG("registering interface %p (%d)", v, fallback ? 1 : 0);
+ destructors.push_back([=]() {
+ DBUS_DEBUG("unregistering interface %p", v);
+ GlobalEntries::Get().Erase(v);
+ eldbus_service_interface_unregister(v);
+ });
}
static void listenerEventChangedCallback(void* data, Eldbus_Proxy* proxy EINA_UNUSED, void* event)
}
};
-std::unordered_map<const Eldbus_Service_Interface*, std::unique_ptr<DefaultDBusWrapper::Implementation>> DefaultDBusWrapper::globalEntries;
-std::mutex DefaultDBusWrapper::globalEntriesMutex;
-
DBusWrapper* DBusWrapper::Installed()
{
if(!InstalledWrapper)
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using PipelineStateCompateFunctionType = bool(const Graphics::PipelineCreateInfo*,
const Graphics::PipelineCreateInfo*);
-static std::vector<PipelineStateCompateFunctionType*> STATE_COMPARE_FUNC_TABLE{};
+static std::vector<PipelineStateCompateFunctionType*>& GetStateCompareFuncTable()
+{
+ static std::vector<PipelineStateCompateFunctionType*> stateCompareFuncTable{};
+ return stateCompareFuncTable;
+}
/**
* @brief Initialises compare function lookup table
*/
void InitialiseStateCompareLookupTable()
{
- STATE_COMPARE_FUNC_TABLE = {
- [](const auto* lhs, const auto* rhs) -> bool // colorBlendState
- {
- const auto& lcb = *lhs->colorBlendState;
- const auto& rcb = *rhs->colorBlendState;
- return lcb.logicOpEnable == rcb.logicOpEnable &&
- lcb.logicOp == rcb.logicOp &&
- cmpf(lcb.blendConstants[0], rcb.blendConstants[0]) &&
- cmpf(lcb.blendConstants[1], rcb.blendConstants[1]) &&
- cmpf(lcb.blendConstants[2], rcb.blendConstants[2]) &&
- cmpf(lcb.blendConstants[3], rcb.blendConstants[3]) &&
- lcb.blendEnable == rcb.blendEnable &&
- lcb.srcColorBlendFactor == rcb.srcColorBlendFactor &&
- lcb.dstColorBlendFactor == rcb.dstColorBlendFactor &&
- lcb.colorBlendOp == rcb.colorBlendOp &&
- lcb.srcAlphaBlendFactor == rcb.srcAlphaBlendFactor &&
- lcb.dstAlphaBlendFactor == rcb.dstAlphaBlendFactor &&
- lcb.alphaBlendOp == rcb.alphaBlendOp &&
- lcb.colorComponentWriteBits == rcb.colorComponentWriteBits;
- },
- [](const auto* lhs, const auto* rhs) -> bool // viewport state
- {
- const auto& lvp = *lhs->viewportState;
- const auto& rvp = *rhs->viewportState;
- return lvp.viewport == rvp.viewport &&
- lvp.scissor == rvp.scissor &&
- lvp.scissorTestEnable == rvp.scissorTestEnable;
- },
- [](const auto* lhs, const auto* rhs) -> bool // basePipeline
- {
- return lhs->basePipeline == rhs->basePipeline;
- },
- [](const auto* lhs, const auto* rhs) -> bool // depthStencilState
- {
- const auto& lds = *lhs->depthStencilState;
- const auto& rds = *rhs->depthStencilState;
- return lds.depthTestEnable == rds.depthTestEnable &&
- lds.depthWriteEnable == rds.depthWriteEnable &&
- lds.depthCompareOp == rds.depthCompareOp &&
- lds.stencilTestEnable == rds.stencilTestEnable &&
- lds.front == rds.front &&
- lds.back == rds.back;
- },
- [](const auto* lhs, const auto* rhs) -> bool // rasterizationState
- {
- const auto& lrs = *lhs->rasterizationState;
- const auto& rrs = *rhs->rasterizationState;
- return lrs.cullMode == rrs.cullMode &&
- lrs.polygonMode == rrs.polygonMode &&
- lrs.frontFace == rrs.frontFace;
- },
- [](const auto* lhs, const auto* rhs) -> bool // vertexInputState
- {
- const auto& lvi = *lhs->vertexInputState;
- const auto& rvi = *rhs->vertexInputState;
- return lvi.bufferBindings.size() == rvi.bufferBindings.size() &&
- lvi.attributes.size() == rvi.attributes.size() &&
- std::equal(lvi.bufferBindings.begin(), lvi.bufferBindings.end(), rvi.bufferBindings.begin(), [](const auto& lhs, const auto& rhs) {
- return operator==(lhs, rhs);
- }) &&
- std::equal(lvi.attributes.begin(), lvi.attributes.end(), rvi.attributes.begin(), [](const auto& lhs, const auto& rhs) {
- return operator==(lhs, rhs);
- });
- },
- [](const auto* lhs, const auto* rhs) -> bool // inputAssemblyState
- {
- const auto& lia = *lhs->inputAssemblyState;
- const auto& ria = *rhs->inputAssemblyState;
- return lia.topology == ria.topology &&
- lia.primitiveRestartEnable == ria.primitiveRestartEnable;
- },
- };
+ GetStateCompareFuncTable().clear();
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // colorBlendState
+ {
+ const auto& lcb = *lhs->colorBlendState;
+ const auto& rcb = *rhs->colorBlendState;
+ return lcb.logicOpEnable == rcb.logicOpEnable &&
+ lcb.logicOp == rcb.logicOp &&
+ cmpf(lcb.blendConstants[0], rcb.blendConstants[0]) &&
+ cmpf(lcb.blendConstants[1], rcb.blendConstants[1]) &&
+ cmpf(lcb.blendConstants[2], rcb.blendConstants[2]) &&
+ cmpf(lcb.blendConstants[3], rcb.blendConstants[3]) &&
+ lcb.blendEnable == rcb.blendEnable &&
+ lcb.srcColorBlendFactor == rcb.srcColorBlendFactor &&
+ lcb.dstColorBlendFactor == rcb.dstColorBlendFactor &&
+ lcb.colorBlendOp == rcb.colorBlendOp &&
+ lcb.srcAlphaBlendFactor == rcb.srcAlphaBlendFactor &&
+ lcb.dstAlphaBlendFactor == rcb.dstAlphaBlendFactor &&
+ lcb.alphaBlendOp == rcb.alphaBlendOp &&
+ lcb.colorComponentWriteBits == rcb.colorComponentWriteBits;
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // viewport state
+ {
+ const auto& lvp = *lhs->viewportState;
+ const auto& rvp = *rhs->viewportState;
+ return lvp.viewport == rvp.viewport &&
+ lvp.scissor == rvp.scissor &&
+ lvp.scissorTestEnable == rvp.scissorTestEnable;
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // basePipeline
+ {
+ return lhs->basePipeline == rhs->basePipeline;
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // depthStencilState
+ {
+ const auto& lds = *lhs->depthStencilState;
+ const auto& rds = *rhs->depthStencilState;
+ return lds.depthTestEnable == rds.depthTestEnable &&
+ lds.depthWriteEnable == rds.depthWriteEnable &&
+ lds.depthCompareOp == rds.depthCompareOp &&
+ lds.stencilTestEnable == rds.stencilTestEnable &&
+ lds.front == rds.front &&
+ lds.back == rds.back;
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // rasterizationState
+ {
+ const auto& lrs = *lhs->rasterizationState;
+ const auto& rrs = *rhs->rasterizationState;
+ return lrs.cullMode == rrs.cullMode &&
+ lrs.polygonMode == rrs.polygonMode &&
+ lrs.frontFace == rrs.frontFace;
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // vertexInputState
+ {
+ const auto& lvi = *lhs->vertexInputState;
+ const auto& rvi = *rhs->vertexInputState;
+ return lvi.bufferBindings.size() == rvi.bufferBindings.size() &&
+ lvi.attributes.size() == rvi.attributes.size() &&
+ std::equal(lvi.bufferBindings.begin(), lvi.bufferBindings.end(), rvi.bufferBindings.begin(), [](const auto& lhs, const auto& rhs) {
+ return operator==(lhs, rhs);
+ }) &&
+ std::equal(lvi.attributes.begin(), lvi.attributes.end(), rvi.attributes.begin(), [](const auto& lhs, const auto& rhs) {
+ return operator==(lhs, rhs);
+ });
+ });
+ GetStateCompareFuncTable().push_back([](const auto* lhs, const auto* rhs) -> bool // inputAssemblyState
+ {
+ const auto& lia = *lhs->inputAssemblyState;
+ const auto& ria = *rhs->inputAssemblyState;
+ return lia.topology == ria.topology &&
+ lia.primitiveRestartEnable == ria.primitiveRestartEnable;
+ });
}
/**
// Test only set states
if((entry.stateBitmask & (1 << i)))
{
- if(!STATE_COMPARE_FUNC_TABLE[i](&info, &cacheInfo))
+ if(!(GetStateCompareFuncTable()[i](&info, &cacheInfo)))
{
break;
}
// killing the program (if program isn't in use anymore)
}
-} // namespace Dali::Graphics::GLES
\ No newline at end of file
+} // namespace Dali::Graphics::GLES