From: Francisco Santos Date: Fri, 28 Nov 2014 18:47:25 +0000 (+0000) Subject: Safeguard when Actor size is too big. X-Git-Tag: dali_1.0.20~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0da71ac1a6a3e031ece01a0c6c142f383a6a9ef7;p=platform%2Fcore%2Fuifw%2Fdali-core.git Safeguard when Actor size is too big. Change-Id: I21355ac8041a137ad5c6bb0feb89965a280c0326 --- diff --git a/automated-tests/.gitignore b/automated-tests/.gitignore index f039d8a..39d9377 100644 --- a/automated-tests/.gitignore +++ b/automated-tests/.gitignore @@ -2,3 +2,4 @@ build build.log tct*core.h +results_xml.* diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp index 25342cc..5b7d430 100644 --- a/automated-tests/src/dali/utc-Dali-ImageActor.cpp +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -174,6 +174,33 @@ int UtcDaliImageActorPixelArea(void) END_TEST; } +// Set a size that is too large on an Image with a shader that requires grid +int UtcDaliImageActorSetSize01(void) +{ + TestApplication application; + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + + ShaderEffect effect = ShaderEffect::New( " ", " ", " ", " ", ShaderEffect::HINT_GRID ); + actor.SetShaderEffect( effect ); + + const float INVALID_SIZE = float(1u<<31); + Vector3 vector( INVALID_SIZE, INVALID_SIZE, INVALID_SIZE ); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(vector); + Stage::GetCurrent().Add(actor); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(vector, actor.GetCurrentSize(), TEST_LOCATION ); + END_TEST; +} + int UtcDaliImageActorGetCurrentSize01(void) { TestApplication application; diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index 8eff3bc..38deddd 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include // INTERNAL INCLUDES @@ -345,6 +346,19 @@ public: \ std::string mDebugString; /** + * Print all the actor tree names + **/ +#define DALI_LOG_ACTOR_TREE( node ) { \ + std::stringstream branch; \ + Node* tempNode = node; \ + while( tempNode ) { \ + branch << "<" << tempNode->mDebugString << ">::"; \ + tempNode = tempNode->GetParent(); \ + } \ + DALI_LOG_ERROR_NOFN("Actor tree: %s\n", branch.str().c_str()); \ +} + +/** * Allows one object to set another object's debug string */ #define DALI_LOG_SET_OBJECT_STRING(object, string) (object->mDebugString = string) @@ -373,6 +387,7 @@ public: \ #else // DEBUG_ENABLED #define DALI_LOG_OBJECT_STRING_DECLARATION +#define DALI_LOG_ACTOR_TREE(node) #define DALI_LOG_SET_OBJECT_STRING(object, string) #define DALI_LOG_FMT_OBJECT_STRING(object, fmt, args...) #define DALI_LOG_GET_OBJECT_STRING(object) diff --git a/dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp b/dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp index c4ee129..c4f3ad3 100644 --- a/dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp +++ b/dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp @@ -224,6 +224,30 @@ void RenderableAttachment::RemoveShader( BufferIndex updateBufferIndex ) ShaderChanged( updateBufferIndex ); } +bool RenderableAttachment::ResolveVisibility( BufferIndex updateBufferIndex ) +{ + mHasSizeAndColorFlag = false; + const Vector4& color = mParent->GetWorldColor( updateBufferIndex ); + if( color.a > FULLY_TRANSPARENT ) // not fully transparent + { + const float MAX_NODE_SIZE = float(1u<<30); + const Vector3& size = mParent->GetSize( updateBufferIndex ); + if( ( size.width > Math::MACHINE_EPSILON_1000 ) && // width is greater than a very small number + ( size.height > Math::MACHINE_EPSILON_1000 ) && // height is greater than a very small number + ( size.width < MAX_NODE_SIZE ) && // width is smaller than the maximum allowed size + ( size.height < MAX_NODE_SIZE ) ) // height is smaller than the maximum allowed size + { + mHasSizeAndColorFlag = true; + } + else + { + DALI_LOG_ERROR("Actor size should be bigger than 0 but not bigger than %f.\n", MAX_NODE_SIZE ); + DALI_LOG_ACTOR_TREE( mParent ); + } + } + return mHasSizeAndColorFlag; +} + void RenderableAttachment::DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling ) { scaling = Vector3::ONE; diff --git a/dali/internal/update/node-attachments/scene-graph-renderable-attachment.h b/dali/internal/update/node-attachments/scene-graph-renderable-attachment.h index 1a6ff25..06874af 100644 --- a/dali/internal/update/node-attachments/scene-graph-renderable-attachment.h +++ b/dali/internal/update/node-attachments/scene-graph-renderable-attachment.h @@ -163,21 +163,7 @@ public: // For use during in the update algorithm only * @param[in] updateBufferIndex The current update buffer index. * @return visible tells if this renderer can be potentially seen */ - virtual bool ResolveVisibility( BufferIndex updateBufferIndex ) - { - mHasSizeAndColorFlag = false; - const Vector4& color = mParent->GetWorldColor( updateBufferIndex ); - if( color.a > FULLY_TRANSPARENT ) // not fully transparent - { - const Vector3& size = mParent->GetSize( updateBufferIndex ); - if( ( size.width > Math::MACHINE_EPSILON_1000 )&& // width is greater than a very small number - ( size.height > Math::MACHINE_EPSILON_1000 ) ) // height is greater than a very small number - { - mHasSizeAndColorFlag = true; - } - } - return mHasSizeAndColorFlag; - } + virtual bool ResolveVisibility( BufferIndex updateBufferIndex ); /** * if this renderable actor has visible size and color