END_TEST;
}
-int UtcDaliAnimationSetEndActionN(void)
+int UtcDaliAnimationSetEndActionP01(void)
{
+ tet_infoline("Test Animation::EndAction with Transform\n");
TestApplication application;
Actor actor = Actor::New();
animation.FinishedSignal().Connect(&application, finishCheck);
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f));
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f) + 1u /*just beyond the animation duration*/);
// We did expect the animation to finish
application.SendNotification();
application.Render(0);
DALI_TEST_EQUALS(Vector3::ZERO, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ tet_printf("Set EndAction::BAKE_FINAL\n");
// Test BakeFinal, animate again, for half the duration
finishCheck.Reset();
animation.SetEndAction(Animation::BAKE_FINAL);
// Stop the animation early
animation.Stop();
+ tet_printf("EndAction::BAKE_FINAL Animation stopped\n");
// We did NOT expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalNotReceived();
DALI_TEST_EQUALS(targetPosition * 0.5f, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), VECTOR4_EPSILON, TEST_LOCATION);
// The position should be same with target position in the next frame
+ tet_printf("Check current value return well\n");
application.Render(0);
DALI_TEST_EQUALS(targetPosition, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
application.Render(0);
DALI_TEST_EQUALS(Vector3::ZERO, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ tet_printf("Set EndAction::Discard\n");
// Test EndAction::Discard, animate again, but don't bake this time
finishCheck.Reset();
animation.SetEndAction(Animation::DISCARD);
animation.Play();
application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f) + 1u /*just beyond the animation duration*/);
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f));
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f) + 1u /*just beyond the animation duration*/);
+ // Check whether we need to keep update at least 2 frames after discard-animation finished.
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) != 0u);
+
+ tet_printf("EndAction::Discard Animation finished\n");
// We did expect the animation to finish
application.SendNotification();
finishCheck.CheckSignalReceived();
DALI_TEST_EQUALS(targetPosition, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
// The position should be discarded in the next frame
+ // And also, check whether we need to keep update next frames after discard-animation finished.
+ tet_printf("Check current value return well\n");
application.Render(0);
DALI_TEST_EQUALS(Vector3::ZERO /*discarded*/, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) != 0u);
// Check that nothing has changed after a couple of buffer swaps
+ // After 2 frames rendered, UpdateStatus will not mark as animation runing.
application.Render(0);
DALI_TEST_EQUALS(Vector3::ZERO, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) == 0u);
+
application.Render(0);
DALI_TEST_EQUALS(Vector3::ZERO, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) == 0u);
+ END_TEST;
+}
+
+int UtcDaliAnimationSetEndActionP02(void)
+{
+ tet_infoline("Test Animation::EndAction with non-Transform\n");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ application.GetScene().Add(actor);
+
+ Vector4 initialColor(0.0f, 0.0f, 0.0f, 1.0f);
+ actor.SetProperty(Actor::Property::COLOR, initialColor);
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ DALI_TEST_CHECK(animation.GetEndAction() == Animation::BAKE);
+
+ Vector4 targetColor(1.0f, 1.0f, 1.0f, 1.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f));
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f) + 1u /*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS(targetColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+
+ // Go back to the start
+ actor.SetProperty(Actor::Property::COLOR, initialColor);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS(initialColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ tet_printf("Set EndAction::BAKE_FINAL\n");
+ // Test BakeFinal, animate again, for half the duration
+ finishCheck.Reset();
+ animation.SetEndAction(Animation::BAKE_FINAL);
+ DALI_TEST_CHECK(animation.GetEndAction() == Animation::BAKE_FINAL);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f * 0.5f) /*half of the animation duration*/);
+
+ // Stop the animation early
+ animation.Stop();
+
+ tet_printf("EndAction::BAKE_FINAL Animation stopped\n");
+ // We did NOT expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS((initialColor + targetColor) * 0.5f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), VECTOR4_EPSILON, TEST_LOCATION);
+
+ // The position should be same with target position in the next frame
+ tet_printf("Check current value return well\n");
+ application.Render(0);
+ DALI_TEST_EQUALS(targetColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+
+ // Go back to the start
+ actor.SetProperty(Actor::Property::COLOR, initialColor);
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS(initialColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ tet_printf("Set EndAction::Discard\n");
+ // Test EndAction::Discard, animate again, but don't bake this time
+ finishCheck.Reset();
+ animation.SetEndAction(Animation::DISCARD);
+ DALI_TEST_CHECK(animation.GetEndAction() == Animation::DISCARD);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f));
+ application.Render(static_cast<unsigned int>(durationSeconds * 500.0f) + 1u /*just beyond the animation duration*/);
+
+ // Check whether we need to keep update at least 2 frames after discard-animation finished.
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) != 0u);
+
+ tet_printf("EndAction::Discard Animation finished\n");
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS(targetColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+
+ // The position should be discarded in the next frame
+ // And also, check whether we need to keep update next frames after discard-animation finished.
+ tet_printf("Check current value return well\n");
+ application.Render(0);
+ DALI_TEST_EQUALS(initialColor /*discarded*/, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) != 0u);
+
+ // Check that nothing has changed after a couple of buffer swaps
+ // After 2 frames rendered, UpdateStatus will not mark as animation runing.
+ application.Render(0);
+ DALI_TEST_EQUALS(initialColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) == 0u);
+
+ application.Render(0);
+ DALI_TEST_EQUALS(initialColor, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+ DALI_TEST_CHECK((application.GetUpdateStatus() & Integration::KeepUpdating::ANIMATIONS_RUNNING) == 0u);
END_TEST;
}
END_TEST;
}
+
+int UtcDaliVisualRendererPartialUpdate03(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Test that partial update works well when we animate visual renderer's animated properties with EndAction::DISCARD");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ Geometry geometry = CreateQuadGeometry();
+ VisualRenderer renderer = VisualRenderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor[Actor::Property::POSITION] = Vector3(64.0f, 64.0f, 0.0f);
+ actor[Actor::Property::SIZE] = Vector3(64.0f, 64.0f, 0.0f);
+ actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+
+ std::vector<Rect<int>> damagedRects;
+
+ // Actor added, damaged rect is added size of actor
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Aligned by 16
+ Rect<int> clippingRect = Rect<int>(64, 672, 80, 80); // in screen coordinates
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Ensure the damaged rect is empty
+ DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+
+ // Set clippingRect as full surface now. TODO : Set valid rect if we can.
+ clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+
+ Property::Index index = VisualRenderer::Property::TRANSFORM_OFFSET;
+
+ uint32_t durationMilliseconds = 1000u;
+ Animation animation = Animation::New(durationMilliseconds / 1000.0f);
+ animation.SetEndAction(Dali::Animation::EndAction::DISCARD); ///< Discard the animation when it ends.
+ animation.AnimateTo(Dali::Property(renderer, index), Vector2(1.0f, 1.0f));
+ animation.Play();
+
+ // Now current actor show as 64x64 rectangle, with center position (96, 96) + (64, 64) * time.
+
+ /// Progress 25%
+ /// Current actor show as 64x64 rectangle, with center position (112, 112).
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(durationMilliseconds / 4, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ // Aligned by 16
+ // Note, this damagedRect is combine of previous rect and current rect
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 656, 96, 96), damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::RED);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Aligned by 16
+ // Note, this damagedRect don't contain previous rect now.
+ // Current rectangle's top left position is (80, 80), and bottom right position is (144, 144).
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(80, 656, 80, 80), damagedRects[0], TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
+
+ /// Progress 50%
+ /// Current actor show as 64x64 rectangle, with center position (128, 128).
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(durationMilliseconds / 4, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ // Aligned by 16
+ // Note, this damagedRect is combine of previous rect and current rect
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(80, 640, 96, 96), damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::RED);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Aligned by 16
+ // Note, this damagedRect don't contain previous rect now.
+ // Current rectangle's top left position is (96, 96), and bottom right position is (160, 160).
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 640, 80, 80), damagedRects[0], TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
+
+ /// Progress 75%
+ /// Current actor show as 64x64 rectangle, with center position (144, 144).
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(durationMilliseconds / 4, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ // Aligned by 16
+ // Note, this damagedRect is combine of previous rect and current rect
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 624, 96, 96), damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::RED);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Aligned by 16
+ // Note, this damagedRect don't contain previous rect now.
+ // Current rectangle's top left position is (112, 112), and bottom right position is (176, 176).
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(112, 624, 80, 80), damagedRects[0], TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
+
+ /// Progress 100%
+ /// Current actor show as 64x64 rectangle, with center position (96, 96).
+ /// Note. Animation end action is DISCARD.
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(durationMilliseconds / 4 + 1u /* Over the animation */, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ // Aligned by 16
+ // Note, this damagedRect is combine of previous rect and current rect
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(112, 608, 96, 96), damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::RED);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::BLUE);
+
+ application.SendNotification();
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(0u, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ // Aligned by 16
+ // Note, this damagedRect don't contain previous rect now.
+ // Current rectangle's top left position is (64, 64), and bottom right position is (128, 128).
+ DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 80, 80), damagedRects[0], TEST_LOCATION);
+
+ // Update dummy property to damangeRect buffer aging
+ actor.SetProperty(Actor::Property::COLOR, Color::GREEN);
+
+ END_TEST;
+}
\ No newline at end of file
#define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
virtual void OnSet()
{
- mDirtyFlags = SET_FLAG;
+ mDirtyFlags |= SET_FLAG;
}
/**
*/
virtual void OnBake()
{
- mDirtyFlags = BAKED_FLAG;
+ mDirtyFlags |= BAKED_FLAG;
}
public:
*/
void MarkAsDirty()
{
- mDirtyFlags = RESET_FLAG;
+ mDirtyFlags |= RESET_FLAG;
}
public: // From PropertyBase
return true; // Animatable properties are always valid
}
-protected: // so that ResetToBaseValue can set it directly
- uint32_t mDirtyFlags; ///< Flag whether value changed during previous 2 frames
+protected: // so that ResetToBaseValue can set it directly
+ uint8_t mDirtyFlags : 2; ///< Flag whether value changed during previous 2 frames
};
/**
: mRenderer(renderer),
mActive(AGING) // Since we make this resetter only initialize case now.
{
- mRenderer->MarkAsDirty();
}
Renderer* mRenderer; ///< The renderer that owns the properties
#if defined(LOW_SPEC_MEMORY_MANAGEMENT_ENABLED)
containerRemovedFlags(ContainerRemovedFlagBits::NOTHING),
#endif
+ discardAnimationFinishedAge(0u),
animationFinishedDuringUpdate(false),
previousUpdateScene(false),
renderTaskWaiting(false),
ContainerRemovedFlags containerRemovedFlags; ///< cumulative container removed flags during current frame
#endif
- bool animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
- bool previousUpdateScene; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
- bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
- bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
- bool renderingRequired; ///< True if required to render the current frame
+ uint8_t discardAnimationFinishedAge : 2; ///< Age of EndAction::Discard animation Stop/Finished. It will make we call ResetToBaseValue at least 2 frames.
+
+ bool animationFinishedDuringUpdate : 1; ///< Flag whether any animations finished during the Update()
+ bool previousUpdateScene : 1; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
+ bool renderTaskWaiting : 1; ///< A REFRESH_ONCE render task is waiting to be rendered
+ bool renderersAdded : 1; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
+ bool renderingRequired : 1; ///< True if required to render the current frame
private:
Impl(const Impl&); ///< Undefined
// Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
mImpl->animationFinishedDuringUpdate = false;
+ // Age down discard animations.
+ mImpl->discardAnimationFinishedAge >>= 1;
+
// Reset node properties
mImpl->nodeResetters.ResetToBaseValues(bufferIndex);
mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || finished;
+ // Check whether finished animation is Discard type. If then, we should update scene at least 2 frames.
+ if(finished && animation->GetEndAction() == Animation::EndAction::DISCARD)
+ {
+ mImpl->discardAnimationFinishedAge |= 2u;
+ }
+
// queue the notification on finished or stopped
if(finished || stopped)
{
isAnimationRunning || // ..at least one animation is running OR
mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
mImpl->frameCallbackProcessor || // ..a frame callback processor is existed OR
+ mImpl->discardAnimationFinishedAge > 0u || // ..at least one animation with EndAction::DISCARD finished
gestureUpdated; // ..a gesture property was updated
uint32_t keepUpdating = 0;
// If the rendering behavior is set to continuously render, then continue to render.
// Keep updating until no messages are received and no animations are running.
- // If an animation has just finished, update at least once more for Discard end-actions.
+ // If an animation has just finished, update at least two frames more for Discard end-actions.
// No need to check for renderQueue as there is always a render after update and if that
// render needs another update it will tell the adaptor to call update again
}
if(IsAnimationRunning() ||
- mImpl->animationFinishedDuringUpdate)
+ mImpl->animationFinishedDuringUpdate ||
+ mImpl->discardAnimationFinishedAge > 0u)
{
keepUpdatingRequest |= KeepUpdating::ANIMATIONS_RUNNING;
}
mResendFlag = 0;
}
+ // Age down visual properties dirty flag
+ if(mVisualProperties)
+ {
+ rendererUpdated |= mVisualProperties->PrepareProperties();
+ }
+
// Ensure collected map is up to date
UpdateUniformMap(updateBufferIndex);
}
}
-void Renderer::MarkAsDirty()
-{
- mOpacity.MarkAsDirty();
- if(mVisualProperties)
- {
- mVisualProperties->MarkAsDirty();
- }
-}
-
uint32_t Renderer::GetMemoryPoolCapacity()
{
return GetRendererMemoryPool().GetCapacity();
bool Renderer::IsUpdated() const
{
- if(Updated() || (mShader && mShader->Updated()))
+ // We should check Whether
+ // 1. Renderer itself's property changed
+ // 2. Renderer's opacity changed
+ // 3. Shader's propperties are changed
+ // 4. Visual properties are changed
+ if(IsDirty() || (mShader && mShader->Updated()) || (mVisualProperties && mVisualProperties->Updated()))
{
return true;
}
void ResetToBaseValues(BufferIndex updateBufferIndex);
/**
- * @brief Mark all animatable properties as dirty.
- */
- void MarkAsDirty();
-
- /**
* Get the capacity of the memory pools
* @return the capacity of the memory pools
*/
#define DALI_INTERNAL_SCENE_GRAPH_VISUAL_RENDERER_PROPERTY_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
struct VisualRendererCoefficientCacheBase
{
VisualRendererCoefficientCacheBase()
- : mUpdated(true)
+ : mUpdatedFlag(Dali::Internal::SceneGraph::BAKED_FLAG),
+ mUpdateCurrentFrame(true),
+ mCoefficientCalculated(false)
{
}
virtual ~VisualRendererCoefficientCacheBase() = default;
/**
- * @brief Check whether this cache need to be update.
- * After call this API, update flag will be reset.
+ * @brief Check whether this cache is updated or not.
*
- * @return True if this coefficient updated. False otherwise.
*/
- bool IsUpdated()
+ bool IsUpdated() const
{
- bool ret = mUpdated;
- mUpdated = false;
- return ret;
+ return mUpdateCurrentFrame;
}
/**
* @brief Mark update flag as true.
+ * @param[in] bake Whether this coefficient updated by OnBake API, or not.
*/
- void Update()
+ void Update(bool bake)
{
- mUpdated = true;
+ mUpdateCurrentFrame = true;
+ mUpdatedFlag |= bake ? Dali::Internal::SceneGraph::BAKED_FLAG : Dali::Internal::SceneGraph::SET_FLAG;
+ }
+
+ /**
+ * @brief Get whether we already calculate coefficient at this frame or not.
+ * @return True if we already calculate coefficient at this frame, false otherwise.
+ */
+ bool IsCoefficientCalculated() const
+ {
+ return mCoefficientCalculated;
+ }
+
+ /**
+ * @brief Mark as we calculate coefficient already at this frame.
+ */
+ void MarkCoefficientCalculated()
+ {
+ mCoefficientCalculated = true;
+ }
+
+ /**
+ * @brief Reset update flag.
+ */
+ void ResetFlag()
+ {
+ mUpdateCurrentFrame = (mUpdatedFlag != Dali::Internal::SceneGraph::CLEAN_FLAG); ///< Keep the flag whether it was updated or not.
+ mCoefficientCalculated = (!mUpdateCurrentFrame); ///< Re-calculate coefficient only if previous update flag was not clean.
+
+ mUpdatedFlag >>= 1;
}
private:
- bool mUpdated; ///< Updated flag for this coefficient cache.
+ uint8_t mUpdatedFlag : 2; ///< Updated flag for this coefficient cache.
+
+ bool mUpdateCurrentFrame : 1; ///< Whether we need to update this frame or not.
+ bool mCoefficientCalculated : 1; ///< Whether we need to re-calculate coefficient or not.
};
/**
*/
void OnSet() override
{
- GetCacheBaseData()->Update();
+ GetCacheBaseData()->Update(false);
AnimatablePropertyBase::OnSet();
}
*/
void OnBake() override
{
- GetCacheBaseData()->Update();
+ GetCacheBaseData()->Update(true);
AnimatablePropertyBase::OnBake();
}
};
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-void AnimatableVisualProperties::MarkAsDirty()
+bool AnimatableVisualProperties::Updated() const
{
- mTransformOffset.MarkAsDirty();
- mTransformSize.MarkAsDirty();
- mTransformOrigin.MarkAsDirty();
- mTransformAnchorPoint.MarkAsDirty();
- mTransformOffsetSizeMode.MarkAsDirty();
- mExtraSize.MarkAsDirty();
- mMixColor.MarkAsDirty();
- mPreMultipliedAlpha.MarkAsDirty();
- if(mExtendedProperties)
- {
- auto* decoratedVisualProperties = static_cast<VisualRenderer::AnimatableDecoratedVisualProperties*>(mExtendedProperties);
- decoratedVisualProperties->MarkAsDirty();
- }
+ return mCoefficient.IsUpdated() || (mExtendedProperties && static_cast<VisualRenderer::AnimatableDecoratedVisualProperties*>(mExtendedProperties)->Updated());
}
Vector4 AnimatableVisualProperties::GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex, const Vector4& originalUpdateArea) noexcept
auto& coefficient = mCoefficient;
// Recalculate only if coefficient need to be updated.
- if(coefficient.IsUpdated())
+ if(!coefficient.IsCoefficientCalculated())
{
// VisualProperty
const Vector2 transformOffset = mTransformOffset.Get(updateBufferIndex);
coefficient.coefXB = coefficient.coefXA * transformAnchorPoint + transformOffset * Vector2(1.0f - transformOffsetSizeMode.x, 1.0f - transformOffsetSizeMode.y) + transformOrigin;
coefficient.coefCA = transformSize * Vector2(transformOffsetSizeMode.z, transformOffsetSizeMode.w) + extraSize;
coefficient.coefCB = coefficient.coefCA * transformAnchorPoint + transformOffset * Vector2(transformOffsetSizeMode.x, transformOffsetSizeMode.y);
+
+ coefficient.MarkCoefficientCalculated();
}
float coefD = 0.0f; ///< Default as 0.0f when we don't use decorated renderer.
auto& decoratedCoefficient = decoratedVisualProperties->mCoefficient;
// Recalculate only if coefficient need to be updated.
- if(decoratedCoefficient.IsUpdated())
+ if(!decoratedCoefficient.IsCoefficientCalculated())
{
// DecoratedVisualProperty
const float borderlineWidth = decoratedVisualProperties->mBorderlineWidth.Get(updateBufferIndex);
// D coefficients be used only decoratedVisual.
// It can be calculated parallely with visual transform.
decoratedCoefficient.coefD = std::max((1.0f + Dali::Clamp(borderlineOffset, -1.0f, 1.0f)) * borderlineWidth, 2.0f * blurRadius) + extraPadding;
+
+ decoratedCoefficient.MarkCoefficientCalculated();
}
// Update coefD so we can use this value out of this scope.
return resultArea;
}
+bool AnimatableVisualProperties::PrepareProperties()
+{
+ bool rendererUpdated = mCoefficient.IsUpdated();
+ mCoefficient.ResetFlag();
+
+ if(mExtendedProperties)
+ {
+ auto* decoratedVisualProperties = static_cast<VisualRenderer::AnimatableDecoratedVisualProperties*>(mExtendedProperties);
+ rendererUpdated |= (decoratedVisualProperties->PrepareProperties());
+ }
+
+ return rendererUpdated;
+}
+
void AnimatableDecoratedVisualProperties::ResetToBaseValues(BufferIndex updateBufferIndex)
{
mCornerRadius.ResetToBaseValue(updateBufferIndex);
mBlurRadius.ResetToBaseValue(updateBufferIndex);
}
-void AnimatableDecoratedVisualProperties::MarkAsDirty()
+bool AnimatableDecoratedVisualProperties::Updated() const
+{
+ return mCoefficient.IsUpdated();
+}
+
+bool AnimatableDecoratedVisualProperties::PrepareProperties()
{
- mCornerRadius.MarkAsDirty();
- mCornerRadiusPolicy.MarkAsDirty();
- mBorderlineWidth.MarkAsDirty();
- mBorderlineColor.MarkAsDirty();
- mBorderlineOffset.MarkAsDirty();
- mBlurRadius.MarkAsDirty();
+ bool rendererUpdated = mCoefficient.IsUpdated();
+ mCoefficient.ResetFlag();
+ return rendererUpdated;
}
} // namespace VisualRenderer
#define DALI_INTERNAL_SCENE_GRAPH_VISUAL_RENDERER_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void ResetToBaseValues(BufferIndex updateBufferIndex);
/**
- * @copydoc Dali::Internal::SceneGraph::Renderer::MarkAsDirty
+ * @copydoc Dali::Internal::SceneGraph::Renderer::Updated
*/
- void MarkAsDirty();
+ bool Updated() const;
/**
* @copydoc RenderDataProvider::GetVisualTransformedUpdateArea()
public:
/**
+ * @brief Prepare properties and ready to render sequence
+ *
+ * @return True if we need to render this frame.
+ */
+ bool PrepareProperties();
+
+public:
+ /**
* @brief Cached coefficient value when we calculate visual transformed update size.
* It can reduce complexity of calculate the vertex position.
*
void ResetToBaseValues(BufferIndex updateBufferIndex);
/**
- * @copydoc Dali::Internal::SceneGraph::Renderer::MarkAsDirty
+ * @copydoc Dali::Internal::SceneGraph::Renderer::Updated
+ */
+ bool Updated() const;
+
+public:
+ /**
+ * @brief Prepare properties and ready to render sequence
+ *
+ * @return True if we need to render this frame.
*/
- void MarkAsDirty();
+ bool PrepareProperties();
public:
/**