2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/render-tasks/render-task-impl.h>
22 #include <cstring> // for strcmp
23 #include "render-task-impl.h"
26 #include <dali/internal/event/actors/actor-impl.h>
27 #include <dali/internal/event/actors/camera-actor-impl.h>
28 #include <dali/internal/event/common/event-thread-services.h>
29 #include <dali/internal/event/common/projection.h>
30 #include <dali/internal/event/common/property-helper.h>
31 #include <dali/internal/event/common/scene-impl.h>
32 #include <dali/internal/event/common/stage-impl.h>
33 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
34 #include <dali/internal/update/common/animatable-property-messages.h>
35 #include <dali/internal/update/nodes/node.h>
36 #include <dali/internal/update/render-tasks/scene-graph-render-task-messages.h>
37 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
38 #include <dali/public-api/common/dali-common.h>
39 #include <dali/public-api/object/type-registry.h>
41 #if defined(DEBUG_ENABLED)
44 Debug::Filter* gLogRender = Debug::Filter::New(Debug::Concise, false, "LOG_RENDER_TASK");
52 namespace // For internal properties
56 // Name Type writable animatable constraint-input enum for index-checking
57 DALI_PROPERTY_TABLE_BEGIN
58 DALI_PROPERTY("viewportPosition", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_POSITION)
59 DALI_PROPERTY("viewportSize", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_SIZE)
60 DALI_PROPERTY("clearColor", VECTOR4, true, true, true, Dali::RenderTask::Property::CLEAR_COLOR)
61 DALI_PROPERTY("requiresSync", BOOLEAN, true, false, false, Dali::RenderTask::Property::REQUIRES_SYNC)
62 DALI_PROPERTY_TABLE_END(DEFAULT_OBJECT_PROPERTY_START_INDEX, RenderTaskDefaultProperties)
66 const char* const SIGNAL_FINISHED = "finished";
68 TypeRegistration mType(typeid(Dali::RenderTask), typeid(Dali::BaseHandle), nullptr, RenderTaskDefaultProperties);
70 SignalConnectorType signalConnector1(mType, SIGNAL_FINISHED, &RenderTask::DoConnectSignal);
72 } // Unnamed namespace
74 RenderTaskPtr RenderTask::New(Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList, bool isOverlayTask)
76 // create scene object first so it's guaranteed to exist for the event side
77 auto sceneObject = SceneGraph::RenderTask::New();
79 // pass the pointer to base for message passing
80 RenderTaskPtr task(new RenderTask(sceneObject, renderTaskList));
82 // transfer scene object ownership to update manager
83 const SceneGraph::RenderTaskList& parentSceneObject = renderTaskList.GetSceneObject();
84 OwnerPointer<SceneGraph::RenderTask> transferOwnership(sceneObject);
85 AddTaskMessage(task->GetEventThreadServices(), parentSceneObject, transferOwnership);
87 // Set the default source & camera actors
88 task->SetSourceActor(sourceActor);
89 task->SetCameraActor(cameraActor);
91 // no need for additional messages as scene objects defaults match ours
95 void RenderTask::SetSourceActor(Actor* actor)
97 mSourceActor.SetActor(actor);
99 if(GetRenderTaskSceneObject())
103 SetSourceNodeMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), &actor->GetNode());
107 SetSourceNodeMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), nullptr);
111 // set the actor on exclusive container for hit testing
112 mRenderTaskList.SetExclusive(this, mExclusive);
115 Actor* RenderTask::GetSourceActor() const
117 return mSourceActor.GetActor();
120 Actor* RenderTask::GetStopperActor() const
122 return mStopperActor.GetActor();
125 void RenderTask::SetExclusive(bool exclusive)
127 if(mExclusive != exclusive)
129 mExclusive = exclusive;
131 mRenderTaskList.SetExclusive(this, exclusive);
133 if(GetRenderTaskSceneObject())
135 // scene object is being used in a separate thread; queue a message to set the value
136 SetExclusiveMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), mExclusive);
141 bool RenderTask::IsExclusive() const
146 void RenderTask::SetInputEnabled(bool enabled)
148 mInputEnabled = enabled;
151 bool RenderTask::GetInputEnabled() const
153 return mInputEnabled;
156 void RenderTask::SetCameraActor(CameraActor* cameraActor)
158 mCameraActor.SetActor(cameraActor);
160 if(GetRenderTaskSceneObject())
164 SetCameraMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), &cameraActor->GetCameraSceneObject());
168 SetCameraMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), nullptr);
172 // set the actor on exclusive container for hit testing
173 mRenderTaskList.SetExclusive(this, mExclusive);
176 CameraActor* RenderTask::GetCameraActor() const
178 if(mCameraActor.GetActor())
180 return static_cast<CameraActor*>(mCameraActor.GetActor());
185 void RenderTask::SetFrameBuffer(FrameBufferPtr frameBuffer)
187 mFrameBuffer = frameBuffer;
188 Render::FrameBuffer* renderFrameBufferPtr(nullptr);
191 renderFrameBufferPtr = mFrameBuffer->GetRenderObject();
194 if(GetRenderTaskSceneObject())
196 SetFrameBufferMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), renderFrameBufferPtr);
200 FrameBuffer* RenderTask::GetFrameBuffer() const
202 return mFrameBuffer.Get();
205 void RenderTask::SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction)
207 mScreenToFrameBufferFunction = conversionFunction;
210 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
212 return mScreenToFrameBufferFunction;
215 void RenderTask::SetScreenToFrameBufferMappingActor(Dali::Actor& mappingActor)
217 mInputMappingActor = WeakHandle<Dali::Actor>(mappingActor);
220 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
222 return mInputMappingActor.GetHandle();
225 void RenderTask::SetViewportGuideActor(Actor* actor)
227 mViewportGuideActor.SetActor(actor);
229 auto sceneObject = GetRenderTaskSceneObject();
232 auto& eventThreadServices = GetEventThreadServices();
233 auto& updateManager = eventThreadServices.GetUpdateManager();
237 SetViewportGuideNodeMessage(eventThreadServices, *sceneObject, &actor->GetNode());
241 // Ensure that if the node is removed through this API, that the
242 // viewport values are set back to their base value and that their dirty
243 // flags are cleared after 1 frame.
244 SetViewportGuideNodeMessage(eventThreadServices, *sceneObject, nullptr);
246 auto renderTask = const_cast<SceneGraph::RenderTask*>(sceneObject);
247 auto viewportPositionProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportPosition);
248 auto viewportSizeProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportSize);
250 OwnerPointer<SceneGraph::PropertyResetterBase> resetter1(
251 new SceneGraph::BakerResetter(renderTask, viewportPositionProperty, SceneGraph::BakerResetter::Lifetime::SET));
252 OwnerPointer<SceneGraph::PropertyResetterBase> resetter2(
253 new SceneGraph::BakerResetter(renderTask, viewportSizeProperty, SceneGraph::BakerResetter::Lifetime::SET));
254 AddResetterMessage(updateManager, resetter1);
255 AddResetterMessage(updateManager, resetter2);
260 Actor* RenderTask::GetViewportGuideActor() const
262 return mViewportGuideActor.GetActor();
265 void RenderTask::ResetViewportGuideActor()
267 // Don't re-use the SetViewportGuideActor method for this task - the bake messages below will create their own resetters.
268 mViewportGuideActor.SetActor(nullptr);
270 if(GetRenderTaskSceneObject())
272 SetViewportGuideNodeMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), nullptr);
274 EventThreadServices& eventThreadServices = GetEventThreadServices();
275 auto renderTask = const_cast<SceneGraph::RenderTask*>(GetRenderTaskSceneObject());
276 auto viewportPositionProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportPosition);
277 auto viewportSizeProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportSize);
278 BakeMessage<Vector2>(eventThreadServices, *renderTask, *viewportPositionProperty, mViewportPosition);
279 BakeMessage<Vector2>(eventThreadServices, *renderTask, *viewportSizeProperty, mViewportSize);
283 void RenderTask::SetViewportPosition(const Vector2& value)
285 mViewportPosition = value;
287 if(GetRenderTaskSceneObject())
289 EventThreadServices& eventThreadServices = GetEventThreadServices();
290 auto renderTask = const_cast<SceneGraph::RenderTask*>(GetRenderTaskSceneObject());
291 auto viewportPositionProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportPosition);
292 BakeMessage<Vector2>(eventThreadServices, *renderTask, *viewportPositionProperty, mViewportPosition);
296 Vector2 RenderTask::GetCurrentViewportPosition() const
298 return GetRenderTaskSceneObject() ? GetRenderTaskSceneObject()->GetViewportPosition(GetEventThreadServices().GetEventBufferIndex()) : Vector2::ZERO;
301 void RenderTask::SetViewportSize(const Vector2& value)
303 mViewportSize = value;
305 if(GetRenderTaskSceneObject())
307 EventThreadServices& eventThreadServices = GetEventThreadServices();
308 auto renderTask = const_cast<SceneGraph::RenderTask*>(GetRenderTaskSceneObject());
309 auto viewportSizeProperty = const_cast<SceneGraph::AnimatableProperty<Vector2>*>(&renderTask->mViewportSize);
310 BakeMessage<Vector2>(eventThreadServices, *renderTask, *viewportSizeProperty, mViewportSize);
314 Vector2 RenderTask::GetCurrentViewportSize() const
316 return GetRenderTaskSceneObject() ? GetRenderTaskSceneObject()->GetViewportSize(GetEventThreadServices().GetEventBufferIndex()) : Vector2::ZERO;
319 void RenderTask::SetViewport(const Viewport& viewport)
321 SetViewportPosition(Vector2(static_cast<float>(viewport.x), static_cast<float>(viewport.y)));
322 SetViewportSize(Vector2(static_cast<float>(viewport.width), static_cast<float>(viewport.height)));
325 void RenderTask::GetViewport(Viewport& viewPort) const
327 if(GetRenderTaskSceneObject())
329 BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
331 if(!GetRenderTaskSceneObject()->GetViewportEnabled(bufferIndex))
333 Internal::Stage* stage = Internal::Stage::GetCurrent();
336 Vector2 size(stage->GetSize());
337 Actor* sourceActor = mSourceActor.GetActor();
338 if(sourceActor && sourceActor->OnScene())
340 Scene& scene = sourceActor->GetScene();
341 size = scene.GetSize();
344 viewPort.x = viewPort.y = 0;
345 viewPort.width = static_cast<int32_t>(size.width); // truncated
346 viewPort.height = static_cast<int32_t>(size.height); // truncated
351 const Vector2& position = GetRenderTaskSceneObject()->GetViewportPosition(bufferIndex);
352 const Vector2& size = GetRenderTaskSceneObject()->GetViewportSize(bufferIndex);
353 viewPort.x = static_cast<int32_t>(position.x); // truncated
354 viewPort.y = static_cast<int32_t>(position.y); // truncated
355 viewPort.width = static_cast<int32_t>(size.width); // truncated
356 viewPort.height = static_cast<int32_t>(size.height); // truncated
361 void RenderTask::SetClearColor(const Vector4& color)
363 if(mClearColor != color)
367 if(GetRenderTaskSceneObject())
369 // scene object is being used in a separate thread; queue a message to set the value
370 EventThreadServices& eventThreadServices = GetEventThreadServices();
371 auto renderTask = const_cast<SceneGraph::RenderTask*>(GetRenderTaskSceneObject());
372 auto clearColorProperty = const_cast<SceneGraph::AnimatableProperty<Vector4>*>(&renderTask->mClearColor);
373 BakeMessage<Vector4>(eventThreadServices, *renderTask, *clearColorProperty, mClearColor);
378 const Vector4& RenderTask::GetClearColor() const
380 return GetRenderTaskSceneObject() ? GetRenderTaskSceneObject()->GetClearColor(GetEventThreadServices().GetEventBufferIndex()) : Vector4::ZERO;
383 void RenderTask::SetSyncRequired(bool requiresSync)
385 if(mRequiresSync != requiresSync)
387 mRequiresSync = requiresSync;
389 if(GetRenderTaskSceneObject())
391 // scene object is being used in a separate thread; queue a message to set the value
392 SetSyncRequiredMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), requiresSync);
397 bool RenderTask::IsSyncRequired() const
399 return mRequiresSync;
402 void RenderTask::SetClearEnabled(bool enabled)
404 if(mClearEnabled != enabled)
406 mClearEnabled = enabled;
408 if(GetRenderTaskSceneObject())
410 // scene object is being used in a separate thread; queue a message to set the value
411 SetClearEnabledMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), mClearEnabled);
416 bool RenderTask::GetClearEnabled() const
418 return mClearEnabled;
421 void RenderTask::SetCullMode(bool mode)
423 if(mCullMode != mode)
427 if(GetRenderTaskSceneObject())
429 // scene object is being used in a separate thread; queue a message to set the value
430 SetCullModeMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), mCullMode);
435 bool RenderTask::GetCullMode() const
440 void RenderTask::SetRefreshRate(uint32_t refreshRate)
442 DALI_LOG_TRACE_METHOD_FMT(gLogRender, "this:%p rate:%d\n", this, refreshRate);
443 DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::SetRefreshRate(this:%p, %d)\n", this, refreshRate);
445 mRefreshRate = refreshRate; // cached for GetRefreshRate()
447 // Note - even when refreshRate is the same as mRefreshRate, a message should be sent
449 if(GetRenderTaskSceneObject())
451 // sceneObject is being used in a separate thread; queue a message to set the value
452 SetRefreshRateMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), refreshRate);
456 uint32_t RenderTask::GetRefreshRate() const
461 bool RenderTask::IsHittable(Vector2& screenCoords) const
463 // True when input is enabled, source & camera actor are valid
464 bool inputEnabled(false);
466 Actor* sourceActor = GetSourceActor();
467 CameraActor* cameraActor = GetCameraActor();
470 nullptr != sourceActor &&
471 sourceActor->OnScene() &&
472 nullptr != cameraActor &&
473 cameraActor->OnScene())
475 // If the actors are rendered off-screen, then the screen coordinates must be converted
476 // and the conversion function will tell us if they are inside or outside
477 if(TranslateCoordinates(screenCoords))
479 // This is a suitable render-task for input handling
487 bool RenderTask::TranslateCoordinates(Vector2& screenCoords) const
489 // return true for on-screen tasks
491 // If the actors are rendered off-screen, then the screen coordinates must be converted
492 // the function should only be called for offscreen tasks
493 Dali::Actor mappingActor = GetScreenToFrameBufferMappingActor();
495 if(mFrameBuffer && mappingActor)
497 Internal::Actor* inputMappingActor = &GetImplementation(mappingActor);
498 if(!inputMappingActor->OnScene())
503 CameraActor* localCamera = GetCameraActor();
504 StagePtr stage = Stage::GetCurrent();
507 Vector2 size(stage->GetSize());
508 CameraActor* defaultCamera(&stage->GetDefaultCameraActor());
509 Actor* sourceActor = mSourceActor.GetActor();
510 if(sourceActor && sourceActor->OnScene())
512 Scene& scene = sourceActor->GetScene();
513 size = scene.GetSize();
514 defaultCamera = &scene.GetDefaultCameraActor();
520 viewport.x = viewport.y = 0;
521 viewport.width = static_cast<int32_t>(size.width); // truncated
522 viewport.height = static_cast<int32_t>(size.height); // truncated
524 float localX, localY;
525 inside = inputMappingActor->ScreenToLocal(defaultCamera->GetViewMatrix(), defaultCamera->GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
526 Vector3 actorSize = inputMappingActor->GetCurrentSize() * inputMappingActor->GetCurrentWorldScale();
527 if(inside && localX >= 0.f && localX <= actorSize.x && localY >= 0.f && localY <= actorSize.y)
529 screenCoords.x = localX;
530 screenCoords.y = localY;
543 else if(mFrameBuffer && mScreenToFrameBufferFunction)
545 inside = mScreenToFrameBufferFunction(screenCoords);
550 void RenderTask::GetHittableViewport(Viewport& viewPort) const
552 if(GetRenderTaskSceneObject())
554 if(GetInputEnabled())
558 auto mappingActor = GetScreenToFrameBufferMappingActor();
561 Actor& inputMappingActor = GetImplementation(mappingActor);
563 Vector3 actorSize = inputMappingActor.GetCurrentSize() * inputMappingActor.GetCurrentWorldScale();
565 viewPort.x = viewPort.y = 0;
566 viewPort.width = static_cast<int32_t>(actorSize.x + 0.5f); // rounded
567 viewPort.height = static_cast<int32_t>(actorSize.y + 0.5f); // rounded
571 // For the case to use ScreenToFrameBufferFunction
572 GetViewport(viewPort);
577 GetViewport(viewPort);
583 bool RenderTask::WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const
585 CameraActor* cam = GetCameraActor();
587 Vector4 pos(position);
590 Vector4 viewportPosition;
593 GetViewport(viewport);
595 bool ok = ProjectFull(pos,
596 cam->GetViewMatrix(),
597 cam->GetProjectionMatrix(),
598 static_cast<float>(viewport.x), // truncated
599 static_cast<float>(viewport.y), // truncated
600 static_cast<float>(viewport.width), // truncated
601 static_cast<float>(viewport.height), // truncated
605 viewportX = viewportPosition.x;
606 viewportY = viewportPosition.y;
612 bool RenderTask::ViewportToLocal(Actor* actor, float viewportX, float viewportY, float& localX, float& localY) const
614 return actor->ScreenToLocal(*this, localX, localY, viewportX, viewportY);
617 void RenderTask::SetRenderPassTag(uint32_t renderPassTag)
619 if(mRenderPassTag != renderPassTag)
621 mRenderPassTag = renderPassTag;
622 if(GetRenderTaskSceneObject())
624 SetRenderPassTagMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), renderPassTag);
629 uint32_t RenderTask::GetRenderPassTag() const
631 return mRenderPassTag;
634 void RenderTask::SetOrderIndex(int32_t orderIndex)
636 if(mOrderIndex != orderIndex)
638 mOrderIndex = orderIndex;
640 // We only need to sort render task list if it is valid.
641 if(GetRenderTaskSceneObject())
643 mRenderTaskList.RequestToSort();
648 int32_t RenderTask::GetOrderIndex() const
653 uint32_t RenderTask::GetRenderTaskId() const
655 return mRenderTaskId;
658 void RenderTask::RenderUntil(Actor* stopperActor)
660 Actor* target = mSourceActor.GetActor();
661 DALI_ASSERT_ALWAYS((target && stopperActor) && "RenderTask::RenderUntil() has empty actors.");
662 DALI_ASSERT_ALWAYS((target->GetHierarchyDepth() < stopperActor->GetHierarchyDepth()) && "RenderTask::RenderUntil() has reversed hierarchy.");
664 Actor* parent = stopperActor;
665 while(parent != target && !(parent->IsLayer()))
667 parent = parent->GetParent();
670 if(parent == target && GetRenderTaskSceneObject())
672 mStopperActor.SetActor(stopperActor);
673 SetStopperNodeMessage(GetEventThreadServices(), *GetRenderTaskSceneObject(), &stopperActor->GetNode());
677 const SceneGraph::RenderTask* RenderTask::GetRenderTaskSceneObject() const
679 return static_cast<const SceneGraph::RenderTask*>(mUpdateObject);
682 void RenderTask::RemoveRenderTaskSceneObject(RenderTaskList& renderTaskList)
684 // send a message to remove the scene-graph RenderTask
685 const SceneGraph::RenderTaskList& parentSceneObject = renderTaskList.GetSceneObject();
686 RemoveTaskMessage(GetEventThreadServices(), parentSceneObject, *GetRenderTaskSceneObject());
688 mUpdateObject = nullptr;
691 RenderTaskList& RenderTask::GetRenderTaskList() const
693 return mRenderTaskList;
696 /********************************************************************************
697 ******************************** PROPERTY METHODS **************************
698 ********************************************************************************/
700 void RenderTask::SetDefaultProperty(Property::Index index, const Property::Value& property)
704 case Dali::RenderTask::Property::VIEWPORT_POSITION:
706 SetViewportPosition(property.Get<Vector2>());
709 case Dali::RenderTask::Property::VIEWPORT_SIZE:
711 SetViewportSize(property.Get<Vector2>());
714 case Dali::RenderTask::Property::CLEAR_COLOR:
716 SetClearColor(property.Get<Vector4>());
719 case Dali::RenderTask::Property::REQUIRES_SYNC:
721 SetSyncRequired(property.Get<bool>());
732 Property::Value RenderTask::GetDefaultProperty(Property::Index index) const
734 Property::Value value;
738 case Dali::RenderTask::Property::VIEWPORT_POSITION:
740 value = mViewportPosition;
743 case Dali::RenderTask::Property::VIEWPORT_SIZE:
745 value = mViewportSize;
748 case Dali::RenderTask::Property::CLEAR_COLOR:
753 case Dali::RenderTask::Property::REQUIRES_SYNC:
755 value = IsSyncRequired();
761 DALI_ASSERT_ALWAYS(false && "RenderTask property index out of range"); // should not come here
769 Property::Value RenderTask::GetDefaultPropertyCurrentValue(Property::Index index) const
771 Property::Value value;
775 case Dali::RenderTask::Property::VIEWPORT_POSITION:
777 value = GetCurrentViewportPosition();
780 case Dali::RenderTask::Property::VIEWPORT_SIZE:
782 value = GetCurrentViewportSize();
785 case Dali::RenderTask::Property::CLEAR_COLOR:
787 value = GetClearColor();
790 case Dali::RenderTask::Property::REQUIRES_SYNC:
792 value = IsSyncRequired();
798 DALI_ASSERT_ALWAYS(false && "RenderTask property index out of range"); // should not come here
806 void RenderTask::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
808 switch(animationType)
811 case Animation::BETWEEN:
815 case Dali::RenderTask::Property::VIEWPORT_POSITION:
817 value.Get(mViewportPosition);
820 case Dali::RenderTask::Property::VIEWPORT_SIZE:
822 value.Get(mViewportSize);
825 case Dali::RenderTask::Property::CLEAR_COLOR:
827 value.Get(mClearColor);
830 case Dali::RenderTask::Property::REQUIRES_SYNC:
833 // Nothing to do as not animatable
844 case Dali::RenderTask::Property::VIEWPORT_POSITION:
846 AdjustValue<Vector2>(mViewportPosition, value);
849 case Dali::RenderTask::Property::VIEWPORT_SIZE:
851 AdjustValue<Vector2>(mViewportSize, value);
854 case Dali::RenderTask::Property::CLEAR_COLOR:
856 AdjustValue<Vector4>(mClearColor, value);
859 case Dali::RenderTask::Property::REQUIRES_SYNC:
862 // Nothing to do as not animatable
871 const SceneGraph::PropertyBase* RenderTask::GetSceneObjectAnimatableProperty(Property::Index index) const
873 if(!GetRenderTaskSceneObject())
878 const SceneGraph::PropertyBase* property(nullptr);
882 case Dali::RenderTask::Property::VIEWPORT_POSITION:
884 property = &GetRenderTaskSceneObject()->mViewportPosition;
887 case Dali::RenderTask::Property::VIEWPORT_SIZE:
889 property = &GetRenderTaskSceneObject()->mViewportSize;
892 case Dali::RenderTask::Property::CLEAR_COLOR:
894 property = &GetRenderTaskSceneObject()->mClearColor;
904 // not our property, ask base
905 property = Object::GetSceneObjectAnimatableProperty(index);
911 const PropertyInputImpl* RenderTask::GetSceneObjectInputProperty(Property::Index index) const
913 // animatable properties are input as well, Object::GetSceneObjectInputProperty does the same so no need to call it
914 return GetSceneObjectAnimatableProperty(index);
917 bool RenderTask::HasFinished()
919 bool finished = false;
921 if(GetRenderTaskSceneObject())
923 const uint32_t counter = GetRenderTaskSceneObject()->GetRenderedOnceCounter();
925 if(mRefreshOnceCounter < counter)
928 mRefreshOnceCounter = counter;
932 DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::HasFinished()=%s SCRT:%p SC\n", finished ? "T" : "F", GetRenderTaskSceneObject());
937 void RenderTask::EmitSignalFinish()
939 DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::EmitSignalFinish(this:%p)\n", this);
941 if(!mSignalFinished.Empty())
943 Dali::RenderTask handle(this);
944 mSignalFinished.Emit(handle);
948 Dali::RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
950 return mSignalFinished;
953 bool RenderTask::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
955 bool connected(true);
956 RenderTask* renderTask = static_cast<RenderTask*>(object); // TypeRegistry guarantees that this is the correct type.
958 if(0 == strcmp(signalName.c_str(), SIGNAL_FINISHED))
960 renderTask->FinishedSignal().Connect(tracker, functor);
964 // signalName does not match any signal
971 RenderTask::RenderTask(const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList)
972 : Object(sceneObject),
975 mViewportGuideActor(),
976 mInputMappingActor(),
977 mRenderTaskList(renderTaskList),
978 mClearColor(Dali::RenderTask::DEFAULT_CLEAR_COLOR),
979 mViewportPosition(Vector2::ZERO),
980 mViewportSize(Vector2::ZERO),
981 mRefreshRate(Dali::RenderTask::DEFAULT_REFRESH_RATE),
982 mRefreshOnceCounter(0u),
983 mScreenToFrameBufferFunction(Dali::RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION),
984 mExclusive(Dali::RenderTask::DEFAULT_EXCLUSIVE),
985 mInputEnabled(Dali::RenderTask::DEFAULT_INPUT_ENABLED),
986 mClearEnabled(Dali::RenderTask::DEFAULT_CLEAR_ENABLED),
987 mCullMode(Dali::RenderTask::DEFAULT_CULL_MODE),
990 // Set id of render task
991 mRenderTaskId = sceneObject->GetNotifyId();
993 DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::RenderTask(this:%p)\n", this);
994 // scene object handles observation of source and camera
997 RenderTask::~RenderTask()
999 if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread()))
1001 DALI_LOG_ERROR("~RenderTask[%p] called from non-UI thread! something unknown issue will be happened!\n", this);
1004 DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::~RenderTask(this:%p)\n", this);
1005 // scene object deletion is handled by our parent
1006 // scene object handles observation of source and camera
1009 } // namespace Internal