/*
- * 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.
#include <test-actor-utils.h>
#include <cfloat> // For FLT_MAX
+#include <set> // For std::multiset
#include <string>
#include "assert.h"
PropertyNotification& mPropertyNotification;
};
+// Check dirtyRect is equal with expected multiset.
+// Note that the order of damagedRect is not important
+struct RectSorter
+{
+ bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
+ {
+ if(lhs.x != rhs.x)
+ {
+ return lhs.x < rhs.x;
+ }
+ if(lhs.y != rhs.y)
+ {
+ return lhs.y < rhs.y;
+ }
+ if(lhs.width != rhs.width)
+ {
+ return lhs.width < rhs.width;
+ }
+ return lhs.height < rhs.height;
+ }
+};
+
+void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation)
+{
+ // Just check damagedRect contain all expectRectList.
+ DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation);
+
+ for(auto& rect : damagedRects)
+ {
+ auto iter = expectedRectList.find(rect);
+ if(iter != expectedRectList.end())
+ {
+ expectedRectList.erase(iter);
+ }
+ else if(checkRectsExact)
+ {
+ std::ostringstream o;
+ o << rect << " exist in expectRectList" << std::endl;
+ fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str());
+ tet_result(TET_FAIL);
+ }
+ }
+
+ // Check all rects are matched
+ DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation);
+}
+
} // anonymous namespace
//& purpose: Testing New API
END_TEST;
}
+int UtcDaliActorSetSize05(void)
+{
+ TestApplication application;
+
+ Actor parent = Actor::New();
+ Vector2 vector(200.0f, 200.0f);
+ DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+
+ parent.SetProperty(Actor::Property::SIZE, vector);
+ Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+
+ Actor child = Actor::New();
+ DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+ child.SetProperty(Actor::Property::SIZE, vector);
+ size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+
+ END_TEST;
+}
+
int UtcDaliActorSetSizeIndividual(void)
{
TestApplication application;
actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
+ application.GetScene().Add(actor);
+
application.SendNotification();
application.Render();
- auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
+ auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
auto actualExtent = DevelActor::CalculateScreenExtents(actor);
DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
END_TEST;
}
+int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
+{
+ TestApplication application;
+ Integration::Scene scene = application.GetScene();
+
+ // Make 3D Layer
+ Layer layer = Layer::New();
+ layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
+ layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+
+ scene.Add(layer);
+
+ // Build custom camera with top-view
+ CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
+ {
+ // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
+ Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
+ cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
+
+ // Now, upside : -Z, leftside : -X, foward : +Y
+
+ cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+ }
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
+ actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
+
+ layer.Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector2 sceneSize = scene.GetSize();
+
+ auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
+ auto actualExtent = DevelActor::CalculateScreenExtents(actor);
+ {
+ std::ostringstream oss;
+ oss << expectedExtent << "\n";
+ oss << actualExtent << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
+{
+ // TODO : Need to make it works well
+ TestApplication application;
+ Integration::Scene scene = application.GetScene();
+ Vector2 sceneSize = scene.GetSize();
+
+ // Make 3D Layer
+ Layer layer = Layer::New();
+ layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
+ layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
+ layer.SetProperty(Actor::Property::SIZE, sceneSize);
+
+ scene.Add(layer);
+
+ // Build custom camera with top-view
+ CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
+
+ offscreenCameraActor.SetPerspectiveProjection(sceneSize);
+ offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+
+ scene.Add(offscreenCameraActor);
+ {
+ // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
+ Vector3 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
+ offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
+
+ // Now, upside : -Z, leftside : -X, foward : +Y
+
+ cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+ }
+ Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
+ Vector3 sourceSize{1.0f, 0.0f, 3.0f};
+
+ Actor sourceActor = Actor::New();
+ sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
+ sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
+
+ layer.Add(sourceActor);
+
+ // Create framebuffer
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+ FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
+ frameBuffer.AttachColorTexture(texture);
+
+ Actor rootActor = Actor::New();
+ rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
+ rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
+ scene.Add(rootActor);
+
+ RenderTaskList taskList = scene.GetRenderTaskList();
+ RenderTask newTask = taskList.CreateTask();
+ newTask.SetCameraActor(offscreenCameraActor);
+ newTask.SetSourceActor(layer);
+ newTask.SetInputEnabled(false);
+ newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
+ newTask.SetClearEnabled(true);
+ newTask.SetExclusive(true);
+ newTask.SetFrameBuffer(frameBuffer);
+ newTask.SetScreenToFrameBufferMappingActor(rootActor);
+
+ application.SendNotification();
+ application.Render(16u);
+
+ auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
+ sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
+ sourceSize.x,
+ sourceSize.z};
+ auto actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
+ {
+ std::ostringstream oss;
+ oss << expectedExtent << "\n";
+ oss << actualExtent << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
+ auto actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+ {
+ std::ostringstream oss;
+ oss << expectedScreen << "\n";
+ oss << actualScreen << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ // Change rootActor's size and position
+
+ Vector3 rootPosition{100.0f, 200.0f, 0.0f};
+ Vector3 rootSize{200.0f, 100.0f, 0.0f};
+
+ rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
+ rootActor.SetProperty(Actor::Property::SIZE, rootSize);
+
+ application.SendNotification();
+ application.Render(16u);
+
+ expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
+ sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
+ sourceSize.x * rootSize.x / sceneSize.x,
+ sourceSize.z * rootSize.y / sceneSize.y};
+ actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
+ {
+ std::ostringstream oss;
+ oss << expectedExtent << "\n";
+ oss << actualExtent << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ expectedScreen = Vector2{sceneSize.x * 0.5f + rootPosition.x + sourcePosition.x * rootSize.x / sceneSize.x, sceneSize.y * 0.5f + rootPosition.y + sourcePosition.z * rootSize.y / sceneSize.y};
+ actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+ {
+ std::ostringstream oss;
+ oss << expectedScreen << "\n";
+ oss << actualScreen << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ END_TEST;
+}
+
// SetPosition(float x, float y)
int UtcDaliActorSetPosition01(void)
{
END_TEST;
}
+int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
+{
+ tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
+
+ TestApplication application;
+ Integration::Scene scene = application.GetScene();
+
+ // Make 3D Layer
+ Layer layer = scene.GetRootLayer();
+ layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
+
+ // Build custom camera with top-view
+ CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
+ {
+ // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
+ Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+
+ cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
+ cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
+
+ // Now, upside : -Z, leftside : -X, foward : +Y
+
+ cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
+ cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
+ {
+ std::ostringstream oss;
+ oss << cameraPos << "\n";
+ oss << cameraOrient << "\n";
+ tet_printf("%s\n", oss.str().c_str());
+ }
+ }
+
+ Actor actorA = Actor::New();
+ actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
+ actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
+
+ Actor actorB = Actor::New();
+ actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
+ actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
+
+ scene.Add(actorA);
+ scene.Add(actorB);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector2 sceneSize = scene.GetSize();
+ Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
+
+ DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
+
+ actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
+
+ DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
+
+ END_TEST;
+}
+
int utcDaliActorPositionUsesAnchorPoint(void)
{
TestApplication application;
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
application.GetScene().Remove(actor);
application.SendNotification();
- // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
+ // Actor removed, last a dirty rect is reported.
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
clippingRect = damagedRects[0];
- clippingRect.Merge(damagedRects[1]);
- clippingRect.Merge(damagedRects[2]);
- DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
// 2. Set new color
actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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(damagedRects.size(), 1, TEST_LOCATION);
clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
// in screen coordinates, adaptor would calculate it using previous frames information
Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
// in screen coordinates, adaptor would calculate it using previous frames information
application.RenderWithPartialUpdate(damagedRects, clippingRect);
END_TEST;
}
-int utcDaliActorPartialUpdateActorsWithSizeHint(void)
+int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
{
TestApplication application(
TestApplication::DEFAULT_SURFACE_WIDTH,
Actor actor = CreateRenderableActor();
actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
- actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
+ actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
application.GetScene().Add(actor);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- END_TEST;
-}
+ // Reset
+ actor.Unparent();
-int utcDaliActorPartialUpdateAnimation(void)
-{
- TestApplication application(
- TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT,
- TestApplication::DEFAULT_HORIZONTAL_DPI,
- TestApplication::DEFAULT_VERTICAL_DPI,
- true,
- true);
+ damagedRects.clear();
+ application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
- tet_infoline("Check the damaged area with partial update and animation");
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
- TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
- drawTrace.Enable(true);
- drawTrace.Reset();
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Actor actor1 = CreateRenderableActor();
- actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
- application.GetScene().Add(actor1);
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Actor actor2 = CreateRenderableActor();
- actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
- application.GetScene().Add(actor2);
+ // Ensure the damaged rect is empty
+ DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
- std::vector<Rect<int>> damagedRects;
- Rect<int> clippingRect;
- Rect<int> expectedRect1, expectedRect2;
+ // Chnage UPDATE_AREA_HINT
+ actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
+ application.GetScene().Add(actor);
application.SendNotification();
- application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
- DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- // Aligned by 16
- expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
- expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
+ clippingRect = Rect<int>(64, 704, 48, 48);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
- clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- damagedRects.clear();
- clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
- application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- 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);
- // Make an animation
- Animation animation = Animation::New(1.0f);
- animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
- animation.Play();
+ // Reset
+ actor.Unparent();
+ damagedRects.clear();
application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
- damagedRects.clear();
- clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
- application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- drawTrace.Reset();
damagedRects.clear();
-
- // In animation deley time
- clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- // Skip rendering
- DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
+ // Ensure the damaged rect is empty
+ DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
- drawTrace.Reset();
- damagedRects.clear();
+ // Chnage UPDATE_AREA_HINT
+ actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
+ application.GetScene().Add(actor);
- // Also in animation deley time
- clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+ application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ clippingRect = Rect<int>(0, 720, 80, 80);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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);
+
+ END_TEST;
+}
+
+int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged rect with partial update and actor size hint");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Actor actor = CreateRenderableActor();
+ actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
+ actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
+ actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ std::vector<Rect<int>> damagedRects;
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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);
+
+ // Chnage UPDATE_AREA_HINT
+ actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
+
+ application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ clippingRect = Rect<int>(32, 704, 80, 80);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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);
+
+ // Chnage UPDATE_AREA_HINT
+ actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+ clippingRect = Rect<int>(32, 688, 96, 96);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, 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);
+
+ END_TEST;
+}
+
+int utcDaliActorPartialUpdateAnimation(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged area with partial update and animation");
+
+ TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
+ drawTrace.Enable(true);
+ drawTrace.Reset();
+
+ Actor actor1 = CreateRenderableActor();
+ actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
+ application.GetScene().Add(actor1);
+
+ Actor actor2 = CreateRenderableActor();
+ actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+ application.GetScene().Add(actor2);
+
+ std::vector<Rect<int>> damagedRects;
+ Rect<int> clippingRect;
+ Rect<int> expectedRect1, expectedRect2;
+
+ application.SendNotification();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
+
+ // Aligned by 16
+ expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
+ expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
+ DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
+
+ clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Make an animation
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
+ animation.Play();
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ drawTrace.Reset();
+ damagedRects.clear();
+
+ // In animation deley time
+ clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Skip rendering
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
+
+ drawTrace.Reset();
+ damagedRects.clear();
+
+ // Also in animation deley time
+ clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
// Started animation
damagedRects.clear();
application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
- DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
+ DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
- // The first dirty rect is actor3's.
- // We don't know the exact dirty rect of actor2
- DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
+ // One of dirty rect is actor3's.
+ // We don't know the exact dirty rect of actor1 and actor2.
+ DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
damagedRects.clear();
application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
- DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
+ DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- 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);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
+ expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
+ DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
drawTrace.Reset();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
drawTrace.Reset();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
drawTrace.Reset();
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- 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);
// Make the actor transparent by changing opacity of the Renderer
// It changes a uniform value
// The damaged rect should be same
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
// The damaged rect should not be empty
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ 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);
+
+ // Make the actor translucent
+ renderer[DevelRenderer::Property::OPACITY] = 0.5f;
+
+ application.SendNotification();
+
+ // The damaged rect should not be empty
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ 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);
+
+ // Change Renderer opacity - also translucent
+ renderer[DevelRenderer::Property::OPACITY] = 0.2f;
+
+ application.SendNotification();
+ // The damaged rect should not be empty
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
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);
+
// Make the actor culled
actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
// The damaged rect should be same
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
// The damaged rect should not be empty
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
- application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
END_TEST;
}
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
END_TEST;
}
-int utcDaliActorPartialAddRemoveRenderer(void)
+int utcDaliActorPartialUpdateAddRemoveRenderer(void)
{
TestApplication application(
TestApplication::DEFAULT_SURFACE_WIDTH,
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// Aligned by 16
- Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
application.RenderWithPartialUpdate(damagedRects, clippingRect);
DALI_TEST_CHECK(damagedRects.size() > 0);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, false, 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);
+
+ // Add the Renderer again
+ actor.AddRenderer(renderer);
+
+ application.SendNotification();
+
+ // The damaged rect should be the actor area
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliActorPartialUpdate3DTransform(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged rect with 3D transformed actors");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Actor actor1 = CreateRenderableActor();
+ actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
+ actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
+ actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor1);
+
+ // Add a new actor
+ Actor actor2 = CreateRenderableActor();
+ actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f);
+ actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
+ actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor2);
+
+ 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(), 2, TEST_LOCATION);
+
+ // Aligned by 16
+ Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
+ DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
+
+ Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ damagedRects.clear();
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ damagedRects.clear();
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ // Rotate actor1 on y axis
+ actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
+
+ // Remove actor2
+ actor2.Unparent();
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Should update full area
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ // Add actor2 again
+ application.GetScene().Add(actor2);
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Should update full area
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ // Reset the orientation of actor1
+ actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Should update full area
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ // Make actor2 dirty
+ actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ clippingRect2 = Rect<int>(160, 608, 48, 48);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect2);
+ DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
+
+ // Remove actor1
+ actor1.Unparent();
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ // Rotate actor1 on y axis
+ actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
+
+ // Add actor1 again
+ application.GetScene().Add(actor1);
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Should update full area
+ surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
+ application.RenderWithPartialUpdate(damagedRects, surfaceRect);
+
+ END_TEST;
+}
+
+int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged rect with one actor which has multiple renderers");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Actor actor = CreateRenderableActor();
+
+ // Create another renderer
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer2 = Renderer::New(geometry, shader);
+ actor.AddRenderer(renderer2);
+
+ actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
+ actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
+ actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
+
+ 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(), 2, TEST_LOCATION);
+
+ // Aligned by 16
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, 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);
+
+ // Make renderer2 dirty
+ renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
+
+ application.SendNotification();
+
+ // The damaged rect should be the actor area
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ 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);
+
+ // Make renderer2 dirty
+ renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
+
+ application.SendNotification();
+
+ // The damaged rect should be the actor area
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ 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);
+
+ END_TEST;
+}
+
+int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Actor actor = CreateRenderableActor();
+ actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
+ actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
+ actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor);
+
+ // Create another actor which has the same renderer with actor1
+ Actor actor2 = Actor::New();
+ Renderer renderer = actor.GetRendererAt(0);
+ actor2.AddRenderer(renderer);
+ actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
+ actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
+ actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor2);
+
+ 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(), 2, TEST_LOCATION);
+
+ // Aligned by 16
+ Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, 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);
// Ensure the damaged rect is empty
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
- // Add the Renderer again
- actor.AddRenderer(renderer);
+ // Make renderer dirty
+ renderer[DevelRenderer::Property::OPACITY] = 0.5f;
application.SendNotification();
// The damaged rect should be the actor area
damagedRects.clear();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+ DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
+ DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
+
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
- DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], 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);
END_TEST;
}
tet_result(TET_FAIL);
}
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliActorCalculateWorldTransform01(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor position inheritance produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ Vector3 worldPos;
+ Vector3 worldScale;
+ Quaternion worldRotation;
+ m.GetTransformComponents(worldPos, worldRotation, worldScale);
+ DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform02(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor position produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ leafActor[Actor::Property::INHERIT_POSITION] = false;
+ leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
+ leafActor[Actor::Property::INHERIT_SCALE] = false;
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform03(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor position produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ leafActor[Actor::Property::INHERIT_POSITION] = true;
+ leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
+ leafActor[Actor::Property::INHERIT_SCALE] = false;
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform04(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform05(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance of scale produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ leafActor[Actor::Property::INHERIT_POSITION] = false;
+ leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform06(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance of scale produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
+ branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ leafActor[Actor::Property::INHERIT_POSITION] = false;
+ leafActor[Actor::Property::INHERIT_SCALE] = false;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform07(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance of scale produces right transform matrix");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ // Set anchor point to the same value as parent origin
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+
+ // This should be ignored.
+ leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+
+ branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
+ branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
+ leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
+
+ leafActor[Actor::Property::INHERIT_POSITION] = false;
+ leafActor[Actor::Property::INHERIT_SCALE] = false;
+ leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldTransform08(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance of scale produces right transform matrix");
+
+ Vector3 solutions[] = {Vector3(250, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(400, 250, 0), Vector3(200, -50, 0), Vector3(500, 200, 0)};
+
+ struct TestCase
+ {
+ bool translation;
+ bool rotation;
+ bool scaling;
+ };
+ TestCase testCases[] = {
+ {false, false, true},
+ {false, true, false},
+ {true, false, false},
+ {false, true, true},
+ {true, false, true},
+ {true, true, false},
+ {false, false, false},
+ {true, true, true},
+ };
+
+ Actor rootActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(1.0f, 2.0f, 1.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+ rootActor[Actor::Property::SIZE] = Vector2(200, 400);
+ rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+
+ leafActor[Actor::Property::POSITION] = Vector3(0.0f, -50.0f, 0.0f);
+ leafActor[Actor::Property::SCALE] = Vector3(1.0f, 1.0f, 1.0f);
+ leafActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+ leafActor[Actor::Property::SIZE] = Vector2(200, 400);
+ leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER;
+ leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_CENTER;
+ leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(leafActor);
+
+ for(uint32_t i = 0; i < 8; ++i)
+ {
+ leafActor[Actor::Property::INHERIT_POSITION] = testCases[i].translation;
+ leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
+ leafActor[Actor::Property::INHERIT_SCALE] = testCases[i].scaling;
+
+ application.SendNotification();
+ application.Render(0);
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix m = DevelActor::GetWorldTransform(leafActor);
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+
+ Vector3 worldPosition1 = Vector3(m.GetTranslation());
+ Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
+
+ DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldColor01(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor inheritance of color produces right final color");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ 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);
+ leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
+
+ // Default is to inherit:
+ leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 color = DevelActor::GetWorldColor(leafActor);
+
+ Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
+ DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldColor02(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor uses own color");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ 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);
+ leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
+
+ leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 color = DevelActor::GetWorldColor(leafActor);
+
+ Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
+ DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldColor03(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor uses parent color");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
+ branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
+ leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
+
+ leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 color = DevelActor::GetWorldColor(leafActor);
+
+ Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
+ DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliActorCalculateWorldColor04(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test that actor blends with parent color");
+
+ Actor rootActor = Actor::New();
+ Actor branchActor = Actor::New();
+ Actor leafActor = Actor::New();
+
+ rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
+ rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
+ rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
+
+ rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
+ rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
+ branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
+ leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
+
+ leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
+
+ application.GetScene().Add(rootActor);
+ rootActor.Add(branchActor);
+ branchActor.Add(leafActor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Vector4 color = DevelActor::GetWorldColor(leafActor);
+
+ Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
+ DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
+
+ END_TEST;
+}