/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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 <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali/devel-api/events/hit-test-algorithm.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali-test-suite-utils.h>
#include <dali/integration-api/debug.h>
#include <test-native-image.h>
tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- ids.push_back( 7 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
newActor.SetSize(1,1);
DALI_TEST_CHECK( task.GetSourceActor() != actor );
DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Update & Render nothing!
application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
END_TEST;
}
Stage stage = Stage::GetCurrent();
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- ids.push_back( 7 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
Actor nonRenderableActor = Actor::New();
stage.Add( nonRenderableActor );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Stop the newActor from being rendered by changing the source actor
DALI_TEST_CHECK( nonRenderableActor );
task.SetSourceActor( nonRenderableActor );
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
+ drawTrace.Reset();
// Set newActor as the new source Actor
task.SetSourceActor( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
END_TEST;
}
tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- GLuint expectedTextureId( 3 );
- ids.push_back( expectedTextureId );
- application.GetGlAbstraction().SetNextTextureIds( ids );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
// Don't add newActor to stage yet //'
// Update & Render with the actor initially off-stage
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
// Now add to stage
stage.Add( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
+ drawTrace.Reset();
// Now remove from stage
stage.Remove( newActor );
// Update & Render with the actor off-stage
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
+
END_TEST;
}
tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- GLuint expectedTextureId( 5 );
- ids.push_back( expectedTextureId );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
newActor.SetSize(1,1);
task.SetSourceActor( Actor() );
DALI_TEST_CHECK( ! task.GetSourceActor() );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Update & Render nothing!
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
// Set with non-empty handle
task.SetSourceActor( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
END_TEST;
}
// Set by Property test
Vector2 newPosition2(32.0f, 32.0f);
task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition, TEST_LOCATION ); // still the old position
// Update
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
Vector2 newPosition3(64.0f, 0.0f);
Animation animation = Animation::New(1.0f);
animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR );
animation.Play();
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition2, TEST_LOCATION );
+
// Perform 1000ms worth of updates at which point animation should have completed.
Wait(application, 1000);
DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_POSITION ), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
END_TEST;
}
// Set by Property test
Vector2 newSize2(50.0f, 50.0f);
task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize, TEST_LOCATION ); // still the old position
// Update
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
Vector2 newSize3(10.0f, 10.0f);
Animation animation = Animation::New(1.0f);
animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR );
animation.Play();
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize2, TEST_LOCATION );
+
// Perform 1000ms worth of updates at which point animation should have completed.
Wait(application, 1000);
DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector2 >( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector2 >( RenderTask::Property::VIEWPORT_SIZE ), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
END_TEST;
}
DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
+ DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor, TEST_LOCATION ); // still the old color
// Wait a frame.
Wait(application);
DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
+
+ Vector4 newColor3(10.0f, 10.0f, 20.0f, 30.0f);
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo( Property( task, RenderTask::Property::CLEAR_COLOR ), newColor3, AlphaFunction::LINEAR );
+ animation.Play();
+
+ DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), testColor2, TEST_LOCATION );
+
+ // Perform 1000ms worth of updates at which point animation should have completed.
+ Wait(application, 1000);
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< Vector4 >( task, RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+ DALI_TEST_EQUALS( task.GetProperty< Vector4 >( RenderTask::Property::CLEAR_COLOR ), newColor3, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
END_TEST;
}
application.SendNotification();
+ //Both render tasks are executed.
DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
DALI_TEST_CHECK( firstFinished == false );
DALI_TEST_CHECK( secondFinished == false );
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
+ //Nothing else to render and both render task should have finished now
+ DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__ ) );
DALI_TEST_CHECK( firstFinished == true );
- DALI_TEST_CHECK( secondFinished == false );
-
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, secondFinished, true, false, __LINE__ ) );
DALI_TEST_CHECK( secondFinished == true );
END_TEST;
END_TEST;
}
+
+int UtcDaliRenderTaskRequiresSync(void)
+{
+ TestApplication application;
+ RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+
+ RenderTask newTask = taskList.CreateTask();
+ newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, false );
+
+ DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( newTask, RenderTask::Property::REQUIRES_SYNC ), false, TEST_LOCATION );
+
+ newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
+
+ DALI_TEST_EQUALS( newTask.GetProperty< bool >( RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelHandle::GetCurrentProperty< bool >( newTask, RenderTask::Property::REQUIRES_SYNC ), true, TEST_LOCATION );
+
+ END_TEST;
+}