Merge "Make sure symbols are visible externally for bullet and chipmunk" into devel...
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 28 Jul 2023 10:34:34 +0000 (10:34 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 28 Jul 2023 10:34:34 +0000 (10:34 +0000)
22 files changed:
automated-tests/resources/test-empty.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy0.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy1.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy2.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy3.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy4.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy5.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy6.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-hierarchy7.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-motion0.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-motion1.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-motion2.bvh [new file with mode: 0644]
automated-tests/resources/test-invalid-motion3.bvh [new file with mode: 0644]
automated-tests/src/dali-scene3d/utc-Dali-BvhLoader.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
dali-scene3d/public-api/loader/bvh-loader.cpp
dali-toolkit/devel-api/visuals/image-visual-properties-devel.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/visual-string-constants.cpp
dali-toolkit/internal/visuals/visual-string-constants.h

diff --git a/automated-tests/resources/test-empty.bvh b/automated-tests/resources/test-empty.bvh
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/automated-tests/resources/test-invalid-hierarchy0.bvh b/automated-tests/resources/test-invalid-hierarchy0.bvh
new file mode 100644 (file)
index 0000000..c8c0cb8
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy1.bvh b/automated-tests/resources/test-invalid-hierarchy1.bvh
new file mode 100644 (file)
index 0000000..be6cd56
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy2.bvh b/automated-tests/resources/test-invalid-hierarchy2.bvh
new file mode 100644 (file)
index 0000000..3bb962a
--- /dev/null
@@ -0,0 +1,18 @@
+HIERARCHY
+ROOT root
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy3.bvh b/automated-tests/resources/test-invalid-hierarchy3.bvh
new file mode 100644 (file)
index 0000000..3ff6a12
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy4.bvh b/automated-tests/resources/test-invalid-hierarchy4.bvh
new file mode 100644 (file)
index 0000000..3175816
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy5.bvh b/automated-tests/resources/test-invalid-hierarchy5.bvh
new file mode 100644 (file)
index 0000000..576adae
--- /dev/null
@@ -0,0 +1,18 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+      OFFSET 0 0 0
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy6.bvh b/automated-tests/resources/test-invalid-hierarchy6.bvh
new file mode 100644 (file)
index 0000000..6f64833
--- /dev/null
@@ -0,0 +1,22 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      {
+        OFFSET 0 0 0
+      }
+    }
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-hierarchy7.bvh b/automated-tests/resources/test-invalid-hierarchy7.bvh
new file mode 100644 (file)
index 0000000..058fde0
--- /dev/null
@@ -0,0 +1,22 @@
+HIERARCHY
+ROOT root
+{
+  {
+    OFFSET 0.0 -0.948831 1.32574
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    JOINT first
+    {
+      OFFSET -0.0 4.130377 -0.008512
+      CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+      End Site
+      {
+        OFFSET 0 0 0
+      }
+    }
+  }
+}
+MOTION
+Frames:        2
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-motion0.bvh b/automated-tests/resources/test-invalid-motion0.bvh
new file mode 100644 (file)
index 0000000..37a8bdc
--- /dev/null
@@ -0,0 +1,21 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frames:        3
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-motion1.bvh b/automated-tests/resources/test-invalid-motion1.bvh
new file mode 100644 (file)
index 0000000..1bba75a
--- /dev/null
@@ -0,0 +1,20 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frames:        1
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-motion2.bvh b/automated-tests/resources/test-invalid-motion2.bvh
new file mode 100644 (file)
index 0000000..c003a2d
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frame Time:    0.3
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
diff --git a/automated-tests/resources/test-invalid-motion3.bvh b/automated-tests/resources/test-invalid-motion3.bvh
new file mode 100644 (file)
index 0000000..0a4a582
--- /dev/null
@@ -0,0 +1,19 @@
+HIERARCHY
+ROOT root
+{
+  OFFSET 0.0 -0.948831 1.32574
+  CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+  JOINT first
+  {
+    OFFSET -0.0 4.130377 -0.008512
+    CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
+    End Site
+    {
+      OFFSET 0 0 0
+    }
+  }
+}
+MOTION
+Frames:        2
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0
\ No newline at end of file
index d642ef4..4fb5a79 100644 (file)
@@ -154,4 +154,37 @@ int UtcDaliLoadBvhFailed02(void)
   AnimationDefinition animDef = LoadBvhFromBuffer(nullptr, 0, "testBvh");
   DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
   END_TEST;
+}
+
+int UtcDaliLoadBvhFailed03(void)
+{
+  TestApplication application;
+
+  tet_infoline("Parse error for hierarchy1");
+  uint32_t caseHierarchyCount = 8;
+  for(uint32_t tc = 0; tc < caseHierarchyCount; ++tc)
+  {
+    tet_printf("Parse error for hierarchy %u\n", tc);
+    std::ostringstream oss;
+    oss << TEST_RESOURCE_DIR << "/test-invalid-hierarchy" << tc << ".bvh";
+    AnimationDefinition animDef = LoadBvh(oss.str(), "testBvh");
+    DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  }
+
+  uint32_t caseMotionCount = 4;
+  for(uint32_t tc = 0; tc < caseMotionCount; ++tc)
+  {
+    tet_printf("Parse error for motion %u\n", tc);
+    std::ostringstream oss;
+    oss << TEST_RESOURCE_DIR << "/test-invalid-motion" << tc << ".bvh";
+    AnimationDefinition animDef = LoadBvh(oss.str(), "testBvh");
+    DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  }
+
+  {
+    tet_infoline("empty file");
+    AnimationDefinition animDef = LoadBvh(TEST_RESOURCE_DIR "/test-empty.bvh", "testBvh");
+    DALI_TEST_EQUALS(0u, animDef.GetPropertyCount(), TEST_LOCATION);
+  }
+  END_TEST;
 }
\ No newline at end of file
index c6a8711..9583e09 100644 (file)
@@ -1961,6 +1961,80 @@ int UtcDaliImageVisualSetInvalidRemoteImage(void)
   END_TEST;
 }
 
+int UtcDaliImageVisualSetInvalidImageWithDisabledBroken(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("Request image visual with invalid images - should draw broken.png");
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK(factory);
+
+  // Load invalid file
+  Property::Map propertyMap;
+  propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+  propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
+
+  Visual::Base visual = factory.CreateVisual(propertyMap);
+  DALI_TEST_CHECK(visual);
+
+  TestGlAbstraction& gl           = application.GetGlAbstraction();
+  TraceCallStack&    textureTrace = gl.GetTextureTrace();
+  textureTrace.Enable(true);
+
+  DummyControl      actor     = DummyControl::New();
+  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+  dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+  actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+  DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+  application.GetScene().Add(actor);
+
+  application.SendNotification();
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+  application.GetScene().Remove(actor);
+  DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+  textureTrace.Reset();
+
+  // Load invalid file with disabled broken
+  propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+  propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
+  propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
+
+  visual = factory.CreateVisual(propertyMap);
+  DALI_TEST_CHECK(visual);
+
+  actor                        = DummyControl::New();
+  DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor.GetImplementation());
+  dummyImpl2.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+  actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+  DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+  application.GetScene().Add(actor);
+
+  application.SendNotification();
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
+
+  application.GetScene().Remove(actor);
+  DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+
+  END_TEST;
+}
+
 int UtcDaliImageVisualAlphaMask01(void)
 {
   ToolkitTestApplication application;
index 3930d33..0c5922b 100644 (file)
@@ -49,6 +49,7 @@ static constexpr std::string_view TOKEN_ROOT                = "ROOT";
 static constexpr std::string_view TOKEN_MOTION              = "MOTION";
 static constexpr std::string_view PROPERTY_NAME_POSITION    = "position";
 static constexpr std::string_view PROPERTY_NAME_ORIENTATION = "orientation";
+static constexpr std::string_view TOKEN_OPENING_BRACE       = "{";
 static constexpr std::string_view TOKEN_CLOSING_BRACE       = "}";
 
 enum class Channel
@@ -87,9 +88,10 @@ void trim(std::string& s)
           s.end());
 }
 
-void ParseHierarchy(std::istream& file, std::shared_ptr<Joint>& joint)
+bool ParseHierarchy(std::istream& file, std::shared_ptr<Joint>& joint)
 {
   std::string line;
+  bool        braceExist = false;
   while(std::getline(file, line))
   {
     trim(line);
@@ -142,24 +144,68 @@ void ParseHierarchy(std::istream& file, std::shared_ptr<Joint>& joint)
       joint->children.push_back(child);
       std::getline(stream, token, ' ');
       child->name = token;
-      ParseHierarchy(file, child);
+
+      if(DALI_UNLIKELY(!ParseHierarchy(file, child)))
+      {
+        return false;
+      }
     }
     else if(line == TOKEN_END_SITE.data())
     {
+      bool braceExistEndSite = false;
       while(std::getline(file, line))
       {
         trim(line);
-        if(line == TOKEN_CLOSING_BRACE.data())
+        if(line == TOKEN_OPENING_BRACE.data())
+        {
+          if(DALI_UNLIKELY(braceExistEndSite))
+          {
+            DALI_LOG_ERROR("Parsing error : Joint[%s] End Site opening brace not matched\n", joint->name.c_str());
+            return false;
+          }
+          braceExistEndSite = true;
+        }
+        else if(line == TOKEN_CLOSING_BRACE.data())
         {
+          if(DALI_UNLIKELY(!braceExistEndSite))
+          {
+            DALI_LOG_ERROR("Parsing error : Joint[%s] End Site closing brace not matched\n", joint->name.c_str());
+            return false;
+          }
           break;
         }
       }
+      if(DALI_UNLIKELY(!braceExistEndSite))
+      {
+        DALI_LOG_ERROR("Parsing error : Joint[%s] End Site opening brace not exist\n", joint->name.c_str());
+        return false;
+      }
+    }
+    else if(token == TOKEN_OPENING_BRACE.data())
+    {
+      if(DALI_UNLIKELY(braceExist))
+      {
+        DALI_LOG_ERROR("Parsing error : Joint[%s] opening brace not matched\n", joint->name.c_str());
+        return false;
+      }
+      braceExist = true;
     }
     else if(token == TOKEN_CLOSING_BRACE.data())
     {
+      if(DALI_UNLIKELY(!braceExist))
+      {
+        DALI_LOG_ERROR("Parsing error : Joint[%s] closing brace not matched\n", joint->name.c_str());
+        return false;
+      }
       break;
     }
   }
+  if(DALI_UNLIKELY(!braceExist))
+  {
+    DALI_LOG_ERROR("Parsing error : Joint[%s] opening brace not exist\n", joint->name.c_str());
+    return false;
+  }
+  return true;
 }
 
 void MakeList(std::shared_ptr<Joint>& joint, std::vector<std::shared_ptr<Joint>>& jointList)
@@ -171,7 +217,7 @@ void MakeList(std::shared_ptr<Joint>& joint, std::vector<std::shared_ptr<Joint>>
   }
 }
 
-void ParseMotion(std::istream& file, std::shared_ptr<Joint>& hierarchy, uint32_t& frameCount, float& frameTime)
+bool ParseMotion(std::istream& file, std::shared_ptr<Joint>& hierarchy, uint32_t& frameCount, float& frameTime)
 {
   std::vector<std::shared_ptr<Joint>> jointList;
   MakeList(hierarchy, jointList);
@@ -198,10 +244,33 @@ void ParseMotion(std::istream& file, std::shared_ptr<Joint>& hierarchy, uint32_t
     }
   }
 
+  if(DALI_UNLIKELY(!frameCountLoaded))
+  {
+    DALI_LOG_ERROR("Parsing error : Frames not exist!\n");
+    return false;
+  }
+  if(DALI_UNLIKELY(!frameTimeLoaded))
+  {
+    DALI_LOG_ERROR("Parsing error : Frame Time not exist!\n");
+    return false;
+  }
+
+  uint32_t loadedFrameCount = 0u;
+
   while(std::getline(file, line))
   {
     trim(line);
+    if(DALI_UNLIKELY(line.empty()))
+    {
+      continue;
+    }
     std::istringstream stream(line);
+    if(DALI_UNLIKELY(++loadedFrameCount > frameCount))
+    {
+      // Parse failed. Just skip decoding, and get the number of line for debug.
+      continue;
+    }
+
     for(auto&& joint : jointList)
     {
       Vector3    translation;
@@ -243,11 +312,21 @@ void ParseMotion(std::istream& file, std::shared_ptr<Joint>& hierarchy, uint32_t
       joint->rotations.push_back(rotation[2] * rotation[0] * rotation[1]);
     }
   }
+
+  if(DALI_UNLIKELY(loadedFrameCount != frameCount))
+  {
+    DALI_LOG_ERROR("Parsing error : Motion frame count not matched! expect : %u, loaded : %u\n", frameCount, loadedFrameCount);
+    return false;
+  }
+
+  return true;
 }
 
 bool ParseBvh(std::istream& file, uint32_t& frameCount, float& frameTime, std::shared_ptr<Joint>& rootJoint)
 {
   std::string line;
+  bool        parseHierarchy = false;
+  bool        parseMotion    = false;
   while(std::getline(file, line))
   {
     trim(line);
@@ -267,17 +346,17 @@ bool ParseBvh(std::istream& file, uint32_t& frameCount, float& frameTime, std::s
         {
           std::getline(stream, token, ' ');
           rootJoint->name = token;
-          ParseHierarchy(file, rootJoint);
+          parseHierarchy  = ParseHierarchy(file, rootJoint);
           break;
         }
       }
     }
     if(token == TOKEN_MOTION.data())
     {
-      ParseMotion(file, rootJoint, frameCount, frameTime);
+      parseMotion = ParseMotion(file, rootJoint, frameCount, frameTime);
     }
   }
-  return true;
+  return parseHierarchy && parseMotion;
 }
 
 AnimationDefinition GenerateAnimation(const std::string& animationName, std::shared_ptr<Joint>& hierarchy, uint32_t frameCount, float frameTime, const Vector3& scale)
index 9e6d199..3c0e7d6 100644 (file)
@@ -155,7 +155,15 @@ enum Type
    * So we change its value to MASKING_ON_RENDERING even if the visual sets the MASKING_TYPE as MASKING_ON_LOADING when it uses external texture.
    * @note It is used in the ImageVisual and AnimatedImageVisual. The default is MASKING_ON_LOADING.
    */
-  MASKING_TYPE = ORIENTATION_CORRECTION + 12
+  MASKING_TYPE = ORIENTATION_CORRECTION + 12,
+
+  /**
+   * @brief Whether to enable broken image in image visual.
+   * Some of visual don't need to show broken image(ex. placeholder)
+   * Disable broken image for these visuals.
+   * default is true.
+   */
+  ENABLE_BROKEN_IMAGE = ORIENTATION_CORRECTION + 14
 };
 
 } //namespace Property
index 5f58fe3..87ab126 100644 (file)
@@ -611,6 +611,7 @@ void ImageView::CreatePlaceholderImage()
   propertyMap.Insert(Toolkit::ImageVisual::Property::URL, mPlaceholderUrl);
   //propertyMap.Insert(Toolkit::ImageVisual::Property::LOAD_POLICY, Toolkit::ImageVisual::LoadPolicy::IMMEDIATE); // TODO: need to enable this property
   propertyMap.Insert(Toolkit::ImageVisual::Property::RELEASE_POLICY, Toolkit::ImageVisual::ReleasePolicy::DESTROYED);
+  propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
   mPlaceholderVisual = Toolkit::VisualFactory::Get().CreateVisual(propertyMap);
   if(mPlaceholderVisual)
   {
index 8adcb32..18cf2b4 100644 (file)
@@ -168,7 +168,8 @@ ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
   mAtlasRectSize(0, 0),
   mLoadState(TextureManager::LoadState::NOT_STARTED),
   mAttemptAtlasing(false),
-  mOrientationCorrection(true)
+  mOrientationCorrection(true),
+  mEnableBrokenImage(true)
 {
   EnablePreMultipliedAlpha(mFactoryCache.GetPreMultiplyOnLoad());
 }
@@ -266,6 +267,10 @@ void ImageVisual::DoSetProperties(const Property::Map& propertyMap)
       {
         DoSetProperty(Toolkit::DevelImageVisual::Property::MASKING_TYPE, keyValue.second);
       }
+      else if(keyValue.first == ENABLE_BROKEN_IMAGE)
+      {
+        DoSetProperty(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, keyValue.second);
+      }
       else if(keyValue.first == LOAD_POLICY_NAME)
       {
         DoSetProperty(Toolkit::ImageVisual::Property::LOAD_POLICY, keyValue.second);
@@ -438,6 +443,16 @@ void ImageVisual::DoSetProperty(Property::Index index, const Property::Value& va
       break;
     }
 
+    case Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE:
+    {
+      bool enableBrokenImage(mEnableBrokenImage);
+      if(value.Get(enableBrokenImage))
+      {
+        mEnableBrokenImage = enableBrokenImage;
+      }
+      break;
+    }
+
     case Toolkit::ImageVisual::Property::RELEASE_POLICY:
     {
       int releasePolicy = 0;
@@ -762,17 +777,7 @@ void ImageVisual::DoSetOnScene(Actor& actor)
   }
   else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
   {
-    Vector2 imageSize = Vector2::ZERO;
-    if(actor)
-    {
-      imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
-      mPlacementActorSize = imageSize;
-    }
-
-    mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
-    actor.AddRenderer(mImpl->mRenderer);
-    mPlacementActor.Reset();
-
+    ShowBrokenImage();
     ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
   }
 }
@@ -785,14 +790,7 @@ void ImageVisual::DoSetOffScene(Actor& actor)
   actor.RemoveRenderer(mImpl->mRenderer);
   if(mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED)
   {
-    RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
-    mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
-
-    TextureSet textureSet = TextureSet::New();
-    mImpl->mRenderer.SetTextures(textureSet);
-    ComputeTextureSize();
-
-    mLoadState = TextureManager::LoadState::NOT_STARTED;
+    ResetRenderer();
   }
 
   mPlacementActor.Reset();
@@ -912,18 +910,7 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
     Actor actor = mPlacementActor.GetHandle();
     if(!loadingSuccess)
     {
-      Vector2 imageSize = Vector2::ZERO;
-      if(actor)
-      {
-        imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
-        mPlacementActorSize = imageSize;
-      }
-      else
-      {
-        imageSize = mPlacementActorSize;
-      }
-
-      mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+      ShowBrokenImage();
       textureInformation.textureSet = mImpl->mRenderer.GetTextures();
     }
     else
@@ -947,13 +934,13 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
           UpdateShader();
         }
       }
-    }
 
-    if(actor)
-    {
-      actor.AddRenderer(mImpl->mRenderer);
-      // reset the weak handle so that the renderer only get added to actor once
-      mPlacementActor.Reset();
+      if(actor)
+      {
+        actor.AddRenderer(mImpl->mRenderer);
+        // reset the weak handle so that the renderer only get added to actor once
+        mPlacementActor.Reset();
+      }
     }
   }
 
@@ -1190,6 +1177,44 @@ void ImageVisual::CheckMaskTexture()
   }
 }
 
+void ImageVisual::ResetRenderer()
+{
+  RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
+  mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+  TextureSet textureSet = TextureSet::New();
+  mImpl->mRenderer.SetTextures(textureSet);
+  ComputeTextureSize();
+
+  mLoadState = TextureManager::LoadState::NOT_STARTED;
+}
+
+void ImageVisual::ShowBrokenImage()
+{
+  if(mEnableBrokenImage)
+  {
+    Actor actor = mPlacementActor.GetHandle();
+
+    Vector2 imageSize = Vector2::ZERO;
+    if(actor)
+    {
+      imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+      mPlacementActorSize = imageSize;
+    }
+
+    mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+    if(actor)
+    {
+      actor.AddRenderer(mImpl->mRenderer);
+      mPlacementActor.Reset();
+    }
+  }
+  else
+  {
+    ResetRenderer();
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index f5bf6fe..1bd414b 100644 (file)
@@ -322,6 +322,17 @@ private:
    */
   void CheckMaskTexture();
 
+  /**
+   * @brief Reset Renderer using empty texture
+   * For drawing empty visual, reset the renderer.
+   */
+  void ResetRenderer();
+
+  /**
+   * @brief Show broken image when image loading is failed.
+   */
+  void ShowBrokenImage();
+
 private:
   Vector4                            mPixelArea;
   WeakHandle<Actor>                  mPlacementActor;
@@ -348,6 +359,7 @@ private:
   bool                                            mAttemptAtlasing;       ///< If true will attempt atlasing, otherwise create unique texture
   bool                                            mOrientationCorrection; ///< true if the image will have it's orientation corrected.
   bool                                            mNeedYuvToRgb{false};   ///< true if we need to convert yuv to rgb.
+  bool                                            mEnableBrokenImage;
 };
 
 } // namespace Internal
index ac898d7..ec888ce 100644 (file)
@@ -123,6 +123,7 @@ const char* const ALPHA_MASK_URL("alphaMaskUrl");
 const char* const REDRAW_IN_SCALING_DOWN_NAME("redrawInScalingDown");
 const char* const MASKING_TYPE_NAME("maskingType");
 const char* const MASK_TEXTURE_RATIO_NAME("maskTextureRatio");
+const char* const ENABLE_BROKEN_IMAGE("enableBrokenImage");
 
 // Text visual
 const char* const TEXT_PROPERTY("text");
index 0bb5840..29d75a9 100644 (file)
@@ -107,6 +107,7 @@ extern const char* const ALPHA_MASK_URL;
 extern const char* const REDRAW_IN_SCALING_DOWN_NAME;
 extern const char* const MASKING_TYPE_NAME;
 extern const char* const MASK_TEXTURE_RATIO_NAME;
+extern const char* const ENABLE_BROKEN_IMAGE;
 
 // Text visual
 extern const char* const TEXT_PROPERTY;