Since member value of EventThreadService can call API at worker thread.
It might make some resource leak.
For example, we can call animation.Clear() at worker thread.
If then, only event thread side informations removed, and nothing changed
for update thread.
To avoid this kind of issue
- Let we define interface class s.t. Get EventThreadService and assert if we access here at workerthread.
- Change every local value usage to using this API.
During test, let we just assert it always.
After several weeks later, it would be change as debug.
Change-Id: I956445c67c40956af2e4219417f6638072ae29e4
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
END_TEST;
}
+
+int UtcDaliAnimationPlayWorkerThreadN(void)
+{
+ TestApplication application;
+ tet_infoline("UtcDaliAnimationPlayWorkerThreadN Test");
+
+ try
+ {
+ class TestThread : public Thread
+ {
+ public:
+ virtual void Run()
+ {
+ tet_printf("Run TestThread\n");
+ for(auto& functor : {&Animation::Play, &Animation::Pause, &Animation::Stop, &Animation::Clear})
+ {
+ try
+ {
+ // API call at worker thread.
+ (mAnimation.*functor)();
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT(e);
+ DALI_TEST_ASSERT(e, "Core is not running! Might call this API from worker thread.", TEST_LOCATION);
+ }
+ }
+ }
+
+ Dali::Animation mAnimation;
+ };
+ TestThread thread;
+
+ Dali::Animation animation = Dali::Animation::New(0);
+ Dali::Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(100.0f, 10.0f, 1.0f), AlphaFunction::LINEAR);
+ thread.mAnimation = std::move(animation);
+ animation.Reset();
+
+ thread.Start();
+
+ thread.Join();
+ }
+ catch(...)
+ {
+ }
+
+ // Always success
+ DALI_TEST_CHECK(true);
+
+ END_TEST;
+}
namespace Dali::Internal
{
RendererContainer::RendererContainer(EventThreadServices& eventThreadServices)
-: mEventThreadServices(eventThreadServices)
+: EventThreadServicesHolder(eventThreadServices)
{
}
}
RendererPtr rendererPtr = RendererPtr(&renderer);
mRenderers.push_back(rendererPtr);
- AttachRendererMessage(mEventThreadServices.GetUpdateManager(), node, renderer.GetRendererSceneObject());
+ AttachRendererMessage(GetEventThreadServices().GetUpdateManager(), node, renderer.GetRendererSceneObject());
return index;
}
if((*iter).Get() == &renderer)
{
mRenderers.erase(iter);
- DetachRendererMessage(mEventThreadServices, node, renderer.GetRendererSceneObject());
+ DetachRendererMessage(GetEventThreadServices(), node, renderer.GetRendererSceneObject());
break;
}
}
if(index < mRenderers.size())
{
RendererPtr renderer = mRenderers[index];
- DetachRendererMessage(mEventThreadServices, node, renderer->GetRendererSceneObject());
+ DetachRendererMessage(GetEventThreadServices(), node, renderer->GetRendererSceneObject());
mRenderers.erase(mRenderers.begin() + index);
}
}
{
for(auto&& renderer : mRenderers)
{
- DetachRendererMessage(mEventThreadServices, node, renderer->GetRendererSceneObject());
+ DetachRendererMessage(GetEventThreadServices(), node, renderer->GetRendererSceneObject());
}
mRenderers.clear();
}
#define DALI_INTERNAL_ACTORS_ACTOR_RENDERER_CONTAINER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
*/
#include <dali/devel-api/rendering/renderer-devel.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/public-api/common/vector-wrapper.h>
* Class to contain an actor's renderers.
* Enables actor to set the blending for all renderers at once.
*/
-class RendererContainer
+class RendererContainer : public EventThreadServicesHolder
{
public:
/**
void SetBlending(DevelBlendEquation::Type blendEquation);
private:
- EventThreadServices& mEventThreadServices; ///< The event thread services (for sending messages)
- std::vector<RendererPtr> mRenderers; ///< The contained renderers
+ std::vector<RendererPtr> mRenderers; ///< The contained renderers
};
} // namespace Dali::Internal
}
Animation::Animation(EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha)
-: mEventThreadServices(eventThreadServices),
+: EventThreadServicesHolder(eventThreadServices),
mPlaylist(playlist),
mDefaultAlpha(defaultAlpha),
mDurationSeconds(durationSeconds),
mAnimationId = mAnimation->GetNotifyId();
OwnerPointer<SceneGraph::Animation> transferOwnership(const_cast<SceneGraph::Animation*>(mAnimation));
- AddAnimationMessage(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ AddAnimationMessage(GetEventThreadServices().GetUpdateManager(), transferOwnership);
// Setup mapping infomations between scenegraph animation
mPlaylist.MapNotifier(mAnimation, *this);
mPlaylist.UnmapNotifier(mAnimation);
// Remove animation using a message to the update manager
- RemoveAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
+ RemoveAnimationMessage(GetEventThreadServices().GetUpdateManager(), *mAnimation);
mAnimation = nullptr;
// Reset id
mDurationSeconds = seconds;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetDurationMessage(mEventThreadServices, *mAnimation, seconds);
+ SetDurationMessage(GetEventThreadServices(), *mAnimation, seconds);
}
void Animation::SetProgressNotification(float progress)
mLoopCount = count;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetLoopingMessage(mEventThreadServices, *mAnimation, mLoopCount);
+ SetLoopingMessage(GetEventThreadServices(), *mAnimation, mLoopCount);
}
int32_t Animation::GetLoopCount()
mEndAction = action;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetEndActionMessage(mEventThreadServices, *mAnimation, action);
+ SetEndActionMessage(GetEventThreadServices(), *mAnimation, action);
}
Dali::Animation::EndAction Animation::GetEndAction() const
mDisconnectAction = action;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetDisconnectActionMessage(mEventThreadServices, *mAnimation, action);
+ SetDisconnectActionMessage(GetEventThreadServices(), *mAnimation, action);
}
Dali::Animation::EndAction Animation::GetDisconnectAction() const
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a Play message
- PlayAnimationMessage(mEventThreadServices, *mAnimation);
+ PlayAnimationMessage(GetEventThreadServices(), *mAnimation);
}
void Animation::PlayFrom(float progress)
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a Play message
- PlayAnimationFromMessage(mEventThreadServices, *mAnimation, progress);
+ PlayAnimationFromMessage(GetEventThreadServices(), *mAnimation, progress);
}
}
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a message to set the value
- PlayAfterMessage(mEventThreadServices, *mAnimation, delaySeconds);
+ PlayAfterMessage(GetEventThreadServices(), *mAnimation, delaySeconds);
}
void Animation::Pause()
if(InternalStateConverter(mState, Dali::Animation::PAUSED))
{
// mAnimation is being used in a separate thread; queue a Pause message
- PauseAnimationMessage(mEventThreadServices, *mAnimation);
+ PauseAnimationMessage(GetEventThreadServices(), *mAnimation);
// Notify the objects with the _paused_, i.e. current values
NotifyObjects(Notify::FORCE_CURRENT_VALUE);
if(InternalStateConverter(mState, Dali::Animation::STOPPED))
{
// mAnimation is being used in a separate thread; queue a Stop message
- StopAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
+ StopAnimationMessage(GetEventThreadServices().GetUpdateManager(), *mAnimation);
// Only notify the objects with the _stopped_, i.e. current values if the end action is set to BAKE
if(mEndAction == EndAction::BAKE)
mConnectorTargetValuesSortRequired = false;
// mAnimation is being used in a separate thread; queue a Clear message
- ClearAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
+ ClearAnimationMessage(GetEventThreadServices().GetUpdateManager(), *mAnimation);
// Reset the notification count and relative values, since the new scene-object has never been played
mNotificationCount = 0;
if(mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y)
{
// mAnimation is being used in a separate thread; queue a message to set the current progress
- SetCurrentProgressMessage(mEventThreadServices, *mAnimation, progress);
+ SetCurrentProgressMessage(GetEventThreadServices(), *mAnimation, progress);
}
}
if(mAnimation)
{
mSpeedFactor = factor;
- SetSpeedFactorMessage(mEventThreadServices, *mAnimation, factor);
+ SetSpeedFactorMessage(GetEventThreadServices(), *mAnimation, factor);
}
}
mPlayRange = orderedRange;
// mAnimation is being used in a separate thread; queue a message to set play range
- SetPlayRangeMessage(mEventThreadServices, *mAnimation, orderedRange);
+ SetPlayRangeMessage(GetEventThreadServices(), *mAnimation, orderedRange);
}
}
if(blendPoint >= 0.0f && blendPoint <= 1.0f)
{
mBlendPoint = blendPoint;
- SetBlendPointMessage(mEventThreadServices, *mAnimation, mBlendPoint);
+ SetBlendPointMessage(GetEventThreadServices(), *mAnimation, mBlendPoint);
}
else
{
mAutoReverseEnabled = (loopingMode == Dali::Animation::LoopingMode::AUTO_REVERSE);
// mAnimation is being used in a separate thread; queue a message to set play range
- SetLoopingModeMessage(mEventThreadServices, *mAnimation, mAutoReverseEnabled);
+ SetLoopingModeMessage(GetEventThreadServices(), *mAnimation, mAutoReverseEnabled);
}
Dali::Animation::LoopingMode Animation::GetLoopingMode() const
if(mProgressReachedMarker > 0.0f)
{
float progressMarkerSeconds = mDurationSeconds * mProgressReachedMarker;
- SetProgressNotificationMessage(mEventThreadServices, *mAnimation, progressMarkerSeconds);
+ SetProgressNotificationMessage(GetEventThreadServices(), *mAnimation, progressMarkerSeconds);
}
}
// INTERNAL INCLUDES
#include <dali/devel-api/animation/animation-devel.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/animation/key-frames.h>
* The UpdateManager owns the Animation object, but the lifetime of the animation is
* indirectly controlled by the Animation.
*/
-class Animation : public BaseObject
+class Animation : public BaseObject, public EventThreadServicesHolder
{
public:
enum Type : uint8_t
* Retrieve the event thread services object
* @return The interface for sending messages to the scene graph
*/
- EventThreadServices& GetEventThreadServices()
+ EventThreadServices& GetAnimationEventThreadServices()
{
- return mEventThreadServices;
+ return GetEventThreadServices();
}
protected:
const SceneGraph::Animation* mAnimation{nullptr};
- EventThreadServices& mEventThreadServices;
- AnimationPlaylist& mPlaylist;
+ AnimationPlaylist& mPlaylist;
Dali::Animation::AnimationSignalType mFinishedSignal{};
Dali::Animation::AnimationSignalType mProgressReachedSignal{};
#define DALI_INTERNAL_ANIMATOR_CONNECTOR_BASE_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// Add the new SceneGraph::Animator to its correspondent SceneGraph::Animation via message
const SceneGraph::Animation* animation = mParent->GetSceneObject();
DALI_ASSERT_DEBUG(nullptr != animation);
- AddAnimatorMessage(mParent->GetEventThreadServices(), *animation, *mAnimator);
+ AddAnimatorMessage(mParent->GetAnimationEventThreadServices(), *animation, *mAnimator);
// Add the new SceneGraph::PropertyResetter to the update manager via message
if(resetterRequired)
{
OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::AnimatorResetter::New(propertyOwner, *baseProperty, *mAnimator);
- AddResetterMessage(mParent->GetEventThreadServices().GetUpdateManager(), resetter);
+ AddResetterMessage(mParent->GetAnimationEventThreadServices().GetUpdateManager(), resetter);
}
}
} // unnamed namespace
ConstraintBase::ConstraintBase(Object& object, Property::Index targetPropertyIndex, SourceContainer& sources)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mTargetObject(&object),
mSceneGraphConstraint(nullptr),
mSources(sources),
#define DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL INCLUDES
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/animation/constraint-source-impl.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/dali-common.h>
/**
* An abstract base class for active constraints.
*/
-class ConstraintBase : public BaseObject, public Object::Observer
+class ConstraintBase : public BaseObject, public Object::Observer, public EventThreadServicesHolder
{
public:
using RemoveAction = Dali::Constraint::RemoveAction;
*/
PropertyInputImpl* AddInputProperty(Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex);
- /**
- * Get the event thread services object - used for sending messages to the scene graph
- * Assert if called from the wrong thread.
- * This is intentionally inline for performance reasons.
- *
- * @return The event thread services object
- */
- inline EventThreadServices& GetEventThreadServices()
- {
- DALI_ASSERT_DEBUG(EventThreadServices::IsCoreRunning());
- return mEventThreadServices;
- }
-
- /**
- * Get the event thread services object - used for sending messages to the scene graph
- * Assert if called from the wrong thread
- * This is intentionally inline for performance reasons.
- *
- * @return The event thread services object
- */
- inline const EventThreadServices& GetEventThreadServices() const
- {
- DALI_ASSERT_DEBUG(EventThreadServices::IsCoreRunning());
- return mEventThreadServices;
- }
-
protected:
- EventThreadServices& mEventThreadServices;
Object* mTargetObject; ///< The object owns the constraint.
const SceneGraph::ConstraintBase* mSceneGraphConstraint;
SourceContainer mSources;
--- /dev/null
+#ifndef DALI_INTERNAL_EVENT_THREAD_SERVICES_HOLDER_H
+#define DALI_INTERNAL_EVENT_THREAD_SERVICES_HOLDER_H
+
+/*
+ * Copyright (c) 2024 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.
+ * 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.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/public-api/common/dali-common.h>
+
+#ifndef DALI_ASSERT_EVENT_THREAD_SERVICES
+#define DALI_ASSERT_EVENT_THREAD_SERVICES(x) DALI_ASSERT_DEBUG(x)
+#endif
+
+namespace Dali::Internal
+{
+class EventThreadServicesHolder
+{
+protected:
+ EventThreadServicesHolder(EventThreadServices& eventThreadServices)
+ : mEventThreadServices(eventThreadServices)
+ {
+ }
+
+ virtual ~EventThreadServicesHolder() = default;
+
+protected:
+ /**
+ * Get the event thread services object - used for sending messages to the scene graph
+ * Assert if called from the wrong thread.
+ * This is intentionally inline for performance reasons.
+ *
+ * @return The event thread services object
+ */
+ inline EventThreadServices& GetEventThreadServices()
+ {
+ DALI_ASSERT_EVENT_THREAD_SERVICES(EventThreadServices::IsCoreRunning() && "Core is not running! Might call this API from worker thread.");
+ return mEventThreadServices;
+ }
+
+ /**
+ * Get the event thread services object - used for sending messages to the scene graph
+ * Assert if called from the wrong thread
+ * This is intentionally inline for performance reasons.
+ *
+ * @return The event thread services object
+ */
+ inline const EventThreadServices& GetEventThreadServices() const
+ {
+ DALI_ASSERT_EVENT_THREAD_SERVICES(EventThreadServices::IsCoreRunning() && "Core is not running! Might call this API from worker thread.");
+ return mEventThreadServices;
+ }
+
+private:
+ EventThreadServices& mEventThreadServices;
+};
+
+} // namespace Dali::Internal
+
+#endif // DALI_INTERNAL_EVENT_THREAD_SERVICES_HOLDER_H
}
Object::Object(const SceneGraph::PropertyOwner* sceneObject)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mUpdateObject(sceneObject),
mTypeInfo(nullptr),
mConstraints(nullptr),
#include <dali/integration-api/ordered-set.h>
#include <dali/internal/common/const-string.h>
#include <dali/internal/event/animation/animation-impl.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/event/common/property-metadata.h>
* a) Create their own scene-graph object and pass it to Object constructor.
* b) pass nullptr to Object constructor, in this case Object will create default scene object for property handling
*/
-class Object : public Dali::BaseObject
+class Object : public Dali::BaseObject, public EventThreadServicesHolder
{
public:
using Capability = Dali::Handle::Capability;
*/
virtual void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value);
-protected:
- /**
- * Get the event thread services object - used for sending messages to the scene graph
- * Assert if called from the wrong thread.
- * This is intentionally inline for performance reasons.
- *
- * @return The event thread services object
- */
- inline EventThreadServices& GetEventThreadServices()
- {
- DALI_ASSERT_ALWAYS(EventThreadServices::IsCoreRunning());
- return mEventThreadServices;
- }
-
- /**
- * Get the event thread services object - used for sending messages to the scene graph
- * Assert if called from the wrong thread
- * This is intentionally inline for performance reasons.
- *
- * @return The event thread services object
- */
- inline const EventThreadServices& GetEventThreadServices() const
- {
- DALI_ASSERT_ALWAYS(EventThreadServices::IsCoreRunning());
- return mEventThreadServices;
- }
-
-private:
- EventThreadServices& mEventThreadServices;
-
protected:
// mutable because it's lazy initialised and GetSceneObject has to be const so it can be called from const methods
// const to prevent accidentally calling setters directly from event thread
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
namespace Internal
{
RayTest::RayTest()
-: mEventThreadServices(EventThreadServices::Get())
{
}
#define DALI_INTERNAL_RAY_TEST_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
* @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
*/
bool ActorTest(const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir, Vector2& hitPointLocal, float& distance) const;
-
-private:
- const EventThreadServices& mEventThreadServices;
};
} // namespace Internal
{
namespace Internal
{
-
typedef std::vector<Actor*> OffScreenRenderableContainer;
typedef std::pair<Actor*, OffScreenRenderableContainer> ForwardOffScreenRenderableSubTree;
typedef std::vector<ForwardOffScreenRenderableSubTree> OffScreenRenderableData;
{
sortedTasks->push_back(task->GetRenderTaskSceneObject());
}
- SortTasksMessage(mEventThreadServices, *mSceneObject, sortedTasks);
+ SortTasksMessage(GetEventThreadServices(), *mSceneObject, sortedTasks);
mIsRequestedToSortTask = false;
}
bool IsWithinSourceActors(const Actor& sourceActor, Actor& actor)
{
- bool isInside = false;
+ bool isInside = false;
Actor* currentActor = &actor;
while(currentActor)
{
{
if(&actor != renderableData[subTreeIndex].first)
{
-
// New BACKWARD OffScreen Renderable
if(actor.GetOffScreenRenderableType() & OffScreenRenderable::Type::BACKWARD)
{
}
RenderTaskList::RenderTaskList()
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mDefaults(*Stage::GetCurrent()),
mSceneObject(nullptr)
{
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mSceneObject))
{
// Remove the render task list using a message to the update manager
- RemoveRenderTaskListMessage(mEventThreadServices.GetUpdateManager(), *mSceneObject);
+ RemoveRenderTaskListMessage(GetEventThreadServices().GetUpdateManager(), *mSceneObject);
}
}
mSceneObject = SceneGraph::RenderTaskList::New();
OwnerPointer<SceneGraph::RenderTaskList> transferOwnership(const_cast<SceneGraph::RenderTaskList*>(mSceneObject));
- AddRenderTaskListMessage(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ AddRenderTaskListMessage(GetEventThreadServices().GetUpdateManager(), transferOwnership);
// set the callback to call us back when tasks are completed
mSceneObject->SetCompleteNotificationInterface(this);
#define DALI_INTERNAL_RENDER_TASK_LIST_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali/internal/event/actors/layer-list.h>
#include <dali/internal/event/common/complete-notification-interface.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/scene-graph-notifier-interface-mapper.h>
#include <dali/internal/event/events/actor-observer.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
* A proxy for the scene-graph RenderTaskList.
* A separate LayerList is maintained for actors added via the SystemLevel::Add().
*/
-class RenderTaskList : public BaseObject, public CompleteNotificationInterface, public SceneGraphNotifierInterfaceMapper<RenderTask>
+class RenderTaskList : public BaseObject, public CompleteNotificationInterface, public SceneGraphNotifierInterfaceMapper<RenderTask>, public EventThreadServicesHolder
{
public:
using RenderTaskContainer = std::vector<RenderTaskPtr>;
void NotifyCompleted(CompleteNotificationInterface::ParameterList notifierList) override;
private:
- EventThreadServices& mEventThreadServices;
- RenderTaskDefaults& mDefaults;
+ RenderTaskDefaults& mDefaults;
SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
}
FrameBuffer::FrameBuffer(uint32_t width, uint32_t height, Mask attachments)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mRenderObject(nullptr),
mColor{nullptr},
mDepth(nullptr),
mRenderObject = new Render::FrameBuffer(mWidth, mHeight, mAttachments);
OwnerPointer<Render::FrameBuffer> transferOwnership(mRenderObject);
- AddFrameBuffer(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ AddFrameBuffer(GetEventThreadServices().GetUpdateManager(), transferOwnership);
}
void FrameBuffer::AttachColorTexture(TexturePtr texture, uint32_t mipmapLevel, uint32_t layer)
mColor[mColorAttachmentCount] = texture;
++mColorAttachmentCount;
- AttachColorTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel, layer);
+ AttachColorTextureToFrameBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel, layer);
}
}
else
{
mDepth = texture;
- AttachDepthTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
+ AttachDepthTextureToFrameBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
}
}
else
{
mStencil = texture;
- AttachDepthStencilTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
+ AttachDepthStencilTextureToFrameBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
}
}
void FrameBuffer::SetMultiSamplingLevel(uint8_t multiSamplingLevel)
{
- SetMultiSamplingLevelToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, multiSamplingLevel);
+ SetMultiSamplingLevelToFrameBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject, multiSamplingLevel);
}
Texture* FrameBuffer::GetColorTexture(uint8_t index) const
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject))
{
- RemoveFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject);
+ RemoveFrameBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject);
}
}
#define DALI_INTERNAL_FRAME_BUFFER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL INCLUDES
#include <dali/devel-api/rendering/frame-buffer-devel.h>
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/rendering/texture-impl.h>
#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
class FrameBuffer;
using FrameBufferPtr = IntrusivePtr<FrameBuffer>;
-class FrameBuffer : public BaseObject
+class FrameBuffer : public BaseObject, public EventThreadServicesHolder
{
public:
using Mask = Dali::FrameBuffer::Attachment::Mask;
*/
void Initialize();
-protected:
private: // unimplemented methods
FrameBuffer() = delete;
FrameBuffer(const FrameBuffer&) = delete;
FrameBuffer& operator=(const FrameBuffer&) = delete;
-private: // data
- Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
- Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
+private: // data
+ Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
TexturePtr mColor[Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS];
TexturePtr mDepth;
uint32_t Geometry::AddVertexBuffer(VertexBuffer& vertexBuffer)
{
mVertexBuffers.push_back(&vertexBuffer);
- SceneGraph::AttachVertexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject());
+ SceneGraph::AttachVertexBufferMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject());
return static_cast<uint32_t>(mVertexBuffers.size() - 1u);
}
void Geometry::RemoveVertexBuffer(uint32_t index)
{
const Render::VertexBuffer& renderVertexBuffer = static_cast<const Render::VertexBuffer&>(*(mVertexBuffers[index]->GetRenderObject()));
- SceneGraph::RemoveVertexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, renderVertexBuffer);
+ SceneGraph::RemoveVertexBufferMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, renderVertexBuffer);
mVertexBuffers.erase(mVertexBuffers.begin() + index);
}
std::copy(indices, indices + count, indexData.Begin());
}
- SceneGraph::SetIndexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, indexData);
+ SceneGraph::SetIndexBufferMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, indexData);
}
void Geometry::SetIndexBuffer(const uint32_t* indices, uint32_t count)
std::copy(indices, indices + count, indexData.Begin());
}
- SceneGraph::SetIndexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, indexData);
+ SceneGraph::SetIndexBufferMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, indexData);
}
void Geometry::SetType(Dali::Geometry::Type geometryType)
{
if(geometryType != mType)
{
- SceneGraph::SetGeometryTypeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, geometryType);
+ SceneGraph::SetGeometryTypeMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, geometryType);
mType = geometryType;
}
}
Geometry::Geometry()
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mRenderObject(nullptr),
mType(Dali::Geometry::TRIANGLES)
{
{
mRenderObject = new Render::Geometry();
OwnerPointer<Render::Geometry> transferOwnership(mRenderObject);
- AddGeometry(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ AddGeometry(GetEventThreadServices().GetUpdateManager(), transferOwnership);
}
Geometry::~Geometry()
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject))
{
- RemoveGeometry(mEventThreadServices.GetUpdateManager(), *mRenderObject);
+ RemoveGeometry(GetEventThreadServices().GetUpdateManager(), *mRenderObject);
}
}
#define DALI_INTERNAL_GEOMETRY_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/rendering/geometry.h> // Dali::Geometry
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/rendering/vertex-buffer-impl.h> // Dali::Internal::VertexBuffer
#include <dali/internal/render/renderers/render-geometry.h>
* Geometry is an object that contains an array of structures of values that
* can be accessed as properties.
*/
-class Geometry : public BaseObject
+class Geometry : public BaseObject, public EventThreadServicesHolder
{
public:
/**
Geometry(const Geometry&);
Geometry& operator=(const Geometry&);
-private: // data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Render::Geometry* mRenderObject;
+private: // data
+ Render::Geometry* mRenderObject;
std::vector<VertexBufferPtr> mVertexBuffers; ///< Vector of intrusive pointers to vertex buffers
Dali::Geometry::Type mType; ///< Geometry type (cached)
{
if(nullptr != mRenderObject)
{
- SetFilterModeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(minFilter), static_cast<unsigned int>(magFilter));
+ SetFilterModeMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(minFilter), static_cast<unsigned int>(magFilter));
}
}
{
if(nullptr != mRenderObject)
{
- SetWrapModeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(rWrap), static_cast<unsigned int>(sWrap), static_cast<unsigned int>(tWrap));
+ SetWrapModeMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(rWrap), static_cast<unsigned int>(sWrap), static_cast<unsigned int>(tWrap));
}
}
}
Sampler::Sampler()
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mRenderObject(nullptr)
{
}
void Sampler::Initialize()
{
- SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+ SceneGraph::UpdateManager& updateManager = GetEventThreadServices().GetUpdateManager();
mRenderObject = new Render::Sampler();
OwnerPointer<Render::Sampler> transferOwnership(mRenderObject);
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject))
{
- SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+ SceneGraph::UpdateManager& updateManager = GetEventThreadServices().GetUpdateManager();
RemoveSamplerMessage(updateManager, *mRenderObject);
}
}
#define DALI_INTERNAL_SAMPLER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
*/
// INTERNAL INCLUDES
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/public-api/actors/sampling.h>
* Sampler is an object that contains an array of structures of values that
* can be accessed as properties.
*/
-class Sampler : public BaseObject
+class Sampler : public BaseObject, public EventThreadServicesHolder
{
public:
/**
*/
~Sampler() override;
-private: // data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via the update thread
- Render::Sampler* mRenderObject; ///<Render thread sampler for this sampler
+private: // data
+ Render::Sampler* mRenderObject; ///<Render thread sampler for this sampler
};
} // namespace Internal
}
Texture::Texture(TextureType::Type type, Pixel::Format format, ImageDimensions size)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mTextureKey{},
mNativeImage(),
mSize(size),
}
Texture::Texture(NativeImageInterfacePtr nativeImageInterface)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mTextureKey{},
mNativeImage(nativeImageInterface),
mSize(nativeImageInterface->GetWidth(), nativeImageInterface->GetHeight()),
}
Texture::Texture(TextureType::Type type, uint32_t resourceId)
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mTextureKey{},
mNativeImage(),
mSize(),
}
}
- AddTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
+ AddTextureMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey);
}
}
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey))
{
- RemoveTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
+ RemoveTextureMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey);
}
}
static_cast<uint16_t>(yOffset),
static_cast<uint16_t>(width),
static_cast<uint16_t>(height)};
- UploadTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, pixelData, params);
+ UploadTextureMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey, pixelData, params);
result = true;
}
{
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey))
{
- GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
+ GenerateMipmapsMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey);
}
else
{
mSize = size;
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey))
{
- SetTextureSizeMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, mSize);
+ SetTextureSizeMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey, mSize);
}
}
mFormat = format;
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey))
{
- SetTextureFormatMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, mFormat);
+ SetTextureFormatMessage(GetEventThreadServices().GetUpdateManager(), mTextureKey, mFormat);
}
}
#define DALI_INTERNAL_NEW_TEXTURE_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
*/
// INTERNAL INCLUDES
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/images/pixel-data-impl.h>
#include <dali/internal/render/renderers/render-texture-key.h>
class Texture;
using TexturePtr = IntrusivePtr<Texture>;
-class Texture : public BaseObject
+class Texture : public BaseObject, public EventThreadServicesHolder
{
public:
/**
Texture(const Texture&);
Texture& operator=(const Texture&);
-private: // data
- Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Internal::Render::TextureKey mTextureKey; ///<The Render::Texture associated to this texture
+private: // data
+ Internal::Render::TextureKey mTextureKey; ///<The Render::Texture associated to this texture
NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
ImageDimensions mSize; ///< Size of the texture
renderTexture = texture->GetRenderTextureKey();
}
- SceneGraph::SetTextureMessage(mEventThreadServices, *mSceneObject, index, renderTexture);
+ SceneGraph::SetTextureMessage(GetEventThreadServices(), *mSceneObject, index, renderTexture);
if(!texture)
{
renderSampler = sampler->GetSamplerRenderObject();
}
- SceneGraph::SetSamplerMessage(mEventThreadServices, *mSceneObject, index, renderSampler);
+ SceneGraph::SetSamplerMessage(GetEventThreadServices(), *mSceneObject, index, renderSampler);
if(!sampler)
{
}
TextureSet::TextureSet()
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mSceneObject(nullptr)
{
}
void TextureSet::Initialize()
{
- SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+ SceneGraph::UpdateManager& updateManager = GetEventThreadServices().GetUpdateManager();
mSceneObject = SceneGraph::TextureSet::New();
OwnerPointer<SceneGraph::TextureSet> transferOwnership(mSceneObject);
if(DALI_LIKELY(EventThreadServices::IsCoreRunning()))
{
- SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+ SceneGraph::UpdateManager& updateManager = GetEventThreadServices().GetUpdateManager();
RemoveTextureSetMessage(updateManager, *mSceneObject);
}
}
#define DALI_INTERNAL_TEXTURE_SET_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali/public-api/common/vector-wrapper.h> // std::vector
// INTERNAL INCLUDES
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
/**
* TextureSet is an object that holds all the textures used by a renderer
*/
-class TextureSet : public BaseObject
+class TextureSet : public BaseObject, public EventThreadServicesHolder
{
public:
/**
TextureSet(const TextureSet&);
TextureSet& operator=(const TextureSet&);
-private: // Data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
+private: // Data
SceneGraph::TextureSet* mSceneObject;
std::vector<SamplerPtr> mSamplers;
std::vector<TexturePtr> mTextures;
std::copy(source, source + bufferSize, destination);
// Ownership of the bufferCopy is passed to the message ( uses an owner pointer )
- SceneGraph::SetVertexBufferData(mEventThreadServices.GetUpdateManager(), *mRenderObject, bufferCopy, mSize);
+ SceneGraph::SetVertexBufferData(GetEventThreadServices().GetUpdateManager(), *mRenderObject, bufferCopy, mSize);
}
uint32_t VertexBuffer::GetSize() const
void VertexBuffer::SetDivisor(uint32_t divisor)
{
- SceneGraph::SetVertexBufferDivisorMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, divisor);
+ SceneGraph::SetVertexBufferDivisorMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, divisor);
mDivisor = divisor;
}
ClearVertexBufferUpdateCallback();
}
mVertexBufferUpdateCallback = &callback;
- SceneGraph::SetVertexBufferUpdateCallbackMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, &callback);
+ SceneGraph::SetVertexBufferUpdateCallbackMessage(GetEventThreadServices().GetUpdateManager(), *mRenderObject, &callback);
}
void VertexBuffer::ClearVertexBufferUpdateCallback()
if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject))
{
- SceneGraph::RemoveVertexBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject);
+ SceneGraph::RemoveVertexBuffer(GetEventThreadServices().GetUpdateManager(), *mRenderObject);
}
}
VertexBuffer::VertexBuffer()
-: mEventThreadServices(EventThreadServices::Get()),
+: EventThreadServicesHolder(EventThreadServices::Get()),
mRenderObject(nullptr),
mBufferFormatSize(0),
mSize(0)
{
mRenderObject = new Render::VertexBuffer();
OwnerPointer<Render::VertexBuffer> transferOwnership(mRenderObject);
- SceneGraph::AddVertexBuffer(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ SceneGraph::AddVertexBuffer(GetEventThreadServices().GetUpdateManager(), transferOwnership);
uint32_t numComponents = static_cast<uint32_t>(formatMap.Count());
mBufferFormatSize = format->size;
- SceneGraph::SetVertexBufferFormat(mEventThreadServices.GetUpdateManager(), *mRenderObject, format);
+ SceneGraph::SetVertexBufferFormat(GetEventThreadServices().GetUpdateManager(), *mRenderObject, format);
}
uint32_t GetPropertyImplementationSize(Property::Type& propertyType)
#define DALI_INTERNAL_VERTEX_BUFFER_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali/public-api/object/property-map.h> // Dali::Property::Map
#include <dali/public-api/rendering/vertex-buffer.h> // Dali::VertexBuffer
+#include <dali/internal/event/common/event-thread-services-holder.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/render/renderers/render-vertex-buffer.h>
* VertexBuffer is an object that contains an array of structures of values that
* can be accessed as properties.
*/
-class VertexBuffer : public BaseObject
+class VertexBuffer : public BaseObject, public EventThreadServicesHolder
{
public:
/**
VertexBuffer& operator=(const VertexBuffer&);
private: // data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
Render::VertexBuffer* mRenderObject{nullptr}; ///<Render side object
VertexBufferUpdateCallback* mVertexBufferUpdateCallback{nullptr}; ///<Vertex buffer update callback pointer
uint32_t mBufferFormatSize{0};