Sort overlay actors based on depth index 50/56750/6
authorFerran Sole <ferran.sole@samsung.com>
Tue, 12 Jan 2016 10:28:23 +0000 (10:28 +0000)
committerFerran Sole <ferran.sole@samsung.com>
Wed, 13 Jan 2016 16:15:35 +0000 (08:15 -0800)
Overlay actors were not ordered by depth index for rendering

* Sort overlay actors using same algorithm used by "regular" actors
* Fixed bug in hit test algorithm for overlay actors
* Added test cases to check rendering order of color and overlay actors in 2D layers

Change-Id: I004019faf74a70d3c05502d95c665162cf9f924b

automated-tests/src/dali-devel/utc-Dali-HitTestAlgorithm.cpp
automated-tests/src/dali-devel/utc-Dali-Renderer.cpp
automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp
automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h
dali/internal/event/events/hit-test-algorithm-impl.cpp
dali/internal/update/manager/prepare-render-instructions.cpp

index 633533e..c9edaa4 100644 (file)
@@ -415,3 +415,61 @@ int UtcDaliHitTestAlgorithmStencil(void)
   }
   END_TEST;
 }
+
+int UtcDaliHitTestAlgorithmOverlay(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::HitTestAlgorithm with overlay actors");
+
+  Stage stage = Stage::GetCurrent();
+  RenderTaskList renderTaskList = stage.GetRenderTaskList();
+  RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+  Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+  Vector2 stageSize ( stage.GetSize() );
+  cameraActor.SetOrthographicProjection( stageSize );
+  cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+  Vector2 actorSize( stageSize * 0.5f );
+  // Create two actors with half the size of the stage and set them to be partially overlapping
+  Actor blue = Actor::New();
+  blue.SetDrawMode( DrawMode::OVERLAY_2D );
+  blue.SetName( "Blue" );
+  blue.SetAnchorPoint( AnchorPoint::CENTER );
+  blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
+  blue.SetSize( actorSize );
+  blue.SetZ(30.0f);
+
+  Actor green = Actor::New( );
+  green.SetName( "Green" );
+  green.SetAnchorPoint( AnchorPoint::CENTER );
+  green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
+  green.SetSize( actorSize );
+
+  // Add the actors to the view
+  stage.Add( blue );
+  stage.Add( green );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render(0);
+  application.Render(10);
+
+  HitTestAlgorithm::Results results;
+
+  //Hit in the intersection. Should pick the blue actor since it is an overlay.
+  HitTest(stage, stageSize / 2.0f, results, &DefaultIsActorTouchableFunction);
+  DALI_TEST_CHECK( results.actor == blue );
+  DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION );
+
+  //Hit in the blue actor
+  HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
+  DALI_TEST_CHECK( results.actor == blue );
+  DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+
+  //Hit in the green actor
+  HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
+  DALI_TEST_CHECK( results.actor == green );
+  DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+  END_TEST;
+}
index 1d28209..75fe780 100644 (file)
@@ -884,3 +884,389 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void)
 
   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;
+}
index 921088b..bda38d3 100644 (file)
@@ -84,7 +84,6 @@ int TraceCallStack::CountMethod(std::string method) const
   return numCalls;
 }
 
-
 /**
  * Search for a method in the stack with the given parameter list
  * @param[in] method The name of the method
@@ -93,16 +92,27 @@ int TraceCallStack::CountMethod(std::string method) const
  */
 bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const
 {
-  bool found = false;
+  return FindIndexFromMethodAndParams( method, params ) > -1;
+}
+
+/**
+ * Search for a method in the stack with the given parameter list
+ * @param[in] method The name of the method
+ * @param[in] params A comma separated list of parameter values
+ * @return index in the stack where the method was found or -1 otherwise
+ */
+int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const
+{
+  int index = -1;
   for( size_t i=0; i < mCallStack.size(); i++ )
   {
     if( 0 == mCallStack[i][0].compare(method) && 0 == mCallStack[i][1].compare(params) )
     {
-      found = true;
+      index = i;
       break;
     }
   }
-  return found;
+  return index;
 }
 
 /**
index 25b77f8..d319487 100644 (file)
@@ -78,6 +78,14 @@ public:
   bool FindMethodAndParams(std::string method, std::string params) const;
 
   /**
+   * Search for a method in the stack with the given parameter list
+   * @param[in] method The name of the method
+   * @param[in] params A comma separated list of parameter values
+   * @return index in the stack where the method was found or -1 otherwise
+   */
+  int FindIndexFromMethodAndParams(std::string method, std::string params) const;
+
+  /**
    * Test if the given method and parameters are at a given index in the stack
    * @param[in] index Index in the call stack
    * @param[in] method Name of method to test
index 604f71e..5c77ccc 100644 (file)
@@ -170,6 +170,7 @@ HitActor HitTestWithinLayer( Actor& actor,
                              HitTestInterface& hitCheck,
                              bool& stencilOnLayer,
                              bool& stencilHit,
+                             bool& overlayHit,
                              bool parentIsStencil,
                              bool layerIs3d )
 {
@@ -212,25 +213,38 @@ HitActor HitTestWithinLayer( Actor& actor,
           }
           else
           {
-            hit.actor = &actor;
-            hit.x = hitPointLocal.x;
-            hit.y = hitPointLocal.y;
-            hit.distance = distance;
-            hit.depth = actor.GetHierarchyDepth() * Dali::Layer::TREE_DEPTH_MULTIPLIER;
-
-            if ( actor.GetRendererCount() > 0 )
+            if( overlayHit && !actor.IsOverlay() )
+            {
+              //If we have already hit an overlay and current actor is not an overlay
+              //ignore current actor
+            }
+            else
             {
-              //Get renderer with maximum depth
-              int rendererMaxDepth(actor.GetRendererAt( 0 ).Get()->GetDepthIndex());
-              for( unsigned int i(1); i<actor.GetRendererCount(); ++i)
+              if( actor.IsOverlay() )
+              {
+                overlayHit = true;
+              }
+
+              hit.actor = &actor;
+              hit.x = hitPointLocal.x;
+              hit.y = hitPointLocal.y;
+              hit.distance = distance;
+              hit.depth = actor.GetHierarchyDepth() * Dali::Layer::TREE_DEPTH_MULTIPLIER;
+
+              if ( actor.GetRendererCount() > 0 )
               {
-                int depth = actor.GetRendererAt( i ).Get()->GetDepthIndex();
-                if( depth > rendererMaxDepth )
+                //Get renderer with maximum depth
+                int rendererMaxDepth(actor.GetRendererAt( 0 ).Get()->GetDepthIndex());
+                for( unsigned int i(1); i<actor.GetRendererCount(); ++i)
                 {
-                  rendererMaxDepth = depth;
+                  int depth = actor.GetRendererAt( i ).Get()->GetDepthIndex();
+                  if( depth > rendererMaxDepth )
+                  {
+                    rendererMaxDepth = depth;
+                  }
                 }
+                hit.depth += rendererMaxDepth;
               }
-              hit.depth += rendererMaxDepth;
             }
           }
         }
@@ -271,6 +285,7 @@ HitActor HitTestWithinLayer( Actor& actor,
                                                   hitCheck,
                                                   stencilOnLayer,
                                                   stencilHit,
+                                                  overlayHit,
                                                   isStencil,
                                                   layerIs3d) );
 
@@ -425,6 +440,7 @@ bool HitTestRenderTask( const Vector< RenderTaskList::Exclusive >& exclusives,
         HitActor hit;
         bool stencilOnLayer = false;
         bool stencilHit = false;
+        bool overlayHit = false;
         bool layerConsumesHit = false;
 
         const Vector2& stageSize = stage.GetSize();
@@ -435,6 +451,7 @@ bool HitTestRenderTask( const Vector< RenderTaskList::Exclusive >& exclusives,
           HitActor previousHit = hit;
           stencilOnLayer = false;
           stencilHit = false;
+          overlayHit = false;
 
           // Ensure layer is touchable (also checks whether ancestors are also touchable)
           if ( IsActuallyHittable ( *layer, screenCoordinates, stageSize, hitCheck ) )
@@ -453,6 +470,7 @@ bool HitTestRenderTask( const Vector< RenderTaskList::Exclusive >& exclusives,
                                         hitCheck,
                                         stencilOnLayer,
                                         stencilHit,
+                                        overlayHit,
                                         false,
                                         layer->GetBehavior() == Dali::Layer::LAYER_3D);
             }
@@ -469,6 +487,7 @@ bool HitTestRenderTask( const Vector< RenderTaskList::Exclusive >& exclusives,
                                         hitCheck,
                                         stencilOnLayer,
                                         stencilHit,
+                                        overlayHit,
                                         false,
                                         layer->GetBehavior() == Dali::Layer::LAYER_3D);
             }
index 1de18bd..cf13cb6 100644 (file)
@@ -252,12 +252,13 @@ bool CompareItems3D( const RendererWithSortAttributes& lhs, const RendererWithSo
 }
 
 /**
- * Sort color render items
- * @param colorRenderList to sort
+ * Sort render items
+ * @param bufferIndex The buffer to read from
+ * @param renderList to sort
  * @param layer where the renderers are from
  * @param sortingHelper to use for sorting the renderitems (to avoid reallocating)
  */
-inline void SortColorRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, RendererSortingHelper& sortingHelper )
+inline void SortRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, RendererSortingHelper& sortingHelper )
 {
   const size_t renderableCount = renderList.Count();
   // reserve space if needed
@@ -365,7 +366,7 @@ inline void AddColorRenderers( BufferIndex updateBufferIndex,
   }
 
   AddRenderersToRenderList( updateBufferIndex, renderList, layer.colorRenderables, viewMatrix, cameraAttachment, layer.GetBehavior() == Dali::Layer::LAYER_3D, cull );
-  SortColorRenderItems( updateBufferIndex, renderList, layer, sortingHelper );
+  SortRenderItems( updateBufferIndex, renderList, layer, sortingHelper );
 
   //Set render flags
   unsigned int flags = 0u;
@@ -412,6 +413,7 @@ inline void AddOverlayRenderers( BufferIndex updateBufferIndex,
                                  SceneGraph::CameraAttachment& cameraAttachment,
                                  bool stencilRenderablesExist,
                                  RenderInstruction& instruction,
+                                 RendererSortingHelper& sortingHelper,
                                  bool tryReuseRenderList,
                                  bool cull )
 {
@@ -435,6 +437,7 @@ inline void AddOverlayRenderers( BufferIndex updateBufferIndex,
     }
   }
   AddRenderersToRenderList( updateBufferIndex, overlayRenderList, layer.overlayRenderables, viewMatrix, cameraAttachment, layer.GetBehavior() == Dali::Layer::LAYER_3D, cull );
+  SortRenderItems( updateBufferIndex, overlayRenderList, layer, sortingHelper );
 }
 
 /**
@@ -522,7 +525,7 @@ void PrepareRenderInstruction( BufferIndex updateBufferIndex,
     if ( overlayRenderablesExist )
     {
       AddOverlayRenderers( updateBufferIndex, layer, viewMatrix, cameraAttachment, stencilRenderablesExist,
-                           instruction, tryReuseRenderList, cull );
+                           instruction, sortingHelper, tryReuseRenderList, cull );
     }
   }