From 308967f3c2a3d7942a40e8dbe6463a85ce0cb389 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Thu, 17 Apr 2014 18:29:41 +0400 Subject: [PATCH] Optimize HitTestWithinLayer (20% faster HitTest). Whenever a temporary HitActor structure instance is created, constructor and destructor functions are called for its .actor field. In certain scenarios this results in creating and instantly deleting around 1000 dummy Actor objects during a single call of HitTest(). HitTestWithinLayer is an important bottleneck in such scenarios, second only to UpdateNodesAndAttachments (depending on the touchevent:framerate ratio). This change makes the test around 20% faster and additionally reduces power consumption. Change-Id: Iad9f59f39f6229516f036cc49025c2e0ef72ad3d --- dali/internal/event/events/hit-test-algorithm-impl.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dali/internal/event/events/hit-test-algorithm-impl.cpp b/dali/internal/event/events/hit-test-algorithm-impl.cpp index 5077f70..7ebf256 100644 --- a/dali/internal/event/events/hit-test-algorithm-impl.cpp +++ b/dali/internal/event/events/hit-test-algorithm-impl.cpp @@ -48,7 +48,8 @@ namespace struct HitActor { HitActor() - : x( 0 ), + : actor( NULL ), + x( 0 ), y( 0 ), distance( std::numeric_limits::max() ), overlay( false ) @@ -56,7 +57,7 @@ struct HitActor } - Dali::Actor actor; ///< the actor hit. (if actor hit, then initialised) + Actor *actor; ///< the actor hit. (if actor hit, then initialised) float x; ///< x position of hit (only valid if actor valid) float y; ///< y position of hit (only valid if actor valid) float distance; ///< distance from ray origin to hit actor @@ -159,7 +160,7 @@ HitActor HitTestWithinLayer( Actor& actor, } else { - hit.actor = Dali::Actor(&actor); + hit.actor = &actor; hit.x = hitPointLocal.x; hit.y = hitPointLocal.y; hit.distance = distance; @@ -370,7 +371,7 @@ bool HitTestRenderTask( LayerList& layers, if ( hit.actor ) { results.renderTask = Dali::RenderTask(&renderTask); - results.actor = hit.actor; + results.actor = Dali::Actor(hit.actor); results.actorCoordinates.x = hit.x; results.actorCoordinates.y = hit.y; return true; // Success -- 2.7.4