From: Adam Bialogonski Date: Tue, 22 Mar 2022 15:05:49 +0000 (+0000) Subject: Added New() function creating Renderer with RenderCallback X-Git-Tag: dali_2.1.18~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F272689%2F5;p=platform%2Fcore%2Fuifw%2Fdali-core.git Added New() function creating Renderer with RenderCallback Change-Id: I6f82838ed654342723cf043e43e8d7caba4125f7 --- diff --git a/automated-tests/src/dali/utc-Dali-DrawableActor.cpp b/automated-tests/src/dali/utc-Dali-DrawableActor.cpp index e13606e..e413029 100644 --- a/automated-tests/src/dali/utc-Dali-DrawableActor.cpp +++ b/automated-tests/src/dali/utc-Dali-DrawableActor.cpp @@ -28,9 +28,37 @@ struct DrawableObject return false; } - Size size; + Size size{}; }; +int UtcDaliRendererSetRenderCallbackP(void) +{ + tet_infoline("Testing Renderer:LSetRenderCallback()"); + TestApplication application; + + DrawableObject drawable{}; + + auto callback = RenderCallback::New(&drawable, &DrawableObject::Render); + + Actor actor = Actor::New(); + application.GetScene().Add(actor); + + actor.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + + auto renderer = Renderer::New(*callback); + actor.AddRenderer(renderer); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Check the size (whether callback has been called) + auto size(drawable.size); + DALI_TEST_EQUALS(drawable.size, Size(100, 100), TEST_LOCATION); + + END_TEST; +} + int UtcDaliDrawableActor1P(void) { tet_infoline("Testing DrawableActor"); diff --git a/dali/public-api/rendering/renderer.cpp b/dali/public-api/rendering/renderer.cpp index 15b2df3..326b54b 100644 --- a/dali/public-api/rendering/renderer.cpp +++ b/dali/public-api/rendering/renderer.cpp @@ -31,6 +31,13 @@ Renderer Renderer::New(Geometry& geometry, Shader& shader) return Renderer(renderer.Get()); } +Renderer Renderer::New(RenderCallback& renderCallback) +{ + Internal::RendererPtr renderer = Internal::Renderer::New(); + renderer->SetRenderCallback(&renderCallback); + return Renderer(renderer.Get()); +} + Renderer::Renderer() = default; Renderer::~Renderer() = default; diff --git a/dali/public-api/rendering/renderer.h b/dali/public-api/rendering/renderer.h index 21e2b24..c19e514 100644 --- a/dali/public-api/rendering/renderer.h +++ b/dali/public-api/rendering/renderer.h @@ -428,6 +428,15 @@ public: static Renderer New(Geometry& geometry, Shader& shader); /** + * @brief Creates a new Renderer object with RenderCallback. + * + * @SINCE_2_1.18 + * @param[in] renderCallback Valid RenderCallback + * @return A handle to the Renderer + */ + static Renderer New(RenderCallback& renderCallback); + + /** * @brief Default constructor, creates an empty handle * * @SINCE_1_1.43