END_TEST;
}
+
+
+int UtcDaliRendererRenderOrder2DLayer(void)
+{
+ TestApplication application;
+ tet_infoline("Test the rendering order in a 2D layer is correct");
+
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+ Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+
+ Actor actor0 = Actor::New();
+ actor0.SetAnchorPoint(AnchorPoint::CENTER);
+ actor0.SetParentOrigin(AnchorPoint::CENTER);
+ actor0.SetPosition(0.0f,0.0f);
+ Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material0 = Material::New( shader );
+ material0.AddTexture( image0, "sTexture0" );
+ Renderer renderer0 = Renderer::New( geometry, material0 );
+ actor0.AddRenderer(renderer0);
+ actor0.SetSize(1, 1);
+ Stage::GetCurrent().Add(actor0);
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor1 = Actor::New();
+ actor1.SetAnchorPoint(AnchorPoint::CENTER);
+ actor1.SetParentOrigin(AnchorPoint::CENTER);
+ actor1.SetPosition(0.0f,0.0f);
+ Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material1 = Material::New( shader );
+ material1.AddTexture( image1, "sTexture1" );
+ Renderer renderer1 = Renderer::New( geometry, material1 );
+ actor1.AddRenderer(renderer1);
+ actor1.SetSize(1, 1);
+ Stage::GetCurrent().Add(actor1);
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor2 = Actor::New();
+ actor2.SetAnchorPoint(AnchorPoint::CENTER);
+ actor2.SetParentOrigin(AnchorPoint::CENTER);
+ actor2.SetPosition(0.0f,0.0f);
+ Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material2 = Material::New( shader );
+ material2.AddTexture( image2, "sTexture2" );
+ Renderer renderer2 = Renderer::New( geometry, material2 );
+ actor2.AddRenderer(renderer2);
+ actor2.SetSize(1, 1);
+ Stage::GetCurrent().Add(actor2);
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor3 = Actor::New();
+ actor3.SetAnchorPoint(AnchorPoint::CENTER);
+ actor3.SetParentOrigin(AnchorPoint::CENTER);
+ actor3.SetPosition(0.0f,0.0f);
+ Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material3 = Material::New( shader );
+ material3.AddTexture( image3, "sTexture3" );
+ Renderer renderer3 = Renderer::New( geometry, material3 );
+ actor3.AddRenderer(renderer3);
+ actor3.SetSize(1, 1);
+ Stage::GetCurrent().Add(actor3);
+ application.SendNotification();
+ application.Render(0);
+
+ /*
+ * Create the following hierarchy:
+ *
+ * actor2
+ * /
+ * /
+ * actor1
+ * /
+ * /
+ * actor0
+ * /
+ * /
+ * actor3
+ *
+ * Expected rendering order : actor2 - actor1 - actor0 - actor3
+ */
+ actor2.Add(actor1);
+ actor1.Add(actor0);
+ actor0.Add(actor3);
+ application.SendNotification();
+ application.Render(0);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.EnableTextureCallTrace(true);
+ application.SendNotification();
+ application.Render(0);
+
+ int textureBindIndex[4];
+ for( unsigned int i(0); i<4; ++i )
+ {
+ std::stringstream params;
+ params << GL_TEXTURE_2D<<", "<<i+1;
+ textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
+ }
+
+ //Check that actor1 has been rendered after actor2
+ DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
+
+ //Check that actor0 has been rendered after actor1
+ DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
+
+ //Check that actor3 has been rendered after actor0
+ DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
+{
+ TestApplication application;
+ tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
+
+ /*
+ * Creates the following hierarchy:
+ *
+ * actor0------------------------>actor1
+ * / | \ / | \
+ * / | \ / | \
+ * / | \ / | \
+ * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
+ *
+ * renderer0 has depth index 2
+ * renderer1 has depth index 0
+ * renderer2 has depth index 1
+ *
+ * renderer3 has depth index 1
+ * renderer4 has depth index 0
+ * renderer5 has depth index -1
+ *
+ * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
+ */
+
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+ Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+
+ Actor actor0 = Actor::New();
+ actor0.SetAnchorPoint(AnchorPoint::CENTER);
+ actor0.SetParentOrigin(AnchorPoint::CENTER);
+ actor0.SetPosition(0.0f,0.0f);
+ actor0.SetSize(1, 1);
+ Stage::GetCurrent().Add(actor0);
+
+ Actor actor1 = Actor::New();
+ actor1.SetAnchorPoint(AnchorPoint::CENTER);
+ actor1.SetParentOrigin(AnchorPoint::CENTER);
+ actor1.SetPosition(0.0f,0.0f);
+ actor1.SetSize(1, 1);
+ actor0.Add(actor1);
+
+ //Renderer0
+ Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material0 = Material::New( shader );
+ material0.AddTexture( image0, "sTexture0" );
+ Renderer renderer0 = Renderer::New( geometry, material0 );
+ renderer0.SetDepthIndex( 2 );
+ actor0.AddRenderer(renderer0);
+ application.SendNotification();
+ application.Render(0);
+
+ //Renderer1
+ Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material1 = Material::New( shader );
+ material1.AddTexture( image1, "sTexture1" );
+ Renderer renderer1 = Renderer::New( geometry, material1 );
+ renderer1.SetDepthIndex( 0 );
+ actor0.AddRenderer(renderer1);
+ application.SendNotification();
+ application.Render(0);
+
+ //Renderer2
+ Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material2 = Material::New( shader );
+ material2.AddTexture( image2, "sTexture2" );
+ Renderer renderer2 = Renderer::New( geometry, material2 );
+ renderer2.SetDepthIndex( 1 );
+ actor0.AddRenderer(renderer2);
+ application.SendNotification();
+ application.Render(0);
+
+ //Renderer3
+ Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material3 = Material::New( shader );
+ material3.AddTexture( image3, "sTexture3" );
+ Renderer renderer3 = Renderer::New( geometry, material3 );
+ renderer3.SetDepthIndex( 1 );
+ actor1.AddRenderer(renderer3);
+ application.SendNotification();
+ application.Render(0);
+
+ //Renderer4
+ Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material4 = Material::New( shader );
+ material4.AddTexture( image4, "sTexture4" );
+ Renderer renderer4 = Renderer::New( geometry, material4 );
+ renderer4.SetDepthIndex( 0 );
+ actor1.AddRenderer(renderer4);
+ application.SendNotification();
+ application.Render(0);
+
+ //Renderer5
+ Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material5 = Material::New( shader );
+ material5.AddTexture( image5, "sTexture5" );
+ Renderer renderer5 = Renderer::New( geometry, material5 );
+ renderer5.SetDepthIndex( -1 );
+ actor1.AddRenderer(renderer5);
+ application.SendNotification();
+ application.Render(0);
+
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.EnableTextureCallTrace(true);
+ application.SendNotification();
+ application.Render(0);
+
+ int textureBindIndex[6];
+ for( unsigned int i(0); i<6; ++i )
+ {
+ std::stringstream params;
+ params << GL_TEXTURE_2D<<", "<<i+1;
+ textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
+ }
+
+ //Check that renderer3 has been rendered after renderer4
+ DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
+
+ //Check that renderer0 has been rendered after renderer2
+ DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
+
+ //Check that renderer0 has been rendered after renderer2
+ DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
+
+ //Check that renderer0 has been rendered after renderer2
+ DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
+
+ //Check that renderer2 has been rendered after renderer1
+ DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererRenderOrder2DLayerOverlay(void)
+{
+ TestApplication application;
+ tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
+
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+ Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+
+ Actor actor0 = Actor::New();
+ actor0.SetAnchorPoint(AnchorPoint::CENTER);
+ actor0.SetParentOrigin(AnchorPoint::CENTER);
+ Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material0 = Material::New( shader );
+ material0.AddTexture( image0, "sTexture0" );
+ Renderer renderer0 = Renderer::New( geometry, material0 );
+ actor0.AddRenderer(renderer0);
+ actor0.SetPosition(0.0f,0.0f);
+ actor0.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor0);
+ actor0.SetDrawMode( DrawMode::OVERLAY_2D );
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor1 = Actor::New();
+ actor1.SetAnchorPoint(AnchorPoint::CENTER);
+ actor1.SetParentOrigin(AnchorPoint::CENTER);
+ Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material1 = Material::New( shader );
+ material1.AddTexture( image1, "sTexture1" );
+ Renderer renderer1 = Renderer::New( geometry, material1 );
+ actor1.SetPosition(0.0f,0.0f);
+ actor1.AddRenderer(renderer1);
+ actor1.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor1);
+ actor1.SetDrawMode( DrawMode::OVERLAY_2D );
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor2 = Actor::New();
+ actor2.SetAnchorPoint(AnchorPoint::CENTER);
+ actor2.SetParentOrigin(AnchorPoint::CENTER);
+ Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material2 = Material::New( shader );
+ material2.AddTexture( image2, "sTexture2" );
+ Renderer renderer2 = Renderer::New( geometry, material2 );
+ actor2.AddRenderer(renderer2);
+ actor2.SetPosition(0.0f,0.0f);
+ actor2.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor2);
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor3 = Actor::New();
+ actor3.SetAnchorPoint(AnchorPoint::CENTER);
+ actor3.SetParentOrigin(AnchorPoint::CENTER);
+ Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material3 = Material::New( shader );
+ material3.AddTexture( image3, "sTexture3" );
+ Renderer renderer3 = Renderer::New( geometry, material3 );
+ actor3.SetPosition(0.0f,0.0f);
+ actor3.AddRenderer(renderer3);
+ actor3.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor3);
+ actor3.SetDrawMode( DrawMode::OVERLAY_2D );
+ application.SendNotification();
+ application.Render(0);
+
+ Actor actor4 = Actor::New();
+ actor4.SetAnchorPoint(AnchorPoint::CENTER);
+ actor4.SetParentOrigin(AnchorPoint::CENTER);
+ Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ Material material4 = Material::New( shader );
+ material4.AddTexture( image4, "sTexture4" );
+ Renderer renderer4 = Renderer::New( geometry, material4 );
+ actor4.AddRenderer(renderer4);
+ actor4.SetPosition(0.0f,0.0f);
+ actor4.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor4);
+ application.SendNotification();
+ application.Render(0);
+
+ /*
+ * Create the following hierarchy:
+ *
+ * actor2
+ * (Regular actor)
+ * / \
+ * / \
+ * actor1 actor4
+ * (Overlay) (Regular actor)
+ * /
+ * /
+ * actor0
+ * (Overlay)
+ * /
+ * /
+ * actor3
+ * (Overlay)
+ *
+ * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
+ */
+ Stage::GetCurrent().Add( actor2 );
+ actor2.Add(actor1);
+ actor2.Add(actor4);
+ actor1.Add(actor0);
+ actor0.Add(actor3);
+ application.SendNotification();
+ application.Render(0);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.EnableTextureCallTrace(true);
+ application.SendNotification();
+ application.Render(0);
+
+ int textureBindIndex[5];
+ for( unsigned int i(0); i<5; ++i )
+ {
+ std::stringstream params;
+ params << GL_TEXTURE_2D<<", "<<i+1;
+ textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
+ }
+
+ //Check that actor4 has been rendered after actor2
+ DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
+
+ //Check that actor1 has been rendered after actor4
+ DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
+
+ //Check that actor0 has been rendered after actor1
+ DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
+
+ //Check that actor3 has been rendered after actor0
+ DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
+
+ END_TEST;
+}