Safeguard when Actor size is too big. 40/31040/7
authorFrancisco Santos <f1.santos@samsung.com>
Fri, 28 Nov 2014 18:47:25 +0000 (18:47 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Tue, 2 Dec 2014 11:06:50 +0000 (03:06 -0800)
Change-Id: I21355ac8041a137ad5c6bb0feb89965a280c0326

automated-tests/.gitignore
automated-tests/src/dali/utc-Dali-ImageActor.cpp
dali/integration-api/debug.h
dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp
dali/internal/update/node-attachments/scene-graph-renderable-attachment.h

index f039d8a..39d9377 100644 (file)
@@ -2,3 +2,4 @@
 build
 build.log
 tct*core.h
+results_xml.*
index 25342cc..5b7d430 100644 (file)
@@ -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;
index 8eff3bc..38deddd 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <string>
+#include <sstream>
 #include <list>
 
 // 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)
index c4ee129..c4f3ad3 100644 (file)
@@ -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;
index 1a6ff25..06874af 100644 (file)
@@ -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