From e7304225078a7a0052ffd21c6029870ab7d6421c Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 8 Feb 2023 14:46:36 +0000 Subject: [PATCH] AnimatableProperty Set/Bake now resets properly. If animatable properties are Set/Baked from event side, then the dirty flag is never cleared. This is due to not having any PropertyResetter or NodeResetter working. It's not an issue for TransformProperties, as they have their own reset system. Added a BakerResetter to run the ResetToBaseValue() method for 1 or 2 frames, then will auto-age and die. Changed all the messaging for baking/setting animatable properties to also create and send the BakerResetter. Currently, update doesn't run again even if there are new property resetters outstanding. (Fine for constraint resetters, maybe not so fine for new BakerResetters?) To avoid cyclic dependencies, have also split the messages out into their own headers (which should also help reduce compile time) Added a test case to exercise Object internals for coverage - there are some lowkey bugs in here. [Normally, we use derived methods to link event side properties to scene-graph properties, here, we're using untested code to access component scene-graph properties. If we don't first generate the "parent" property, then the wrong type is used to generate the component properties]. We could potentially delete some of this code!!! Signed-off-by: David Steele Change-Id: I2c860a8416e71666fceb8d0b0d072c5c735655ad --- .../dali-internal/utc-Dali-Internal-Handles.cpp | 128 ++++++++- automated-tests/src/dali/utc-Dali-Actor.cpp | 21 +- automated-tests/src/dali/utc-Dali-RenderTask.cpp | 206 +++++++++++++- dali/internal/event/actors/camera-actor-impl.cpp | 1 + dali/internal/event/common/object-impl.cpp | 40 +-- .../event/render-tasks/render-task-impl.cpp | 54 +++- .../rendering/decorated-visual-renderer-impl.cpp | 20 +- dali/internal/event/rendering/renderer-impl.cpp | 14 +- .../event/rendering/visual-renderer-impl.cpp | 19 +- .../update/animation/scene-graph-animator.h | 6 +- .../update/common/animatable-property-messages.h | 171 ++++++++++++ dali/internal/update/common/animatable-property.h | 105 +------ dali/internal/update/common/double-buffered.h | 3 +- dali/internal/update/common/property-resetter.h | 72 ++++- .../update/manager/transform-manager-property.h | 14 +- dali/internal/update/nodes/node-messages.h | 24 +- .../internal/update/nodes/partial-rendering-data.h | 6 +- .../render-tasks/scene-graph-camera-messages.h | 196 +++++++++++++ .../update/render-tasks/scene-graph-camera.h | 151 ---------- .../scene-graph-render-task-messages.h | 145 ++++++++++ .../render-tasks/scene-graph-render-task.cpp | 40 +-- .../update/render-tasks/scene-graph-render-task.h | 157 +---------- .../rendering/scene-graph-renderer-messages.h | 304 +++++++++++++++++++++ .../update/rendering/scene-graph-renderer.h | 266 ------------------ 24 files changed, 1370 insertions(+), 793 deletions(-) create mode 100644 dali/internal/update/common/animatable-property-messages.h create mode 100644 dali/internal/update/render-tasks/scene-graph-camera-messages.h create mode 100644 dali/internal/update/render-tasks/scene-graph-render-task-messages.h create mode 100644 dali/internal/update/rendering/scene-graph-renderer-messages.h diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp index 8c0a0ac..87d8fd0 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp @@ -17,11 +17,16 @@ #include #include -#include +#include +#include #include // Internal headers are allowed here +#include // Dali::Internal::Object +#include +#include +#include using namespace Dali; @@ -45,3 +50,124 @@ int UtcDaliCameraActorConstructorRefObject(void) DALI_TEST_CHECK(!actor); END_TEST; } + +namespace Impl +{ +struct DerivedRenderer : public Dali::Internal::Renderer +{ + static IntrusivePtr New() + { + auto sceneObjectKey = Dali::Internal::SceneGraph::Renderer::NewKey(); + IntrusivePtr impl = new DerivedRenderer(sceneObjectKey.Get()); + + // transfer scene object ownership to update manager + Internal::EventThreadServices& eventThreadServices = impl->GetEventThreadServices(); + Internal::SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager(); + AddRendererMessage(updateManager, sceneObjectKey); + eventThreadServices.RegisterObject(impl.Get()); + return impl; + } + + DerivedRenderer(const Dali::Internal::SceneGraph::Renderer* sceneObject) + : Internal::Renderer(sceneObject) + { + } + ~DerivedRenderer() + { + } +}; +} // namespace Impl + +struct DerivedRenderer : public Renderer +{ + static DerivedRenderer New(Geometry geometry, Shader shader) + { + IntrusivePtr impl = Impl::DerivedRenderer::New(); + impl->SetGeometry(GetImplementation(geometry)); + impl->SetShader(GetImplementation(shader)); + DerivedRenderer custom(impl.Get()); + return custom; + } + DerivedRenderer() = default; + ~DerivedRenderer() = default; + DerivedRenderer(Impl::DerivedRenderer* impl) + : Renderer(impl) + { + } +}; + +int UtcDaliInternalHandleRendererPropertyComponents(void) +{ + TestApplication application; + + Dali::TypeRegistration typeRegistration(typeid(DerivedRenderer), typeid(Dali::Renderer), nullptr); + + Shader shader = Shader::New("VertexSource", "FragmentSource"); + Geometry geometry = CreateQuadGeometry(); + auto derived = DerivedRenderer::New(geometry, shader); + Actor actor = Actor::New(); + actor.AddRenderer(derived); + application.GetScene().Add(actor); + + const Property::Index foobarIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX; + const Property::Index fooIndex = foobarIndex + 1; + const Property::Index barIndex = foobarIndex + 2; + + const Property::Index rgbIndex = foobarIndex + 3; + const Property::Index redIndex = rgbIndex + 1; + const Property::Index greenIndex = rgbIndex + 2; + const Property::Index blueIndex = rgbIndex + 3; + + const Property::Index rgbaIndex = rgbIndex + 4; + const Property::Index red2Index = rgbaIndex + 1; + const Property::Index green2Index = rgbaIndex + 2; + const Property::Index blue2Index = rgbaIndex + 3; + const Property::Index alphaIndex = rgbaIndex + 4; + + // If we don't properly register a scene graph property for the "parent" type, + // then Object::GetSceneGraphProperty registers a float type for the child... + + AnimatablePropertyRegistration(typeRegistration, "Foobar", foobarIndex, Vector2(10.0f, 20.0f)); + AnimatablePropertyComponentRegistration(typeRegistration, "Foobar.x", fooIndex, foobarIndex, 0); + AnimatablePropertyComponentRegistration(typeRegistration, "Foobar.y", barIndex, foobarIndex, 1); + + AnimatablePropertyRegistration(typeRegistration, "RGB", rgbIndex, Vector3(0.5f, 0.5, 1.0f)); + AnimatablePropertyComponentRegistration(typeRegistration, "RGB.red", redIndex, rgbIndex, 0); + AnimatablePropertyComponentRegistration(typeRegistration, "RGB.green", greenIndex, rgbIndex, 1); + AnimatablePropertyComponentRegistration(typeRegistration, "RGB.blue", blueIndex, rgbIndex, 2); + + AnimatablePropertyRegistration(typeRegistration, "RGBA", rgbaIndex, Vector4(0.5f, 0.5, 1.0f, 1.0f)); + AnimatablePropertyComponentRegistration(typeRegistration, "RGBA.red", red2Index, rgbaIndex, 0); + AnimatablePropertyComponentRegistration(typeRegistration, "RGBA.green", green2Index, rgbaIndex, 1); + AnimatablePropertyComponentRegistration(typeRegistration, "RGBA.blue", blue2Index, rgbaIndex, 2); + AnimatablePropertyComponentRegistration(typeRegistration, "RGBA.alpha", alphaIndex, rgbaIndex, 3); + + derived.SetProperty(foobarIndex, Vector2(9.0f, 10.0f)); + derived.SetProperty(fooIndex, 100.0f); + derived.SetProperty(barIndex, 200.0f); + + derived.SetProperty(rgbIndex, Vector3(0.9f, 0.9f, 0.1f)); + derived.SetProperty(redIndex, 1.0f); + derived.SetProperty(greenIndex, 1.0f); + derived.SetProperty(blueIndex, 1.0f); + + derived.SetProperty(rgbaIndex, Color::WHITE * 0.5f); + derived.SetProperty(red2Index, Color::SEA_GREEN.r); + derived.SetProperty(green2Index, Color::SEA_GREEN.g); + derived.SetProperty(blue2Index, Color::SEA_GREEN.b); + derived.SetProperty(alphaIndex, Color::SEA_GREEN.a); + + application.SendNotification(); + application.Render(16); + + Vector2 foobar = derived.GetCurrentProperty(foobarIndex); + DALI_TEST_EQUALS(foobar, Vector2(100.0f, 200.0f), 0.0001f, TEST_LOCATION); + + Vector3 colour = derived.GetCurrentProperty(rgbIndex); + DALI_TEST_EQUALS(colour, Vector3(1.0f, 1.0f, 1.0f), 0.0001f, TEST_LOCATION); + + Vector4 col2 = derived.GetCurrentProperty(rgbaIndex); + DALI_TEST_EQUALS(col2, Color::SEA_GREEN, 0.0001f, TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 92a7a0a..4413115 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -11887,8 +11887,9 @@ int UtcDaliActorCalculateWorldColor01(void) branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - rootActor[Actor::Property::COLOR] = Color::WHITE; - branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f); + rootActor[Actor::Property::COLOR] = Color::WHITE; + Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f); + branchActor[Actor::Property::COLOR] = testColor1; leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f); // Default is to inherit: @@ -11899,9 +11900,21 @@ int UtcDaliActorCalculateWorldColor01(void) branchActor.Add(leafActor); application.SendNotification(); - application.Render(0); + application.Render(16); + Vector4 color = branchActor.GetCurrentProperty(Actor::Property::COLOR); + DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION); - Vector4 color = DevelActor::GetWorldColor(leafActor); + application.SendNotification(); + application.Render(16); + color = branchActor.GetCurrentProperty(Actor::Property::COLOR); + DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION); + + application.SendNotification(); + application.Render(16); + color = branchActor.GetCurrentProperty(Actor::Property::COLOR); + DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION); + + color = DevelActor::GetWorldColor(leafActor); Vector4 actualColor = leafActor.GetCurrentProperty(Actor::Property::WORLD_COLOR); DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION); diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index af93507..cbdee4a 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -3685,6 +3685,210 @@ int UtcDaliRenderTaskViewportGuideActor02(void) END_TEST; } +int UtcDaliRenderTaskViewportGuideActor03(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& callStack = glAbstraction.GetViewportTrace(); + glAbstraction.EnableViewportCallTrace(true); + tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport"); + + Stage stage = Stage::GetCurrent(); + Vector2 stageSize(stage.GetSize()); + + // Render and notify + application.SendNotification(); + application.Render(16); + glAbstraction.ResetViewportCallStack(); + + Geometry geometry = Geometry::New(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + + Actor blue = Actor::New(); + blue[Dali::Actor::Property::NAME] = "Blue"; + blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + blue[Dali::Actor::Property::SIZE] = Vector2(400, 300); + blue[Dali::Actor::Property::POSITION] = Vector2(100, 50); + blue.AddRenderer(renderer); + stage.Add(blue); + + Actor green = Actor::New(); + green[Dali::Actor::Property::NAME] = "Green"; + green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + green[Dali::Actor::Property::SIZE] = Vector2(400, 300); + green[Dali::Actor::Property::POSITION] = Vector2(100, 50); + green.AddRenderer(renderer); + stage.Add(green); + + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + RenderTask renderTask = renderTaskList.CreateTask(); + + Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize); + cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + stage.Add(cameraActor); + + renderTask.SetExclusive(true); + renderTask.SetInputEnabled(true); + renderTask.SetCameraActor(cameraActor); + renderTask.SetSourceActor(green); + + Viewport viewport(75, 55, 150, 250); + renderTask.SetViewport(viewport); + + // Render and notify + application.SendNotification(); + application.Render(16); + + // Note Y pos: 800 - (250+55) = 495 + std::string viewportParams1("75, 495, 150, 250"); + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0); + glAbstraction.ResetViewportCallStack(); + + // Update to use viewport guide actor instead. + renderTask.SetViewportGuideActor(blue); + + // Render and notify + application.SendNotification(); + application.Render(16); + + // Note: Y pos: 800 - (300+50) = 450 + std::string viewportParams2("100, 450, 400, 300"); + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0); + tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport"); + glAbstraction.ResetViewportCallStack(); + + // Remove guide actor, expect that the viewport is reset to its original values + renderTask.SetViewportGuideActor(Actor()); + application.SendNotification(); + application.Render(16); + + // Currently, update manager does not consider that added Resetters should cause another + // update; this is probably right. But, we have to then force another update for the resetter to trigger, and this will register as un-necessary in the test output. + // + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0); + + END_TEST; +} + +int UtcDaliRenderTaskViewportGuideActor04(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& callStack = glAbstraction.GetViewportTrace(); + glAbstraction.EnableViewportCallTrace(true); + tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport"); + + Stage stage = Stage::GetCurrent(); + Vector2 stageSize(stage.GetSize()); + + // Render and notify + application.SendNotification(); + application.Render(16); + glAbstraction.ResetViewportCallStack(); + + Geometry geometry = Geometry::New(); + Shader shader = Shader::New("vertexSrc", "fragmentSrc"); + Renderer renderer = Renderer::New(geometry, shader); + + Actor blue = Actor::New(); + blue[Dali::Actor::Property::NAME] = "Blue"; + blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + blue[Dali::Actor::Property::SIZE] = Vector2(400, 300); + blue[Dali::Actor::Property::POSITION] = Vector2(100, 50); + blue.AddRenderer(renderer); + stage.Add(blue); + + Actor green = Actor::New(); + green[Dali::Actor::Property::NAME] = "Green"; + green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + green[Dali::Actor::Property::SIZE] = Vector2(400, 300); + green[Dali::Actor::Property::POSITION] = Vector2(100, 50); + green.AddRenderer(renderer); + stage.Add(green); + + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + RenderTask renderTask = renderTaskList.CreateTask(); + + Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize); + cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + stage.Add(cameraActor); + + renderTask.SetExclusive(true); + renderTask.SetInputEnabled(true); + renderTask.SetCameraActor(cameraActor); + renderTask.SetSourceActor(green); + + Viewport viewport(75, 55, 150, 250); + renderTask.SetViewport(viewport); + + // Render and notify + application.SendNotification(); + application.Render(16); + + // Note Y pos: 800 - (250+55) = 495 + std::string viewportParams1("75, 495, 150, 250"); + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0); + glAbstraction.ResetViewportCallStack(); + + // Update to use viewport guide actor instead. + renderTask.SetViewportGuideActor(blue); + + // Render and notify + application.SendNotification(); + application.Render(16); + + std::string viewportParams2("100, 450, 400, 300"); + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0); + tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport"); + + glAbstraction.ResetViewportCallStack(); + + // Remove guide actor, expect that the viewport is reset to it's original values + renderTask.ResetViewportGuideActor(); + application.SendNotification(); + application.Render(16); + + // Currently, update manager does not consider that added Resetters should cause another + // update; this is probably right. But, we have to then force another update for the resetter + // to trigger, and this will register as un-necessary in the test output. + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0); + + // This should remove the baking resetters, but is again going to show up + // as unnecessary. Also try and figure out if we can test the dirty flags + // here, somehow (Can at least check the property's dirty flags in the debugger). + application.SendNotification(); + application.Render(16); + + END_TEST; +} + int UtcDaliRenderTaskSetPartialUpdate(void) { TestApplication application( diff --git a/dali/internal/event/actors/camera-actor-impl.cpp b/dali/internal/event/actors/camera-actor-impl.cpp index f714d74..beefc38 100644 --- a/dali/internal/event/actors/camera-actor-impl.cpp +++ b/dali/internal/event/actors/camera-actor-impl.cpp @@ -32,6 +32,7 @@ #include #include +#include namespace Dali { diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index da251d7..ce584da 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -36,6 +36,8 @@ #include #include +#include + using Dali::Internal::SceneGraph::AnimatableProperty; using Dali::Internal::SceneGraph::PropertyBase; @@ -1464,7 +1466,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } @@ -1474,7 +1476,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } @@ -1484,7 +1486,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } @@ -1496,15 +1498,15 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata // property is being used in a separate thread; queue a message to set the property if(entry.componentIndex == 0) { - SetXComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetXComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 1) { - SetYComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetYComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else { - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } break; } @@ -1517,19 +1519,19 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata // property is being used in a separate thread; queue a message to set the property if(entry.componentIndex == 0) { - SetXComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetXComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 1) { - SetYComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetYComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 2) { - SetZComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetZComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else { - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } break; @@ -1543,23 +1545,23 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata // property is being used in a separate thread; queue a message to set the property if(entry.componentIndex == 0) { - SetXComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetXComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 1) { - SetYComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetYComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 2) { - SetZComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetZComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else if(entry.componentIndex == 3) { - SetWComponentMessage(GetEventThreadServices(), *property, value.Get()); + SetWComponentMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } else { - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); } break; } @@ -1570,7 +1572,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } @@ -1580,7 +1582,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } @@ -1590,7 +1592,7 @@ void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata DALI_ASSERT_DEBUG(property); // property is being used in a separate thread; queue a message to set the property - BakeMessage(GetEventThreadServices(), *property, value.Get()); + BakeMessage(GetEventThreadServices(), *mUpdateObject, *property, value.Get()); break; } diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index d0032dd..cac0ab8 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -30,7 +30,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -210,13 +212,32 @@ Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const void RenderTask::SetViewportGuideActor(Actor* actor) { mViewportGuideActor.SetActor(actor); + + auto& sceneObject = GetRenderTaskSceneObject(); + auto& eventThreadServices = GetEventThreadServices(); + auto& updateManager = eventThreadServices.GetUpdateManager(); + if(actor) { - SetViewportGuideNodeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), &actor->GetNode()); + SetViewportGuideNodeMessage(eventThreadServices, sceneObject, &actor->GetNode()); } else { - SetViewportGuideNodeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr); + // Ensure that if the node is removed through this API, that the + // viewport values are set back to their base value and that their dirty + // flags are cleared after 1 frame. + SetViewportGuideNodeMessage(eventThreadServices, sceneObject, nullptr); + + auto renderTask = const_cast(&sceneObject); + auto viewportPositionProperty = const_cast*>(&renderTask->mViewportPosition); + auto viewportSizeProperty = const_cast*>(&renderTask->mViewportSize); + + OwnerPointer resetter1( + new SceneGraph::BakerResetter(renderTask, viewportPositionProperty, SceneGraph::BakerResetter::Lifetime::SET)); + OwnerPointer resetter2( + new SceneGraph::BakerResetter(renderTask, viewportSizeProperty, SceneGraph::BakerResetter::Lifetime::SET)); + AddResetterMessage(updateManager, resetter1); + AddResetterMessage(updateManager, resetter2); } } @@ -227,17 +248,26 @@ Actor* RenderTask::GetViewportGuideActor() const void RenderTask::ResetViewportGuideActor() { - SetViewportGuideActor(nullptr); + // Don't re-use the SetViewportGuideActor method for this task - the bake messages below will create their own resetters. + mViewportGuideActor.SetActor(nullptr); + SetViewportGuideNodeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr); - BakeViewportPositionMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), mViewportPosition); - BakeViewportSizeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), mViewportSize); + EventThreadServices& eventThreadServices = GetEventThreadServices(); + auto renderTask = const_cast(&GetRenderTaskSceneObject()); + auto viewportPositionProperty = const_cast*>(&renderTask->mViewportPosition); + auto viewportSizeProperty = const_cast*>(&renderTask->mViewportSize); + BakeMessage(eventThreadServices, *renderTask, *viewportPositionProperty, mViewportPosition); + BakeMessage(eventThreadServices, *renderTask, *viewportSizeProperty, mViewportSize); } void RenderTask::SetViewportPosition(const Vector2& value) { mViewportPosition = value; - BakeViewportPositionMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), value); + EventThreadServices& eventThreadServices = GetEventThreadServices(); + auto renderTask = const_cast(&GetRenderTaskSceneObject()); + auto viewportPositionProperty = const_cast*>(&renderTask->mViewportPosition); + BakeMessage(eventThreadServices, *renderTask, *viewportPositionProperty, mViewportPosition); } Vector2 RenderTask::GetCurrentViewportPosition() const @@ -249,7 +279,10 @@ void RenderTask::SetViewportSize(const Vector2& value) { mViewportSize = value; - BakeViewportSizeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), value); + EventThreadServices& eventThreadServices = GetEventThreadServices(); + auto renderTask = const_cast(&GetRenderTaskSceneObject()); + auto viewportSizeProperty = const_cast*>(&renderTask->mViewportSize); + BakeMessage(eventThreadServices, *renderTask, *viewportSizeProperty, mViewportSize); } Vector2 RenderTask::GetCurrentViewportSize() const @@ -303,7 +336,10 @@ void RenderTask::SetClearColor(const Vector4& color) mClearColor = color; // scene object is being used in a separate thread; queue a message to set the value - BakeClearColorMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), color); + EventThreadServices& eventThreadServices = GetEventThreadServices(); + auto renderTask = const_cast(&GetRenderTaskSceneObject()); + auto clearColorProperty = const_cast*>(&renderTask->mClearColor); + BakeMessage(eventThreadServices, *renderTask, *clearColorProperty, mClearColor); } } diff --git a/dali/internal/event/rendering/decorated-visual-renderer-impl.cpp b/dali/internal/event/rendering/decorated-visual-renderer-impl.cpp index ee879f1c..f68862d 100644 --- a/dali/internal/event/rendering/decorated-visual-renderer-impl.cpp +++ b/dali/internal/event/rendering/decorated-visual-renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -23,6 +23,8 @@ #include #include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END #include +#include +#include #include #include #include @@ -61,11 +63,11 @@ TypeRegistration mType(typeid(Dali::DecoratedVisualRenderer), typeid(Dali::Visua * @param animatableProperty The animatable property to set on the update-thread */ template -void SetValue(EventThreadServices& eventThreadServices, const Property::Value& propertyValue, T& cachedValue, const SceneGraph::AnimatableProperty& animatableProperty) +void SetValue(EventThreadServices& eventThreadServices, const SceneGraph::PropertyOwner& propertyOwner, const Property::Value& propertyValue, T& cachedValue, const SceneGraph::AnimatableProperty& animatableProperty) { if(propertyValue.Get(cachedValue)) { - BakeMessage(eventThreadServices, animatableProperty, cachedValue); + BakeMessage(eventThreadServices, propertyOwner, animatableProperty, cachedValue); } } @@ -131,37 +133,37 @@ void DecoratedVisualRenderer::SetDefaultProperty(Property::Index index, { case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mCornerRadius, decoratedVisualProperties->mCornerRadius); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mCornerRadius, decoratedVisualProperties->mCornerRadius); break; } case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mCornerRadiusPolicy, decoratedVisualProperties->mCornerRadiusPolicy); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mCornerRadiusPolicy, decoratedVisualProperties->mCornerRadiusPolicy); break; } case Dali::DecoratedVisualRenderer::Property::BORDERLINE_WIDTH: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mBorderlineWidth, decoratedVisualProperties->mBorderlineWidth); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mBorderlineWidth, decoratedVisualProperties->mBorderlineWidth); break; } case Dali::DecoratedVisualRenderer::Property::BORDERLINE_COLOR: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mBorderlineColor, decoratedVisualProperties->mBorderlineColor); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mBorderlineColor, decoratedVisualProperties->mBorderlineColor); break; } case Dali::DecoratedVisualRenderer::Property::BORDERLINE_OFFSET: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mBorderlineOffset, decoratedVisualProperties->mBorderlineOffset); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mBorderlineOffset, decoratedVisualProperties->mBorderlineOffset); break; } case Dali::DecoratedVisualRenderer::Property::BLUR_RADIUS: { - SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mBlurRadius, decoratedVisualProperties->mBlurRadius); + SetValue(eventThreadServices, *mUpdateObject, propertyValue, mDecoratedPropertyCache.mBlurRadius, decoratedVisualProperties->mBlurRadius); break; } } diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index ace6e68..5dbcab4 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -663,8 +664,15 @@ void Renderer::SetDefaultProperty(Property::Index index, { if(!Equals(mOpacity, opacity)) { - mOpacity = opacity; - BakeOpacityMessage(GetEventThreadServices(), GetRendererSceneObject(), mOpacity); + mOpacity = opacity; + auto sceneObject = const_cast(&GetRendererSceneObject()); + SceneGraph::BakeOpacityMessage(GetEventThreadServices(), *sceneObject, mOpacity); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(sceneObject, + &sceneObject->mOpacity, + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(GetEventThreadServices().GetUpdateManager(), resetter); } } break; diff --git a/dali/internal/event/rendering/visual-renderer-impl.cpp b/dali/internal/event/rendering/visual-renderer-impl.cpp index 9c8f008..62a78ac 100644 --- a/dali/internal/event/rendering/visual-renderer-impl.cpp +++ b/dali/internal/event/rendering/visual-renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -23,6 +23,7 @@ #include #include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END #include +#include #include #include #include @@ -119,7 +120,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mTransformOffset, mPropertyCache.mTransformOffset); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mTransformOffset, mPropertyCache.mTransformOffset); } } break; @@ -133,7 +134,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mTransformSize, mPropertyCache.mTransformSize); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mTransformSize, mPropertyCache.mTransformSize); } } break; @@ -146,7 +147,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mTransformOrigin, mPropertyCache.mTransformOrigin); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mTransformOrigin, mPropertyCache.mTransformOrigin); } } break; @@ -159,7 +160,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mTransformAnchorPoint, mPropertyCache.mTransformAnchorPoint); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mTransformAnchorPoint, mPropertyCache.mTransformAnchorPoint); } } break; @@ -172,7 +173,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mTransformOffsetSizeMode, mPropertyCache.mTransformOffsetSizeMode); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mTransformOffsetSizeMode, mPropertyCache.mTransformOffsetSizeMode); } } break; @@ -185,7 +186,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mExtraSize, mPropertyCache.mExtraSize); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mExtraSize, mPropertyCache.mExtraSize); } } break; @@ -198,7 +199,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, auto visualProperties = sceneObject.GetVisualProperties(); if(visualProperties) { - BakeMessage(GetEventThreadServices(), visualProperties->mMixColor, mPropertyCache.mMixColor); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mMixColor, mPropertyCache.mMixColor); } } break; @@ -215,7 +216,7 @@ void VisualRenderer::SetDefaultProperty(Property::Index index, if(visualProperties) { mPropertyCache.mPreMultipliedAlpha = preMultipliedAlpha; - BakeMessage(GetEventThreadServices(), visualProperties->mPreMultipliedAlpha, preMultipliedAlpha); + BakeMessage(GetEventThreadServices(), *mUpdateObject, visualProperties->mPreMultipliedAlpha, preMultipliedAlpha); } } } diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h index 7be4a13..391bacf 100644 --- a/dali/internal/update/animation/scene-graph-animator.h +++ b/dali/internal/update/animation/scene-graph-animator.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H /* - * 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. @@ -23,13 +23,11 @@ #include // INTERNAL INCLUDES -#include -#include #include #include #include #include -#include +#include #include #include #include diff --git a/dali/internal/update/common/animatable-property-messages.h b/dali/internal/update/common/animatable-property-messages.h new file mode 100644 index 0000000..57ce8d0 --- /dev/null +++ b/dali/internal/update/common/animatable-property-messages.h @@ -0,0 +1,171 @@ +#ifndef DALI_INTERNAL_COMMON_ANIMATABLE_PROPERTY_MESSAGES_H +#define DALI_INTERNAL_COMMON_ANIMATABLE_PROPERTY_MESSAGES_H + +/* + * 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. + * 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. + */ + +#include +#include +#include +#include +#include +#include + +namespace Dali::Internal +{ +// Messages for AnimatableProperty + +template +void BakeMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + typename ParameterType::PassingType newValue) +{ + using LocalType = MessageDoubleBuffered1, T>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::Bake, + newValue); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +template +void BakeRelativeMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + const T& delta) +{ + using LocalType = MessageDoubleBuffered1, const T&>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::BakeRelative, + delta); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +template +void SetXComponentMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + typename ParameterType::PassingType newValue) +{ + using LocalType = MessageDoubleBuffered1, float>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::BakeX, + newValue); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +template +void SetYComponentMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + typename ParameterType::PassingType newValue) +{ + using LocalType = MessageDoubleBuffered1, float>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::BakeY, + newValue); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +template +void SetZComponentMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + typename ParameterType::PassingType newValue) +{ + using LocalType = MessageDoubleBuffered1, float>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::BakeZ, + newValue); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +template +void SetWComponentMessage(EventThreadServices& eventThreadServices, + const SceneGraph::PropertyOwner& propertyOwner, + const SceneGraph::AnimatableProperty& property, + typename ParameterType::PassingType newValue) +{ + using LocalType = MessageDoubleBuffered1, float>; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&property, + &SceneGraph::AnimatableProperty::BakeW, + newValue); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&propertyOwner), + const_cast*>(&property), + SceneGraph::BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +} // namespace Dali::Internal + +#endif //DALI_INTERNAL_COMMON_ANIMATABLE_PROPERTY_MESSAGES_H diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index 7bc5831..949fec7 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H /* - * Copyright (c) 2022 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. @@ -23,12 +23,9 @@ // INTERNAL INCLUDES #include -#include -#include -#include + #include #include -#include #include #include #include @@ -2074,104 +2071,6 @@ private: } // namespace SceneGraph -// Messages for AnimatableProperty - -template -void BakeMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType::PassingType newValue) -{ - using LocalType = MessageDoubleBuffered1, T>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::Bake, - newValue); -} - -template -void BakeRelativeMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - const T& delta) -{ - using LocalType = MessageDoubleBuffered1, const T&>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::BakeRelative, - delta); -} - -template -void SetXComponentMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType::PassingType newValue) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::BakeX, - newValue); -} - -template -void SetYComponentMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType::PassingType newValue) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::BakeY, - newValue); -} - -template -void SetZComponentMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType::PassingType newValue) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::BakeZ, - newValue); -} - -template -void SetWComponentMessage(EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType::PassingType newValue) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&property, - &SceneGraph::AnimatableProperty::BakeW, - newValue); -} - } // namespace Internal } // namespace Dali diff --git a/dali/internal/update/common/double-buffered.h b/dali/internal/update/common/double-buffered.h index 53a5cad..65f7cd6 100644 --- a/dali/internal/update/common/double-buffered.h +++ b/dali/internal/update/common/double-buffered.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H /* - * 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. @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include namespace Dali diff --git a/dali/internal/update/common/property-resetter.h b/dali/internal/update/common/property-resetter.h index 5be8ca2..ddbc110 100644 --- a/dali/internal/update/common/property-resetter.h +++ b/dali/internal/update/common/property-resetter.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENEGRAPH_PROPERTY_RESETTER_H /* - * 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. @@ -66,7 +66,7 @@ public: * Reset the property to it's base value if the property owner is still alive and on stage * @param[in] updateBufferIndex the current buffer index */ - void ResetToBaseValue(BufferIndex updateBufferIndex) + virtual void ResetToBaseValue(BufferIndex updateBufferIndex) { if(mPropertyOwner != nullptr && mActive) { @@ -131,15 +131,9 @@ public: */ virtual bool IsFinished() { - bool finished = mRunning <= STOPPED; - if(mRunning == AGING) - { - mRunning = STOPPED; - } - return finished; + return mRunning <= STOPPED; } -protected: enum { STOPPED = 0, @@ -147,6 +141,7 @@ protected: ACTIVE = 2, }; +protected: /** * Constructor * @@ -170,6 +165,65 @@ protected: bool mDisconnected; ///< True if the property owner has been disconnected }; +class BakerResetter : public PropertyResetterBase +{ +public: + enum class Lifetime + { + BAKE, + SET + }; + + /** + * New method. + * @param[in] propertyOwner The owner of the property + * @param[in] baseProperty The property being animated + * @param[in] lifetime How long this resetter stays alive (1 or 2 frames) + * @return the new property resetter + */ + static PropertyResetterBase* New(const PropertyOwner& propertyOwner, + const PropertyBase& baseProperty, + Lifetime lifetime) + { + return new BakerResetter(const_cast(&propertyOwner), + const_cast(&baseProperty), + lifetime); + } + + /** + * Constructor + * @param[in] propertyOwner The owner of the property + * @param[in] baseProperty The property being animated + * @param[in] lifetime How many frames this stays alive for + */ + BakerResetter(PropertyOwner* propertyOwner, + PropertyBase* baseProperty, + Lifetime lifetime) + : PropertyResetterBase(propertyOwner, baseProperty) + { + mRunning = lifetime == Lifetime::BAKE ? ACTIVE : AGING; + } + + /** + * Virtual destructor. + */ + ~BakerResetter() override = default; + + /** + * @param updateBufferIndex + */ + void ResetToBaseValue(BufferIndex updateBufferIndex) override + { + if(mPropertyOwner && mRunning > 0) + { + mRunning--; + mBaseProperty->ResetToBaseValue(updateBufferIndex); + + // @todo Consider adding mPropertyOwner->SetUpdated(true) here. + } + } +}; + /** * Specialization of Resetter based on templated modifier type (either Constraint or Animator) */ diff --git a/dali/internal/update/manager/transform-manager-property.h b/dali/internal/update/manager/transform-manager-property.h index 3c11242..b9600bd 100644 --- a/dali/internal/update/manager/transform-manager-property.h +++ b/dali/internal/update/manager/transform-manager-property.h @@ -1,8 +1,8 @@ -#ifndef TRANSFORM_MANAGER_PROPERTY_H_ -#define TRANSFORM_MANAGER_PROPERTY_H_ +#ifndef DALI_INTERNAL_UPDATE_TRANSFORM_MANAGER_PROPERTY_H +#define DALI_INTERNAL_UPDATE_TRANSFORM_MANAGER_PROPERTY_H /* - * Copyright (c) 2022 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. @@ -463,7 +463,7 @@ public: } private: - TransformManagerVector3Input(const TransformManagerVector3Input& property) = delete; + TransformManagerVector3Input(const TransformManagerVector3Input& property) = delete; TransformManagerVector3Input& operator=(const TransformManagerVector3Input& rhs) = delete; public: @@ -603,7 +603,7 @@ public: } private: - TransformManagerQuaternionInput(const TransformManagerQuaternionInput& property) = delete; + TransformManagerQuaternionInput(const TransformManagerQuaternionInput& property) = delete; TransformManagerQuaternionInput& operator=(const TransformManagerQuaternionInput& rhs) = delete; public: @@ -736,7 +736,7 @@ public: } private: - TransformManagerMatrixInput(const TransformManagerMatrixInput& property) = delete; + TransformManagerMatrixInput(const TransformManagerMatrixInput& property) = delete; TransformManagerMatrixInput& operator=(const TransformManagerMatrixInput& rhs) = delete; }; @@ -744,4 +744,4 @@ private: } // namespace Internal } // namespace Dali -#endif // TRANSFORM_MANAGER_PROPERTY_H_ +#endif // DALI_INTERNAL_UPDATE_TRANSFORM_MANAGER_PROPERTY_H diff --git a/dali/internal/update/nodes/node-messages.h b/dali/internal/update/nodes/node-messages.h index a866119..340559e 100644 --- a/dali/internal/update/nodes/node-messages.h +++ b/dali/internal/update/nodes/node-messages.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H /* - * 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. @@ -82,8 +82,17 @@ public: // Reserve some memory inside the message queue uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodePropertyMessage)); + auto& updateManager = eventThreadServices.GetUpdateManager(); + // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) NodePropertyMessage(eventThreadServices.GetUpdateManager(), node, property, member, value); + new(slot) NodePropertyMessage(updateManager, node, property, member, value); + + // Non-transform property doesn't get reset. Add a resetter. + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(node), + const_cast*>(property), + BakerResetter::Lifetime::BAKE)); + AddResetterMessage(updateManager, resetter); } /** @@ -158,8 +167,17 @@ public: // Reserve some memory inside the message queue uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodePropertyComponentMessage)); + auto& updateManager = eventThreadServices.GetUpdateManager(); + // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) NodePropertyComponentMessage(eventThreadServices.GetUpdateManager(), node, property, member, value); + new(slot) NodePropertyComponentMessage(updateManager, node, property, member, value); + + // Non-transform property doesn't get reset. Add a resetter. + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(node), + const_cast*>(property), + BakerResetter::Lifetime::BAKE)); + AddResetterMessage(updateManager, resetter); } /** diff --git a/dali/internal/update/nodes/partial-rendering-data.h b/dali/internal/update/nodes/partial-rendering-data.h index 5d7f943..c099b03 100644 --- a/dali/internal/update/nodes/partial-rendering-data.h +++ b/dali/internal/update/nodes/partial-rendering-data.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_PARTIAL_RENDERING_DATA_H /* - * Copyright (c) 2022 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. @@ -17,16 +17,12 @@ * limitations under the License. */ -#include #include #include #include namespace Dali::Internal::SceneGraph { -class Node; -class TextureSet; - /** * Structure contains partial rendering data used in order to determine * whether anything has changed and node has to be updated diff --git a/dali/internal/update/render-tasks/scene-graph-camera-messages.h b/dali/internal/update/render-tasks/scene-graph-camera-messages.h new file mode 100644 index 0000000..5ff3e8d --- /dev/null +++ b/dali/internal/update/render-tasks/scene-graph-camera-messages.h @@ -0,0 +1,196 @@ +#ifndef DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H +#define DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H + +/* + * 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. + * 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. + */ + +#include +#include +#include +#include +#include + +namespace Dali::Internal +{ +// value types used by messages +template<> +struct ParameterType +: public BasicType +{ +}; + +template<> +struct ParameterType +: public BasicType +{ +}; + +namespace SceneGraph +{ +inline void SetTypeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetType, parameter); +} + +inline void SetProjectionModeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter) +{ + using LocalProjectionMode = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionMode)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalProjectionMode(&camera, &Camera::SetProjectionMode, parameter); +} + +inline void SetProjectionDirectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::DevelCameraActor::ProjectionDirection parameter) +{ + using LocalProjectionDirection = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionDirection)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalProjectionDirection(&camera, &Camera::SetProjectionDirection, parameter); +} + +inline void BakeFieldOfViewMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) +{ + using LocalType = MessageDoubleBuffered1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::BakeFieldOfView, parameter); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&camera), + const_cast*>(&camera.mFieldOfView), + BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +inline void BakeOrthographicSizeMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) +{ + using LocalType = MessageDoubleBuffered1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::BakeOrthographicSize, parameter); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&camera), + const_cast*>(&camera.mOrthographicSize), + BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +inline void BakeAspectRatioMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) +{ + using LocalType = MessageDoubleBuffered1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::BakeAspectRatio, parameter); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&camera), + const_cast*>(&camera.mAspectRatio), + BakerResetter::Lifetime::BAKE)); + AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetNearClippingPlane, parameter); +} + +inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetFarClippingPlane, parameter); +} + +inline void SetReflectByPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector4& plane) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetReflectByPlane, plane); +} + +inline void SetTargetPositionMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetTargetPosition, parameter); +} + +inline void SetInvertYAxisMessage(EventThreadServices& eventThreadServices, const Camera& camera, bool parameter) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::SetInvertYAxis, parameter); +} + +inline void RotateProjectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, int parameter) +{ + typedef MessageValue1 LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&camera, &Camera::RotateProjection, parameter); +} + +} // namespace SceneGraph +} // namespace Dali::Internal + +#endif //DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H diff --git a/dali/internal/update/render-tasks/scene-graph-camera.h b/dali/internal/update/render-tasks/scene-graph-camera.h index 278d765..e779f49 100644 --- a/dali/internal/update/render-tasks/scene-graph-camera.h +++ b/dali/internal/update/render-tasks/scene-graph-camera.h @@ -20,9 +20,6 @@ // INTERNAL INCLUDES #include -#include -#include -#include #include #include #include @@ -34,18 +31,6 @@ namespace Dali { namespace Internal { -// value types used by messages -template<> -struct ParameterType -: public BasicType -{ -}; -template<> -struct ParameterType -: public BasicType -{ -}; - namespace SceneGraph { class SceneController; @@ -416,144 +401,8 @@ public: // PROPERTIE DoubleBuffered mFinalProjection; ///< Final projection matrix; double buffered for input handling }; -// Messages for Camera - -inline void SetTypeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetType, parameter); -} - -inline void SetProjectionModeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter) -{ - using LocalProjectionMode = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionMode)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalProjectionMode(&camera, &Camera::SetProjectionMode, parameter); -} - -inline void SetProjectionDirectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::DevelCameraActor::ProjectionDirection parameter) -{ - using LocalProjectionDirection = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionDirection)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalProjectionDirection(&camera, &Camera::SetProjectionDirection, parameter); -} - -inline void BakeFieldOfViewMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::BakeFieldOfView, parameter); -} - -inline void BakeOrthographicSizeMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::BakeOrthographicSize, parameter); -} - -inline void BakeAspectRatioMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::BakeAspectRatio, parameter); -} - -inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetNearClippingPlane, parameter); -} - -inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetFarClippingPlane, parameter); -} - -inline void SetReflectByPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector4& plane) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetReflectByPlane, plane); -} - -inline void SetTargetPositionMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetTargetPosition, parameter); -} - -inline void SetInvertYAxisMessage(EventThreadServices& eventThreadServices, const Camera& camera, bool parameter) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::SetInvertYAxis, parameter); -} - -inline void RotateProjectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, int parameter) -{ - typedef MessageValue1 LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&camera, &Camera::RotateProjection, parameter); -} - } // namespace SceneGraph - } // namespace Internal - } // namespace Dali #endif // DALI_INTERNAL_SCENE_GRAPH_CAMERA_H diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-messages.h b/dali/internal/update/render-tasks/scene-graph-render-task-messages.h new file mode 100644 index 0000000..8762f02 --- /dev/null +++ b/dali/internal/update/render-tasks/scene-graph-render-task-messages.h @@ -0,0 +1,145 @@ +#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H +#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H + +/* + * 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. + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali::Internal::SceneGraph +{ +// Messages for RenderTask +inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetFrameBuffer, frameBuffer); +} + +inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetClearEnabled, enabled); +} + +inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetCullMode, mode); +} + +inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetRefreshRate, refreshRate); +} + +inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode) +{ + // Scene graph thread can destroy this object. + Node* node = const_cast(constNode); + + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetSourceNode, node); +} + +inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera) +{ + using LocalType = MessageValue2; + + Node* node = const_cast(constNode); + Camera* camera = const_cast(constCamera); + // Reserve memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetCamera, node, camera); +} + +inline void SetViewportGuideNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode) +{ + // Scene graph thread can destroy this object. + Node* node = const_cast(constNode); + + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetViewportGuideNode, node); +} + +inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetExclusive, exclusive); +} + +inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&task, &RenderTask::SetSyncRequired, requiresSync); +} + +} // namespace Dali::Internal::SceneGraph + +#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.cpp b/dali/internal/update/render-tasks/scene-graph-render-task.cpp index 90dca93..d49af14 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -167,21 +167,11 @@ bool RenderTask::QueryViewport(BufferIndex bufferIndex, Viewport& viewport) cons return true; } -void RenderTask::SetClearColor(BufferIndex updateBufferIndex, const Vector4& value) -{ - mClearColor.Set(updateBufferIndex, value); -} - const Vector4& RenderTask::GetClearColor(BufferIndex bufferIndex) const { return mClearColor[bufferIndex]; } -void RenderTask::BakeClearColor(BufferIndex updateBufferIndex, const Vector4& value) -{ - mClearColor.Bake(updateBufferIndex, value); -} - void RenderTask::SetClearEnabled(bool enabled) { mClearEnabled = enabled; @@ -425,14 +415,13 @@ void RenderTask::UpdateViewport(BufferIndex updateBufferIndex, Vector2 sceneSize Vector3 halfNodeSize(nodeSize * 0.5f); Vector2 screenPosition(halfSceneSize.width + worldPosition.x - halfNodeSize.x, halfSceneSize.height + worldPosition.y - halfNodeSize.y); - SetViewportPosition(updateBufferIndex, screenPosition); - SetViewportSize(updateBufferIndex, Vector2(nodeSize)); - } -} -void RenderTask::SetViewportPosition(BufferIndex updateBufferIndex, const Vector2& value) -{ - mViewportPosition.Set(updateBufferIndex, value); + /* This is an implicit constraint - the properties will be dirty until the node + * is removed. (RenderTask::Impl manages this) + */ + mViewportPosition.Set(updateBufferIndex, screenPosition); + mViewportSize.Set(updateBufferIndex, Vector2(nodeSize)); + } } const Vector2& RenderTask::GetViewportPosition(BufferIndex bufferIndex) const @@ -440,26 +429,11 @@ const Vector2& RenderTask::GetViewportPosition(BufferIndex bufferIndex) const return mViewportPosition[bufferIndex]; } -void RenderTask::BakeViewportPosition(BufferIndex updateBufferIndex, const Vector2& value) -{ - mViewportPosition.Bake(updateBufferIndex, value); -} - -void RenderTask::SetViewportSize(BufferIndex updateBufferIndex, const Vector2& value) -{ - mViewportSize.Set(updateBufferIndex, value); -} - const Vector2& RenderTask::GetViewportSize(BufferIndex bufferIndex) const { return mViewportSize[bufferIndex]; } -void RenderTask::BakeViewportSize(BufferIndex updateBufferIndex, const Vector2& value) -{ - mViewportSize.Bake(updateBufferIndex, value); -} - bool RenderTask::GetViewportEnabled(BufferIndex bufferIndex) const { if(fabsf(mViewportPosition[bufferIndex].x) > Math::MACHINE_EPSILON_1 || diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.h b/dali/internal/update/render-tasks/scene-graph-render-task.h index 0d5142c..13947f8 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H /* - * Copyright (c) 2022 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. @@ -19,9 +19,6 @@ */ // INTERNAL INCLUDES -#include -#include -#include #include #include #include @@ -413,158 +410,6 @@ private: bool mCullMode : 1; ///< Whether renderers should be frustum culled }; -// Messages for RenderTask -inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetFrameBuffer, frameBuffer); -} - -inline void SetClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetClearColor, value); -} - -inline void BakeClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::BakeClearColor, value); -} - -inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetClearEnabled, enabled); -} - -inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetCullMode, mode); -} - -inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetRefreshRate, refreshRate); -} - -inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode) -{ - // Scene graph thread can destroy this object. - Node* node = const_cast(constNode); - - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetSourceNode, node); -} - -inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera) -{ - using LocalType = MessageValue2; - - Node* node = const_cast(constNode); - Camera* camera = const_cast(constCamera); - // Reserve memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetCamera, node, camera); -} - -inline void SetViewportGuideNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode) -{ - // Scene graph thread can destroy this object. - Node* node = const_cast(constNode); - - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetViewportGuideNode, node); -} - -inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetExclusive, exclusive); -} - -inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetSyncRequired, requiresSync); -} - -inline void BakeViewportPositionMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::BakeViewportPosition, value); -} - -inline void BakeViewportSizeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::BakeViewportSize, value); -} - } // namespace SceneGraph } // namespace Internal diff --git a/dali/internal/update/rendering/scene-graph-renderer-messages.h b/dali/internal/update/rendering/scene-graph-renderer-messages.h new file mode 100644 index 0000000..625e196 --- /dev/null +++ b/dali/internal/update/rendering/scene-graph-renderer-messages.h @@ -0,0 +1,304 @@ +#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H +#define DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H + +/* + * 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. + * 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. + */ + +#include +#include +#include +#include +#include +#include + +namespace Dali::Internal::SceneGraph +{ +class TextureSet; + +/// Messages +inline void SetTexturesMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&renderer, &Renderer::SetTextures, const_cast(&textureSet)); +} + +inline void SetGeometryMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&renderer, &Renderer::SetGeometry, const_cast(&geometry)); +} + +inline void SetShaderMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&renderer, &Renderer::SetShader, const_cast(&shader)); +} + +inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new(slot) LocalType(&renderer, &Renderer::SetDepthIndex, depthIndex); +} + +inline void SetFaceCullingModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetFaceCullingMode, faceCullingMode); +} + +inline void SetBlendModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetBlendMode, blendingMode); +} + +inline void SetBlendingOptionsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetBlendingOptions, options); +} + +inline void SetBlendColorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetBlendColor, blendColor); +} + +inline void SetIndexedDrawFirstElementMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawFirstElement, firstElement); +} + +inline void SetIndexedDrawElementsCountMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount); +} + +inline void SetEnablePreMultipliedAlphaMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied); +} + +inline void SetDepthWriteModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetDepthWriteMode, depthWriteMode); +} + +inline void SetDepthTestModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetDepthTestMode, depthTestMode); +} + +inline void SetDepthFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetDepthFunction, depthFunction); +} + +inline void SetRenderModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetRenderMode, mode); +} + +inline void SetStencilFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilFunction, stencilFunction); +} + +inline void SetStencilFunctionMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int mask) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionMask, mask); +} + +inline void SetStencilFunctionReferenceMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference); +} + +inline void SetStencilMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilMask, stencilMask); +} + +inline void SetStencilOperationOnFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnFail, stencilOperation); +} + +inline void SetStencilOperationOnZFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation); +} + +inline void SetStencilOperationOnZPassMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation); +} + +inline void BakeOpacityMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity) +{ + using LocalType = MessageDoubleBuffered1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::BakeOpacity, opacity); + + OwnerPointer resetter( + new SceneGraph::BakerResetter(const_cast(&renderer), + const_cast*>(&renderer.mOpacity), + SceneGraph::BakerResetter::Lifetime::BAKE)); + SceneGraph::AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter); +} + +inline void SetRenderingBehaviorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetRenderingBehavior, renderingBehavior); +} + +inline void SetDrawCommandsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size) +{ + using LocalType = MessageValue2; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetDrawCommands, pDrawCommands, size); +} + +inline void SetRenderCallbackMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::RenderCallback* callback) +{ + using LocalType = MessageValue1; + + // Reserve some memory inside the message queue + uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); + + new(slot) LocalType(&renderer, &Renderer::SetRenderCallback, callback); +} + +} // namespace Dali::Internal::SceneGraph + +#endif //DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index be4bf71..889a791 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -662,271 +661,6 @@ public: int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions }; -/// Messages -inline void SetTexturesMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&renderer, &Renderer::SetTextures, const_cast(&textureSet)); -} - -inline void SetGeometryMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&renderer, &Renderer::SetGeometry, const_cast(&geometry)); -} - -inline void SetShaderMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&renderer, &Renderer::SetShader, const_cast(&shader)); -} - -inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&renderer, &Renderer::SetDepthIndex, depthIndex); -} - -inline void SetFaceCullingModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetFaceCullingMode, faceCullingMode); -} - -inline void SetBlendModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetBlendMode, blendingMode); -} - -inline void SetBlendingOptionsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetBlendingOptions, options); -} - -inline void SetBlendColorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetBlendColor, blendColor); -} - -inline void SetIndexedDrawFirstElementMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawFirstElement, firstElement); -} - -inline void SetIndexedDrawElementsCountMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount); -} - -inline void SetEnablePreMultipliedAlphaMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied); -} - -inline void SetDepthWriteModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetDepthWriteMode, depthWriteMode); -} - -inline void SetDepthTestModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetDepthTestMode, depthTestMode); -} - -inline void SetDepthFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetDepthFunction, depthFunction); -} - -inline void SetRenderModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetRenderMode, mode); -} - -inline void SetStencilFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilFunction, stencilFunction); -} - -inline void SetStencilFunctionMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int mask) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionMask, mask); -} - -inline void SetStencilFunctionReferenceMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference); -} - -inline void SetStencilMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilMask, stencilMask); -} - -inline void SetStencilOperationOnFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnFail, stencilOperation); -} - -inline void SetStencilOperationOnZFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation); -} - -inline void SetStencilOperationOnZPassMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation); -} - -inline void BakeOpacityMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity) -{ - using LocalType = MessageDoubleBuffered1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::BakeOpacity, opacity); -} - -inline void SetRenderingBehaviorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetRenderingBehavior, renderingBehavior); -} - -inline void SetDrawCommandsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size) -{ - using LocalType = MessageValue2; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetDrawCommands, pDrawCommands, size); -} - -inline void SetRenderCallbackMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::RenderCallback* callback) -{ - using LocalType = MessageValue1; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); - - new(slot) LocalType(&renderer, &Renderer::SetRenderCallback, callback); -} - } // namespace SceneGraph } // namespace Internal } // namespace Dali -- 2.7.4