{
bool Render(const RenderCallbackInput& inputData)
{
- // Store the size of rendered area
- size = inputData.size;
+ // Store the size and clipping box of rendered area
+ size = inputData.size;
+ clippingBox = inputData.clippingBox;
return false;
}
bool RenderWithTextures(const RenderCallbackInput& inputData)
{
- // Store the size of rendered area
- size = inputData.size;
+ // Store the size and clipping box of rendered area
+ size = inputData.size;
+ clippingBox = inputData.clippingBox;
auto count = inputData.textureBindings.size();
return false;
}
- Size size{};
+ Size size{};
+ ClippingBox clippingBox{};
};
int UtcDaliRendererSetRenderCallbackP(void)
// Check the size (whether callback has been called)
DALI_TEST_EQUALS(drawable.size, Size(100, 100), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliDrawableActor2P(void)
+{
+ tet_infoline("Testing Renderer:LSetRenderCallback() and check clipping box");
+ TestApplication application;
+
+ DrawableObject drawable{};
+
+ auto callback = RenderCallback::New<DrawableObject>(&drawable, &DrawableObject::Render);
+
+ Actor actor = Actor::New();
+ Actor parentActor = Actor::New();
+ application.GetScene().Add(parentActor);
+ parentActor.Add(actor);
+
+ parentActor.SetProperty(Actor::Property::POSITION, Vector2(20, 50));
+ parentActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100, 200));
+ actor.SetProperty(Actor::Property::POSITION, Vector2(50, 70));
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ 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)
+ DALI_TEST_EQUALS(drawable.size, Size(100, 200), TEST_LOCATION);
+
+ // Check clippingBox. Note that clippingBox coordinate is in screen coordinates
+ DALI_TEST_EQUALS(drawable.clippingBox, Rect<int32_t>(20 + 50, 800 - (50 + 70 + 200), 100, 200), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliDrawableActorSceneRotated(void)
+{
+ tet_infoline("Testing Renderer:LSetRenderCallback()");
+ TestApplication application;
+
+ DrawableObject drawable{};
+
+ auto callback = RenderCallback::New<DrawableObject>(&drawable, &DrawableObject::Render);
+
+ Actor actor = Actor::New();
+ Actor parentActor = Actor::New();
+ application.GetScene().Add(parentActor);
+ parentActor.Add(actor);
+
+ parentActor.SetProperty(Actor::Property::POSITION, Vector2(20, 50));
+ parentActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ parentActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100, 200));
+ actor.SetProperty(Actor::Property::POSITION, Vector2(50, 70));
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ 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)
+ DALI_TEST_EQUALS(drawable.size, Size(100, 200), TEST_LOCATION);
+
+ // Check clippingBox. Note that clippingBox coordinate is in screen coordinates
+ DALI_TEST_EQUALS(drawable.clippingBox, Rect<int32_t>(20 + 50, TestApplication::DEFAULT_SURFACE_HEIGHT - (50 + 70 + 200), 100, 200), TEST_LOCATION);
+
+ // Reset size (to check callback comes)
+ drawable.size = Size();
+
+ application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ 90,
+ 0);
+
+ application.SendNotification();
+ application.Render();
+
+ // Check the size (whether callback has been called)
+ DALI_TEST_EQUALS(drawable.size, Size(100, 200), TEST_LOCATION);
+
+ // Check clippingBox. Note that clippingBox coordinate is in screen coordinates
+ DALI_TEST_EQUALS(drawable.clippingBox, Rect<int32_t>(50 + 70, 20 + 50, 200, 100), TEST_LOCATION);
+
END_TEST;
}
\ No newline at end of file
#define DALI_RENDER_CALLBACK_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
Matrix mvp;
Matrix projection;
Size size;
- Rect<int32_t> clippingBox;
+ Rect<int32_t> clippingBox; ///< in screen coordinates
std::vector<uint32_t> textureBindings;
- std::any eglContext; ///< Storage for EGL Context
+ std::any eglContext; ///< Storage for EGL Context
bool usingOwnEglContext; ///< Uses own EGL context (owns GL state), custom code should be aware of it
Matrix view; // Added at end to avoid abi break.
class DALI_CORE_API RenderCallback
{
public:
-
/**
* @brief Mode of execution of custom rendering code into the pipeline
*
* @SINCE_2_3.12
* @return Valid execution mode
*/
- [[nodiscard]] ExecutionMode GetExecutionMode() const
- {
- return mExecutionMode;
- }
+ [[nodiscard]] ExecutionMode GetExecutionMode() const
+ {
+ return mExecutionMode;
+ }
private:
std::unique_ptr<CallbackBase> mCallback; //< Callback base object
RenderCallbackInput mRenderCallbackInput;
ExecutionMode mExecutionMode{ExecutionMode::DEFAULT};
- std::vector<Dali::Texture> mTextureResources{};
+ std::vector<Dali::Texture> mTextureResources{};
};
} // namespace Dali