Merge "Fix text written below cursor bug" into devel/master
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 7 Jan 2022 02:44:34 +0000 (02:44 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 7 Jan 2022 02:44:34 +0000 (02:44 +0000)
21 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/devel-api/controls/control-accessible.cpp
dali-toolkit/devel-api/controls/control-accessible.h
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/utility/npatch-helper.cpp [new file with mode: 0644]
dali-toolkit/devel-api/utility/npatch-helper.h [new file with mode: 0644]
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/text/cursor-helper-functions.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/visual-factory-cache.cpp
dali-toolkit/internal/visuals/visual-factory-cache.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index 6d2e281..643b552 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 
 #include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
@@ -142,3 +143,24 @@ int UtcDaliAccessibilityCheckShowingState(void)
 
   END_TEST;
 }
+
+int utcDaliAccessibilityHidden(void)
+{
+  ToolkitTestApplication application;
+
+  auto  control    = Toolkit::Control::New();
+  auto* accessible = Dali::Accessibility::Accessible::Get(control);
+
+  // Check not hidden
+  DALI_TEST_CHECK(accessible);
+  DALI_TEST_CHECK(!accessible->IsHidden());
+  DALI_TEST_CHECK(!control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
+
+  control.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, true);
+
+  // Check hidden
+  DALI_TEST_CHECK(accessible->IsHidden());
+  DALI_TEST_CHECK(control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
+
+  END_TEST;
+}
index 9e352e5..1ed53dc 100644 (file)
@@ -613,7 +613,7 @@ int UtcDaliAccessibilityParentChildren(void)
     child_1_accessible -> GetIndexInParent();
     DALI_ABORT("Object has parent, test abort");
   }
-  catch (Dali::DaliException &){}
+  catch (const std::domain_error&){}
 
   parent.Add(child_1);
   parent.Add(child_2);
@@ -1160,7 +1160,7 @@ int UtcDaliAccessibilityScrollToChildNonScrollable(void)
 
   DALI_TEST_EQUALS(accessible->IsScrollable(), false, TEST_LOCATION);
   DALI_TEST_EQUALS(accessible->ScrollToChild({}), false, TEST_LOCATION);
-  DALI_TEST_EQUALS(accessible->GetInternalActor(), Dali::Actor{}, TEST_LOCATION);
+  DALI_TEST_EQUALS(accessible->GetInternalActor(), label, TEST_LOCATION);
 
   Dali::Accessibility::TestEnableSC( false );
   END_TEST;
index 8184dd7..2887613 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -257,6 +257,57 @@ int UtcDaliDebugRenderingGetVisual2(void)
   END_TEST;
 }
 
+
+int UtcDaliDebugRenderingGetVisual3(void)
+{
+  EnvironmentVariable::SetTestingEnvironmentVariable( true );
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliDebugRenderingGetVisual3: Request visual with various parameters" );
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK( factory );
+
+  // Test that image visual is replaced with debug visual
+  Dali::Property::Map map;
+  map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
+  map[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
+  Visual::Base imageVisual = factory.CreateVisual( map );
+  DALI_TEST_CHECK( imageVisual );
+  TestDebugVisual( application.GetScene(),  imageVisual, Visual::IMAGE, Vector2(64.0f, 64.0f /* Broken Image Size */ ));
+
+  // Test that image visual with null string don't make visual
+  map.Clear();
+  map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
+  map[ ImageVisual::Property::URL ] = "";
+  Visual::Base emptyVisual = factory.CreateVisual( map );
+  DALI_TEST_CHECK( emptyVisual );
+  TestDebugVisual( application.GetScene(), emptyVisual, Visual::WIREFRAME, Vector2::ZERO);
+
+  tet_infoline( "Check that GetVisualObject returns the actual WireframeVisual" );
+  Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( emptyVisual ).GetVisualObject();
+  DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::WireframeVisual* >( &visualImpl ) );
+
+  tet_infoline( "Compare the returned emptyVisual with the visual implementation, should be the same" );
+  DALI_TEST_CHECK( emptyVisual.GetObjectPtr() == &visualImpl );
+
+  // Test that image view with empty property map don't make visual even DebugRendering is enabled.
+  map.Clear();
+  ImageView imageView = ImageView::New();
+  imageView.SetProperty(Control::Property::BACKGROUND, map);
+  imageView.SetProperty(ImageView::Property::IMAGE, map);
+
+  application.GetScene().Add(imageView);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
+
+  EnvironmentVariable::SetTestingEnvironmentVariable(false);
+  END_TEST;
+}
+
+
 int UtcDaliDebugRenderingGetVisualObject01(void)
 {
   EnvironmentVariable::SetTestingEnvironmentVariable( true );
@@ -281,6 +332,7 @@ int UtcDaliDebugRenderingGetVisualObject01(void)
   tet_infoline( "Compare the returned TextVisual with the visual implementation, should differ" );
   DALI_TEST_CHECK( textVisual.GetObjectPtr() != &visualImpl );
 
+  EnvironmentVariable::SetTestingEnvironmentVariable( false );
   END_TEST;
 }
 
@@ -352,4 +404,4 @@ int UtcDaliDebugRenderingRenderText(void)
   }
 
   END_TEST;
-}
+}
\ No newline at end of file
index 96f4536..e81bb5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1170,6 +1170,35 @@ int UtcDaliImageViewSetImageTypeChangesP(void)
   DALI_TEST_CHECK( value.Get( map ) );   // Value should NOT be empty
   DALI_TEST_CHECK( ! visual );           // Visual should be invalid
 
+  // Set a URL in property map again
+  propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
+  imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+  application.SendNotification();
+  application.Render( 16 );
+
+  value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+  visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+  DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+  DALI_TEST_CHECK( value.Get( map ) );   // Value should NOT be empty
+  DALI_TEST_CHECK( visual );             // Visual should be valid
+
+  // Set an empty property map
+  propertyMap.Clear();
+  imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+  application.SendNotification();
+  application.Render( 16 );
+
+  value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+  visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+  DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+  DALI_TEST_CHECK( value.Get( map ) );   // Value should NOT be empty
+  DALI_TEST_CHECK( map.Empty() );        // But PropertyMap should be empty
+  DALI_TEST_CHECK( ! visual );           // Visual should be invalid
+
   END_TEST;
 }
 
@@ -3001,6 +3030,59 @@ int UtcDaliImageViewImageLoadFailure03(void)
   END_TEST;
 }
 
+int UtcDaliImageViewImageLoadFailure04(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New("invalidUrl.png");
+  imageView.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+  application.GetScene().Add( imageView );
+  application.SendNotification();
+  application.Render(16);
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+
+  Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+  DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
+  DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
+  DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
+
+  ImageView imageView2 = ImageView::New("invalidUrl.png");
+  imageView2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+  application.GetScene().Add( imageView2 );
+
+  std::string brokenUrl;
+  brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
+  DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
+
+  brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
+  DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render(16);
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+
+  DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
+
+  ImageView imageView3 = ImageView::New("invalidUrl.png");
+  imageView3.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+  application.GetScene().Add( imageView3 );
+
+  application.SendNotification();
+  application.Render(16);
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
 namespace
 {
 
index 387275d..d54a00b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -890,7 +890,7 @@ int UtcDaliVisualGetPropertyMap5(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK(  value->Get<int>() == WrapMode::MIRRORED_REPEAT);
 
-  value = resultMap.Find( "synchronousLoading",   Property::BOOLEAN );
+  value = resultMap.Find( ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN );
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( value->Get<bool>() == true );
 
index 7010a6c..21fc8e2 100644 (file)
@@ -67,7 +67,7 @@ static Dali::Actor CreateHighlightIndicatorActor()
 } // unnamed namespace
 
 ControlAccessible::ControlAccessible(Dali::Actor self, Dali::Accessibility::Role role, bool modal)
-: mSelf(self),
+: ActorAccessible(self),
   mIsModal(modal)
 {
   auto control = Dali::Toolkit::Control::DownCast(Self());
@@ -174,40 +174,6 @@ std::string ControlAccessible::GetDescriptionRaw() const
   return {};
 }
 
-Dali::Accessibility::Accessible* ControlAccessible::GetParent()
-{
-  return Dali::Accessibility::Accessible::Get(Self().GetParent());
-}
-
-size_t ControlAccessible::GetChildCount() const
-{
-  return Self().GetChildCount();
-}
-
-Dali::Accessibility::Accessible* ControlAccessible::GetChildAtIndex(size_t index)
-{
-  return Dali::Accessibility::Accessible::Get(Self().GetChildAt(static_cast<unsigned int>(index)));
-}
-
-size_t ControlAccessible::GetIndexInParent()
-{
-  auto self = Self();
-  auto parent = self.GetParent();
-  DALI_ASSERT_ALWAYS(parent && "can't call GetIndexInParent on object without parent");
-
-  auto count = parent.GetChildCount();
-  for(auto i = 0u; i < count; ++i)
-  {
-    auto child = parent.GetChildAt(i);
-    if(child == self)
-    {
-      return i;
-    }
-  }
-  DALI_ASSERT_ALWAYS(false && "object isn't child of it's parent");
-  return static_cast<size_t>(-1);
-}
-
 Dali::Accessibility::Role ControlAccessible::GetRole() const
 {
   return Self().GetProperty<Dali::Accessibility::Role>(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE);
@@ -316,41 +282,14 @@ Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const
   return attributeMap;
 }
 
-Dali::Accessibility::ComponentLayer ControlAccessible::GetLayer() const
+bool ControlAccessible::IsHidden() const
 {
-  return Dali::Accessibility::ComponentLayer::WINDOW;
-}
-
-Dali::Rect<> ControlAccessible::GetExtents(Dali::Accessibility::CoordinateType type) const
-{
-  Dali::Actor self = Self();
-
-  Vector2 screenPosition = self.GetProperty(Dali::DevelActor::Property::SCREEN_POSITION).Get<Vector2>();
-  auto size = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
-  bool positionUsesAnchorPoint = self.GetProperty(Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
-  Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
-  Vector2 position = Vector2((screenPosition.x - anchorPointOffSet.x), (screenPosition.y - anchorPointOffSet.y));
-
-  if(type == Dali::Accessibility::CoordinateType::WINDOW)
-  {
-    return {position.x, position.y, size.x, size.y};
-  }
-  else // Dali::Accessibility::CoordinateType::SCREEN
-  {
-    auto window = Dali::DevelWindow::Get(self);
-    auto windowPosition = window.GetPosition();
-    return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y};
-  }
-}
+  auto control = Dali::Toolkit::Control::DownCast(Self());
 
-int16_t ControlAccessible::GetMdiZOrder() const
-{
-  return 0;
-}
+  Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(control);
+  Internal::Control::Impl& controlImpl     = Internal::Control::Impl::Get(internalControl);
 
-double ControlAccessible::GetAlpha() const
-{
-  return 0;
+  return controlImpl.mAccessibilityHidden;
 }
 
 bool ControlAccessible::GrabFocus()
@@ -552,11 +491,6 @@ std::vector<Dali::Accessibility::Relation> ControlAccessible::GetRelationSet()
   return ret;
 }
 
-Dali::Actor ControlAccessible::GetInternalActor()
-{
-  return Dali::Actor{};
-}
-
 bool ControlAccessible::ScrollToChild(Actor child)
 {
   return false;
index 5e576fd..7b0ae78 100644 (file)
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
-#include <dali/devel-api/atspi-interfaces/accessible.h>
+#include <dali/devel-api/adaptor-framework/actor-accessible.h>
 #include <dali/devel-api/atspi-interfaces/action.h>
-#include <dali/devel-api/atspi-interfaces/collection.h>
-#include <dali/devel-api/atspi-interfaces/component.h>
 #include <dali/public-api/object/weak-handle.h>
 
 // INTERNAL INCLUDES
@@ -47,29 +45,15 @@ namespace Dali::Toolkit::DevelControl {
  * @see Dali::Accessibility::Text
  * @see Dali::Accessibility::EditableText
  */
-struct DALI_TOOLKIT_API ControlAccessible : public virtual Dali::Accessibility::Accessible,
-                                            public virtual Dali::Accessibility::Component,
-                                            public virtual Dali::Accessibility::Collection,
+struct DALI_TOOLKIT_API ControlAccessible : public Dali::Accessibility::ActorAccessible,
                                             public virtual Dali::Accessibility::Action
 {
 protected:
   Vector2                       mLastPosition{0.0f, 0.0f};
-  Dali::WeakHandle<Dali::Actor> mSelf;
   Dali::WeakHandle<Dali::Actor> mCurrentHighlightActor;
   bool mIsModal = false;
   bool mIsRoot = false;
 
-  Dali::Actor Self() const
-  {
-    auto handle = mSelf.GetHandle();
-
-    // Control::Impl holds a std::unique_ptr to the Accessible object,
-    // so that one does not outlive the other.
-    DALI_ASSERT_ALWAYS(handle);
-
-    return handle;
-  }
-
   void ScrollToSelf();
 
   /**
@@ -112,26 +96,6 @@ public:
   virtual std::string GetDescriptionRaw() const;
 
   /**
-   * @copydoc Dali::Accessibility::Accessible::GetParent()
-   */
-  Dali::Accessibility::Accessible* GetParent() override;
-
-  /**
-   * @copydoc Dali::Accessibility::Accessible::GetChildCount()
-   */
-  size_t GetChildCount() const override;
-
-  /**
-   * @copydoc Dali::Accessibility::Accessible::GetChildAtIndex()
-   */
-  Dali::Accessibility::Accessible* GetChildAtIndex(size_t index) override;
-
-  /**
-   * @copydoc Dali::Accessibility::Accessible::GetIndexInParent()
-   */
-  size_t GetIndexInParent() override;
-
-  /**
    * @copydoc Dali::Accessibility::Accessible::GetRole()
    */
   Dali::Accessibility::Role GetRole() const override;
@@ -152,19 +116,9 @@ public:
   Dali::Accessibility::Attributes GetAttributes() const override;
 
   /**
-   * @copydoc Dali::Accessibility::Component::GetExtents()
-   */
-  Dali::Rect<> GetExtents(Accessibility::CoordinateType type) const override;
-
-  /**
-   * @copydoc Dali::Accessibility::Component::GetLayer()
-   */
-  Dali::Accessibility::ComponentLayer GetLayer() const override;
-
-  /**
-   * @copydoc Dali::Accessibility::Component::GetMdiZOrder()
+   * @copydoc Dali::Accessibility::Accessible::IsHidden()
    */
-  int16_t GetMdiZOrder() const override;
+  bool IsHidden() const override;
 
   /**
    * @copydoc Dali::Accessibility::Component::GrabFocus()
@@ -172,11 +126,6 @@ public:
   bool GrabFocus() override;
 
   /**
-   * @copydoc Dali::Accessibility::Component::GetAlpha()
-   */
-  double GetAlpha() const override;
-
-  /**
    * @copydoc Dali::Accessibility::Component::GrabHighlight()
    */
   bool GrabHighlight() override;
@@ -232,11 +181,6 @@ public:
   std::vector<Dali::Accessibility::Relation> GetRelationSet() override;
 
   /**
-   * @copydoc Dali::Accessibility::Accessible::GetInternalActor()
-   */
-  Dali::Actor GetInternalActor() override;
-
-  /**
    * @copydoc Dali::Accessibility::Accessible::GetStates()
    */
   virtual Dali::Accessibility::States CalculateStates();
index 5d276cb..33e02f5 100644 (file)
@@ -175,11 +175,13 @@ enum
    * @see Dali::Accessibility::Role
    */
   ACCESSIBILITY_ROLE,
+
   /**
    * @brief Mark of able to highlight object.
    * @details Name "accessibilityHighlightable", type Property::BOOLEAN.
    */
   ACCESSIBILITY_HIGHLIGHTABLE,
+
   /**
    * @brief Set of accessibility attributes describing object in accessibility hierarchy
    * @details Name "accessibilityAttributes", type Property::MAP
@@ -192,6 +194,13 @@ enum
    * @note If a control's dispatchKeyEvents is set to false, then it's children will not emit a key event signal either.
    */
   DISPATCH_KEY_EVENTS,
+
+  /**
+   * @brief Marks the object as invisible to AT-SPI clients.
+   * @details Name "accessibilityHidden", type Property::BOOLEAN.
+   * @note The representative Accessible object will not appear in the AT-SPI tree.
+   */
+  ACCESSIBILITY_HIDDEN,
 };
 
 } // namespace Property
index cc5abef..0a000bc 100755 (executable)
@@ -67,6 +67,7 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/transition-effects/cube-transition-fold-effect.cpp
   ${devel_api_src_dir}/transition-effects/cube-transition-wave-effect.cpp
   ${devel_api_src_dir}/utility/npatch-utilities.cpp
+  ${devel_api_src_dir}/utility/npatch-helper.cpp
   ${devel_api_src_dir}/visual-factory/transition-data.cpp
   ${devel_api_src_dir}/visual-factory/visual-factory.cpp
   ${devel_api_src_dir}/visual-factory/visual-base.cpp
@@ -271,6 +272,7 @@ SET( devel_api_drag_and_drop_detector_header_files
 
 SET( devel_api_utility_header_files
   ${devel_api_src_dir}/utility/npatch-utilities.h
+  ${devel_api_src_dir}/utility/npatch-helper.h
 )
 
 SET( SOURCES ${SOURCES}
diff --git a/dali-toolkit/devel-api/utility/npatch-helper.cpp b/dali-toolkit/devel-api/utility/npatch-helper.cpp
new file mode 100644 (file)
index 0000000..53c6d4d
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace NPatchHelper
+{
+namespace
+{
+/**
+ * @brief Creates the geometry formed from the vertices and indices
+ *
+ * @param[in]  vertices             The vertices to generate the geometry from
+ * @param[in]  indices              The indices to generate the geometry from
+ * @return The geometry formed from the vertices and indices
+ */
+Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
+{
+  Property::Map vertexFormat;
+  vertexFormat["aPosition"] = Property::VECTOR2;
+  VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
+  if(vertices.Size() > 0)
+  {
+    vertexBuffer.SetData(&vertices[0], vertices.Size());
+  }
+
+  // Create the geometry object
+  Geometry geometry = Geometry::New();
+  geometry.AddVertexBuffer(vertexBuffer);
+  if(indices.Size() > 0)
+  {
+    geometry.SetIndexBuffer(&indices[0], indices.Size());
+  }
+
+  return geometry;
+}
+
+/**
+ * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
+ *
+ * @param[out] indices     The indices to add to
+ * @param[in]  rowIdx      The row index to start the quad
+ * @param[in]  nextRowIdx  The index to the next row
+ */
+void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
+{
+  indices.PushBack(rowIdx);
+  indices.PushBack(nextRowIdx + 1);
+  indices.PushBack(rowIdx + 1);
+
+  indices.PushBack(rowIdx);
+  indices.PushBack(nextRowIdx);
+  indices.PushBack(nextRowIdx + 1);
+}
+
+/**
+ * @brief Adds the vertices to create for npatch
+ * @param[out] vertices The vertices to add to
+ * @param[in]  x        The x value of vector
+ * @param[in]  y        The y value of vector
+ */
+void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
+{
+  vertices.PushBack(Vector2(x, y));
+}
+
+} // unnamed namespace
+
+Geometry CreateGridGeometry(Uint16Pair gridSize)
+{
+  uint16_t gridWidth  = gridSize.GetWidth();
+  uint16_t gridHeight = gridSize.GetHeight();
+
+  // Create vertices
+  Vector<Vector2> vertices;
+  vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
+
+  for(int y = 0; y < gridHeight + 1; ++y)
+  {
+    for(int x = 0; x < gridWidth + 1; ++x)
+    {
+      AddVertex(vertices, x, y);
+    }
+  }
+
+  // Create indices
+  Vector<unsigned short> indices;
+  indices.Reserve(gridWidth * gridHeight * 6);
+
+  unsigned int rowIdx     = 0;
+  unsigned int nextRowIdx = gridWidth + 1;
+  for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
+  {
+    for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+    {
+      AddQuadIndices(indices, rowIdx, nextRowIdx);
+    }
+  }
+
+  return GenerateGeometry(vertices, indices);
+}
+
+Geometry CreateBorderGeometry(Uint16Pair gridSize)
+{
+  uint16_t gridWidth  = gridSize.GetWidth();
+  uint16_t gridHeight = gridSize.GetHeight();
+
+  // Create vertices
+  Vector<Vector2> vertices;
+  vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
+
+  //top
+  int y = 0;
+  for(; y < 2; ++y)
+  {
+    for(int x = 0; x < gridWidth + 1; ++x)
+    {
+      AddVertex(vertices, x, y);
+    }
+  }
+
+  for(; y < gridHeight - 1; ++y)
+  {
+    //left
+    AddVertex(vertices, 0, y);
+    AddVertex(vertices, 1, y);
+
+    //right
+    AddVertex(vertices, gridWidth - 1, y);
+    AddVertex(vertices, gridWidth, y);
+  }
+
+  //bottom
+  for(; y < gridHeight + 1; ++y)
+  {
+    for(int x = 0; x < gridWidth + 1; ++x)
+    {
+      AddVertex(vertices, x, y);
+    }
+  }
+
+  // Create indices
+  Vector<unsigned short> indices;
+  indices.Reserve(gridWidth * gridHeight * 6);
+
+  //top
+  unsigned int rowIdx     = 0;
+  unsigned int nextRowIdx = gridWidth + 1;
+  for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+  {
+    AddQuadIndices(indices, rowIdx, nextRowIdx);
+  }
+
+  if(gridHeight > 2)
+  {
+    rowIdx     = gridWidth + 1;
+    nextRowIdx = (gridWidth + 1) * 2;
+
+    unsigned increment = gridWidth - 1;
+    if(gridHeight > 3)
+    {
+      increment = 2;
+      //second row left
+      AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+      rowIdx     = gridWidth * 2;
+      nextRowIdx = (gridWidth + 1) * 2 + 2;
+      //second row right
+      AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+      //left and right
+      rowIdx     = nextRowIdx - 2;
+      nextRowIdx = rowIdx + 4;
+      for(int y = 2; y < 2 * (gridHeight - 3); ++y, rowIdx += 2, nextRowIdx += 2)
+      {
+        AddQuadIndices(indices, rowIdx, nextRowIdx);
+      }
+    }
+
+    //second row left
+    AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+    rowIdx += increment;
+    nextRowIdx += gridWidth - 1;
+    //second row right
+    AddQuadIndices(indices, rowIdx, nextRowIdx);
+  }
+
+  //bottom
+  rowIdx     = nextRowIdx - gridWidth + 1;
+  nextRowIdx = rowIdx + gridWidth + 1;
+  for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+  {
+    AddQuadIndices(indices, rowIdx, nextRowIdx);
+  }
+
+  return GenerateGeometry(vertices, indices);
+}
+
+void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
+{
+  uint16_t     prevEnd     = 0;
+  uint16_t     prevFix     = 0;
+  uint16_t     prevStretch = 0;
+  unsigned int i           = 1;
+  for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
+  {
+    uint16_t start = it->GetX();
+    uint16_t end   = it->GetY();
+
+    uint16_t fix     = prevFix + start - prevEnd;
+    uint16_t stretch = prevStretch + end - start;
+
+    std::stringstream uniform;
+    uniform << uniformName << "[" << i << "]";
+    renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
+
+    prevEnd     = end;
+    prevFix     = fix;
+    prevStretch = stretch;
+  }
+
+  {
+    prevFix += imageExtent - prevEnd;
+    std::stringstream uniform;
+    uniform << uniformName << "[" << i << "]";
+    renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
+  }
+}
+
+void ApplyTextureAndUniforms(Renderer& renderer, const Internal::NPatchData* data)
+{
+  TextureSet        textureSet;
+  textureSet = data->GetTextures();
+
+  if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
+  {
+    //special case for 9 patch
+    Uint16Pair stretchX = data->GetStretchPixelsX()[0];
+    Uint16Pair stretchY = data->GetStretchPixelsY()[0];
+
+    uint16_t stretchWidth  = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
+    uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
+
+    renderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
+    renderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
+    renderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
+    renderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
+  }
+  else
+  {
+    renderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
+    renderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
+
+    RegisterStretchProperties(renderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
+    RegisterStretchProperties(renderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
+  }
+}
+
+} // namespace NPatchHelper
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/utility/npatch-helper.h b/dali-toolkit/devel-api/utility/npatch-helper.h
new file mode 100644 (file)
index 0000000..7a198fe
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef DALI_TOOLKIT_NPATCH_HELPER_H
+#define DALI_TOOLKIT_NPATCH_HELPER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/uint-16-pair.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+#include <dali-toolkit/internal/visuals/npatch-data.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace NPatchHelper
+{
+/**
+ * The list that includes stretch pixel ranges
+ */
+using StretchRanges = Dali::Vector<Uint16Pair>;
+
+/**
+ * @brief Creates a Npatch Geometry object
+ *
+ * @param[in] gridSize The gridSize for creating a geometry
+ * @return The Geometry for NPatch
+ */
+DALI_TOOLKIT_API Geometry CreateGridGeometry(Uint16Pair gridSize);
+
+/**
+ * @brief Creates a geometry with the border only for the grid size to be used by this visuals' shaders
+ * e.g. a 5x4 grid would create a geometry that would look like:
+ *
+ *   ---------------------
+ *   |  /|  /|  /|  /|  /|
+ *   |/  |/  |/  |/  |/  |
+ *   ---------------------
+ *   |  /|           |  /|
+ *   |/  |           |/  |
+ *   -----           -----
+ *   |  /|           |  /|
+ *   |/  |           |/  |
+ *   ---------------------
+ *   |  /|  /|  /|  /|  /|
+ *   |/  |/  |/  |/  |/  |
+ *   ---------------------
+ *
+ * @param[in] gridSize The grid size of the solid geometry to create
+ * @return Returns the created geometry for the grid size
+ */
+DALI_TOOLKIT_API Geometry CreateBorderGeometry(Uint16Pair gridSize);
+
+
+/**
+ * @brief Registers a properties for Stretch Ranges
+ *
+ * @param[in,out] renderer The renderer for broken image
+ * @param[in] uniformName The name of the uniform
+ * @param[in] stretchPixels The stretchable pixels in the cropped image space
+ * @param[in] imageExtent The imageExtent
+ */
+void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
+
+/**
+ * @brief Apply a texture and uniforms
+ *
+ * @param[in,out] renderer The renderer for broken image
+ * @param[in] data The pointer of npatch-data
+ */
+void ApplyTextureAndUniforms(Renderer& renderer, const Internal::NPatchData* data);
+
+} // namespace NPatchUtility
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_NPATCH_HELPER_H
index a476eca..e3cea92 100644 (file)
@@ -468,7 +468,8 @@ const PropertyRegistration Control::Impl::PROPERTY_18(typeRegistration, "accessi
 const PropertyRegistration Control::Impl::PROPERTY_19(typeRegistration, "accessibilityRole",              Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE,               Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_20(typeRegistration, "accessibilityHighlightable",     Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE,      Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_21(typeRegistration, "accessibilityAttributes",        Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES,         Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty);
-const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents",              Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS,               Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents",              Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS,              Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden",            Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN,             Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 
 // clang-format on
 
@@ -1369,6 +1370,16 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const
         }
         break;
       }
+
+      case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+      {
+        bool hidden;
+        if(value.Get(hidden))
+        {
+          controlImpl.mImpl->mAccessibilityHidden = hidden;
+        }
+        break;
+      }
     }
   }
 }
@@ -1529,11 +1540,18 @@ Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index i
         value = controlImpl.mImpl->mAccessibilityAttributes;
         break;
       }
+
       case Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS:
       {
         value = controlImpl.mImpl->mDispatchKeyEvents;
         break;
       }
+
+      case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+      {
+        value = controlImpl.mImpl->mAccessibilityHidden;
+        break;
+      }
     }
   }
 
index e616e52..a227648 100644 (file)
@@ -546,6 +546,8 @@ public:
   bool mAccessibilityHighlightable    = false;
   bool mAccessibilityHighlightableSet = false;
 
+  bool mAccessibilityHidden = false;
+
   Dali::Accessibility::Role mAccessibilityRole = Dali::Accessibility::Role::UNKNOWN;
 
   std::map<Dali::Accessibility::RelationType, std::set<Accessibility::Accessible*>> mAccessibilityRelations;
@@ -596,6 +598,7 @@ public:
   static const PropertyRegistration PROPERTY_20;
   static const PropertyRegistration PROPERTY_21;
   static const PropertyRegistration PROPERTY_22;
+  static const PropertyRegistration PROPERTY_23;
 
 private:
   // Accessibility - notification for highlighted object to check if it is showing.
index c299886..1d9deec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -479,27 +479,43 @@ void ImageView::SetProperty(BaseObject* object, Property::Index index, const Pro
           map = value.GetMap();
           if(map)
           {
-            Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
-            // set image only if property map contains image information other than custom shader
-            if(map->Count() > 1u || !shaderValue)
+            // the property map is emtpy map. Unregister visual.
+            if(DALI_UNLIKELY(map->Count() == 0u))
             {
-              impl.SetImage(*map);
+              // Clear cached properties
+              impl.mPropertyMap.Clear();
+              impl.mUrl.clear();
+
+              // Unregister the exsiting visual
+              DevelControl::UnregisterVisual(impl, Toolkit::ImageView::Property::IMAGE);
+
+              // Trigger a size negotiation request that may be needed when unregistering a visual.
+              impl.RelayoutRequest();
             }
-            // the property map contains only the custom shader
-            else if((map->Count() == 1u) && (shaderValue))
+            else
             {
-              Property::Map* shaderMap = shaderValue->GetMap();
-              if(shaderMap)
+              Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
+              // set image only if property map contains image information other than custom shader
+              if(map->Count() > 1u || !shaderValue)
               {
-                impl.mShaderMap = *shaderMap;
-
-                if(!impl.mUrl.empty())
-                {
-                  impl.SetImage(impl.mUrl, impl.mImageSize);
-                }
-                else if(!impl.mPropertyMap.Empty())
+                impl.SetImage(*map);
+              }
+              // the property map contains only the custom shader
+              else if((map->Count() == 1u) && (shaderValue))
+              {
+                Property::Map* shaderMap = shaderValue->GetMap();
+                if(shaderMap)
                 {
-                  impl.SetImage(impl.mPropertyMap);
+                  impl.mShaderMap = *shaderMap;
+
+                  if(!impl.mUrl.empty())
+                  {
+                    impl.SetImage(impl.mUrl, impl.mImageSize);
+                  }
+                  else if(!impl.mPropertyMap.Empty())
+                  {
+                    impl.SetImage(impl.mPropertyMap);
+                  }
                 }
               }
             }
index 7b08c47..2379bcc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -485,9 +485,9 @@ void GetCursorPosition(GetCursorPositionParameters& parameters,
   const GlyphInfo* const  glyphInfoBuffer          = parameters.visualModel->mGlyphs.Begin();
   CharacterIndex          index;
   GlyphMetrics            glyphMetrics;
-  MetricsPtr&             metrics = parameters.metrics;
-  GlyphIndex glyphIndex = 0u;
-  Length numberOfGlyphs = 0u;
+  MetricsPtr&             metrics        = parameters.metrics;
+  GlyphIndex              glyphIndex     = 0u;
+  Length                  numberOfGlyphs = 0u;
 
   if(isLastNewParagraph)
   {
@@ -503,8 +503,12 @@ void GetCursorPosition(GetCursorPositionParameters& parameters,
 
     cursorInfo.lineHeight = GetLineHeight(newLine);
 
+    index                                = 0u;
     const Length totalNumberOfCharacters = parameters.logicalModel->mText.Count();
-    index                                = totalNumberOfCharacters - 1;
+    if(totalNumberOfCharacters > 0u)
+    {
+      index = totalNumberOfCharacters - 1u;
+    }
 
     GetGlyphMetricsFromCharacterIndex(index, glyphInfoBuffer, charactersToGlyphBuffer, glyphsPerCharacterBuffer, metrics, glyphMetrics, glyphIndex, numberOfGlyphs);
 
index 39b18ee..970e309 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -755,7 +755,7 @@ void ImageVisual::DoCreatePropertyMap(Property::Map& map) const
   map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
 
   bool sync = IsSynchronousLoadingRequired();
-  map.Insert(SYNCHRONOUS_LOADING, sync);
+  map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync);
   if(mImageUrl.IsValid())
   {
     map.Insert(Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl());
index b9e046a..4325dea 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
 #include <dali-toolkit/internal/visuals/npatch-loader.h>
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
 #include <dali-toolkit/internal/visuals/rendering-addon.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
@@ -43,91 +44,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-namespace
-{
-/**
- * @brief Creates the geometry formed from the vertices and indices
- *
- * @param[in]  vertices             The vertices to generate the geometry from
- * @param[in]  indices              The indices to generate the geometry from
- * @return The geometry formed from the vertices and indices
- */
-Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
-{
-  Property::Map vertexFormat;
-  vertexFormat["aPosition"] = Property::VECTOR2;
-  VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
-  if(vertices.Size() > 0)
-  {
-    vertexBuffer.SetData(&vertices[0], vertices.Size());
-  }
-
-  // Create the geometry object
-  Geometry geometry = Geometry::New();
-  geometry.AddVertexBuffer(vertexBuffer);
-  if(indices.Size() > 0)
-  {
-    geometry.SetIndexBuffer(&indices[0], indices.Size());
-  }
-
-  return geometry;
-}
-
-/**
- * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
- *
- * @param[out] indices     The indices to add to
- * @param[in]  rowIdx      The row index to start the quad
- * @param[in]  nextRowIdx  The index to the next row
- */
-void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
-{
-  indices.PushBack(rowIdx);
-  indices.PushBack(nextRowIdx + 1);
-  indices.PushBack(rowIdx + 1);
-
-  indices.PushBack(rowIdx);
-  indices.PushBack(nextRowIdx);
-  indices.PushBack(nextRowIdx + 1);
-}
-
-void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
-{
-  vertices.PushBack(Vector2(x, y));
-}
-
-void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
-{
-  uint16_t     prevEnd     = 0;
-  uint16_t     prevFix     = 0;
-  uint16_t     prevStretch = 0;
-  unsigned int i           = 1;
-  for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
-  {
-    uint16_t start = it->GetX();
-    uint16_t end   = it->GetY();
-
-    uint16_t fix     = prevFix + start - prevEnd;
-    uint16_t stretch = prevStretch + end - start;
-
-    std::stringstream uniform;
-    uniform << uniformName << "[" << i << "]";
-    renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
-
-    prevEnd     = end;
-    prevFix     = fix;
-    prevStretch = stretch;
-  }
-
-  {
-    prevFix += imageExtent - prevEnd;
-    std::stringstream uniform;
-    uniform << uniformName << "[" << i << "]";
-    renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
-  }
-}
-
-} //unnamed namespace
 
 /////////////////NPatchVisual////////////////
 
@@ -421,12 +337,12 @@ Geometry NPatchVisual::CreateGeometry()
       Uint16Pair gridSize(2 * data->GetStretchPixelsX().Size() + 1, 2 * data->GetStretchPixelsY().Size() + 1);
       if(!data->GetRenderingMap())
       {
-        geometry = !mBorderOnly ? CreateGridGeometry(gridSize) : CreateBorderGeometry(gridSize);
+        geometry = !mBorderOnly ?  NPatchHelper::CreateGridGeometry(gridSize) :  NPatchHelper::CreateBorderGeometry(gridSize);
       }
       else
       {
         uint32_t elementCount[2];
-        geometry = !mBorderOnly ? RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), gridSize, elementCount) : CreateBorderGeometry(gridSize);
+        geometry = !mBorderOnly ? RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), gridSize, elementCount) :  NPatchHelper::CreateBorderGeometry(gridSize);
         if(mImpl->mRenderer)
         {
           RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->GetRenderingMap());
@@ -530,29 +446,7 @@ void NPatchVisual::ApplyTextureAndUniforms()
   if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
   {
     textureSet = data->GetTextures();
-
-    if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
-    {
-      //special case for 9 patch
-      Uint16Pair stretchX = data->GetStretchPixelsX()[0];
-      Uint16Pair stretchY = data->GetStretchPixelsY()[0];
-
-      uint16_t stretchWidth  = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
-      uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
-
-      mImpl->mRenderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
-      mImpl->mRenderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
-      mImpl->mRenderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
-      mImpl->mRenderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
-    }
-    else
-    {
-      mImpl->mRenderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
-      mImpl->mRenderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
-
-      RegisterStretchProperties(mImpl->mRenderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
-      RegisterStretchProperties(mImpl->mRenderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
-    }
+    NPatchHelper::ApplyTextureAndUniforms(mImpl->mRenderer, data);
   }
   else
   {
@@ -611,148 +505,17 @@ Geometry NPatchVisual::GetNinePatchGeometry(VisualFactoryCache::GeometryType sub
   {
     if(DALI_LIKELY(VisualFactoryCache::NINE_PATCH_GEOMETRY == subType))
     {
-      geometry = CreateGridGeometry(Uint16Pair(3, 3));
+      geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3, 3));
     }
     else if(VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY == subType)
     {
-      geometry = CreateBorderGeometry(Uint16Pair(3, 3));
+      geometry = NPatchHelper::CreateBorderGeometry(Uint16Pair(3, 3));
     }
     mFactoryCache.SaveGeometry(subType, geometry);
   }
   return geometry;
 }
 
-Geometry NPatchVisual::CreateGridGeometry(Uint16Pair gridSize)
-{
-  uint16_t gridWidth  = gridSize.GetWidth();
-  uint16_t gridHeight = gridSize.GetHeight();
-
-  // Create vertices
-  Vector<Vector2> vertices;
-  vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
-  for(int y = 0; y < gridHeight + 1; ++y)
-  {
-    for(int x = 0; x < gridWidth + 1; ++x)
-    {
-      AddVertex(vertices, x, y);
-    }
-  }
-
-  // Create indices
-  Vector<unsigned short> indices;
-  indices.Reserve(gridWidth * gridHeight * 6);
-
-  unsigned int rowIdx     = 0;
-  unsigned int nextRowIdx = gridWidth + 1;
-  for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
-  {
-    for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
-    {
-      AddQuadIndices(indices, rowIdx, nextRowIdx);
-    }
-  }
-
-  return GenerateGeometry(vertices, indices);
-}
-
-Geometry NPatchVisual::CreateBorderGeometry(Uint16Pair gridSize)
-{
-  uint16_t gridWidth  = gridSize.GetWidth();
-  uint16_t gridHeight = gridSize.GetHeight();
-
-  // Create vertices
-  Vector<Vector2> vertices;
-  vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
-  //top
-  int y = 0;
-  for(; y < 2; ++y)
-  {
-    for(int x = 0; x < gridWidth + 1; ++x)
-    {
-      AddVertex(vertices, x, y);
-    }
-  }
-
-  for(; y < gridHeight - 1; ++y)
-  {
-    //left
-    AddVertex(vertices, 0, y);
-    AddVertex(vertices, 1, y);
-
-    //right
-    AddVertex(vertices, gridWidth - 1, y);
-    AddVertex(vertices, gridWidth, y);
-  }
-
-  //bottom
-  for(; y < gridHeight + 1; ++y)
-  {
-    for(int x = 0; x < gridWidth + 1; ++x)
-    {
-      AddVertex(vertices, x, y);
-    }
-  }
-
-  // Create indices
-  Vector<unsigned short> indices;
-  indices.Reserve(gridWidth * gridHeight * 6);
-
-  //top
-  unsigned int rowIdx     = 0;
-  unsigned int nextRowIdx = gridWidth + 1;
-  for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
-  {
-    AddQuadIndices(indices, rowIdx, nextRowIdx);
-  }
-
-  if(gridHeight > 2)
-  {
-    rowIdx     = gridWidth + 1;
-    nextRowIdx = (gridWidth + 1) * 2;
-
-    unsigned increment = gridWidth - 1;
-    if(gridHeight > 3)
-    {
-      increment = 2;
-      //second row left
-      AddQuadIndices(indices, rowIdx, nextRowIdx);
-
-      rowIdx     = gridWidth * 2;
-      nextRowIdx = (gridWidth + 1) * 2 + 2;
-      //second row right
-      AddQuadIndices(indices, rowIdx, nextRowIdx);
-
-      //left and right
-      rowIdx     = nextRowIdx - 2;
-      nextRowIdx = rowIdx + 4;
-      for(int y = 2; y < 2 * (gridHeight - 3); ++y, rowIdx += 2, nextRowIdx += 2)
-      {
-        AddQuadIndices(indices, rowIdx, nextRowIdx);
-      }
-    }
-
-    //second row left
-    AddQuadIndices(indices, rowIdx, nextRowIdx);
-
-    rowIdx += increment;
-    nextRowIdx += gridWidth - 1;
-    //second row right
-    AddQuadIndices(indices, rowIdx, nextRowIdx);
-  }
-
-  //bottom
-  rowIdx     = nextRowIdx - gridWidth + 1;
-  nextRowIdx = rowIdx + gridWidth + 1;
-  for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
-  {
-    AddQuadIndices(indices, rowIdx, nextRowIdx);
-  }
-
-  return GenerateGeometry(vertices, indices);
-}
-
 void NPatchVisual::SetResource()
 {
   const NPatchData* data;
index febd285..a65c779 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
 #include <dali-toolkit/internal/visuals/svg/svg-visual.h>
 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
 #include <dali/integration-api/debug.h>
 
 namespace Dali
@@ -35,73 +36,14 @@ namespace Toolkit
 {
 namespace Internal
 {
-namespace
-{
-
-/**
- * @brief Creates the geometry formed from the vertices and indices
- *
- * @param[in]  vertices             The vertices to generate the geometry from
- * @param[in]  indices              The indices to generate the geometry from
- * @return The geometry formed from the vertices and indices
- */
-Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
-{
-  Property::Map vertexFormat;
-  vertexFormat["aPosition"] = Property::VECTOR2;
-  VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
-  if(vertices.Size() > 0)
-  {
-    vertexBuffer.SetData(&vertices[0], vertices.Size());
-  }
-
-  // Create the geometry object
-  Geometry geometry = Geometry::New();
-  geometry.AddVertexBuffer(vertexBuffer);
-  if(indices.Size() > 0)
-  {
-    geometry.SetIndexBuffer(&indices[0], indices.Size());
-  }
-
-  return geometry;
-}
-
-/**
- * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
- *
- * @param[out] indices     The indices to add to
- * @param[in]  rowIdx      The row index to start the quad
- * @param[in]  nextRowIdx  The index to the next row
- */
-void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
-{
-  indices.PushBack(rowIdx);
-  indices.PushBack(nextRowIdx + 1);
-  indices.PushBack(rowIdx + 1);
-
-  indices.PushBack(rowIdx);
-  indices.PushBack(nextRowIdx);
-  indices.PushBack(nextRowIdx + 1);
-}
-
-/**
- * @brief Adds the vertices to create for npatch
- * @param[out] vertices The vertices to add to
- * @param[in]  x        The x value of vector
- * @param[in]  y        The y value of vector
- */
-void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
-{
-  vertices.PushBack(Vector2(x, y));
-}
-
-} //unnamed namespace
 
 VisualFactoryCache::VisualFactoryCache(bool preMultiplyOnLoad)
 : mSvgRasterizeThread(NULL),
   mVectorAnimationManager(),
   mPreMultiplyOnLoad(preMultiplyOnLoad),
-  mBrokenImageInfoContainer()
+  mBrokenImageInfoContainer(),
+  mDefaultBrokenImageUrl(""),
+  mUseDefaultBrokenImageOnly(true)
 {
 }
 
@@ -168,10 +110,7 @@ ImageAtlasManagerPtr VisualFactoryCache::GetAtlasManager()
   if(!mAtlasManager)
   {
     mAtlasManager = new ImageAtlasManager();
-    if(!mBrokenImageInfoContainer.empty())
-    {
-      mAtlasManager->SetBrokenImage(mBrokenImageInfoContainer[0].url);
-    }
+    mAtlasManager->SetBrokenImage(mDefaultBrokenImageUrl);
   }
 
   return mAtlasManager;
@@ -302,14 +241,17 @@ bool VisualFactoryCache::GetPreMultiplyOnLoad()
   return mPreMultiplyOnLoad;
 }
 
-void VisualFactoryCache::SetBrokenImageUrl(const std::vector<std::string>& brokenImageUrlList)
+void VisualFactoryCache::SetBrokenImageUrl(std::string& defaultBrokenUrl, const std::vector<std::string>& brokenImageUrlList)
 {
+  mUseDefaultBrokenImageOnly = false;
   mBrokenImageInfoContainer.clear();
   mBrokenImageInfoContainer.assign(brokenImageUrlList.size(), BrokenImageInfo());
   for(unsigned int i = 0; i < brokenImageUrlList.size(); i++)
   {
     mBrokenImageInfoContainer[i].url = brokenImageUrlList[i];
   }
+
+  mDefaultBrokenImageUrl = defaultBrokenUrl;
 }
 
 VisualUrl::Type VisualFactoryCache::GetBrokenImageVisualType(int index)
@@ -317,40 +259,6 @@ VisualUrl::Type VisualFactoryCache::GetBrokenImageVisualType(int index)
   return mBrokenImageInfoContainer[index].visualType;
 }
 
-Geometry VisualFactoryCache::CreateNPatchGeometry(Uint16Pair gridSize)
-{
-  uint16_t gridWidth  = gridSize.GetWidth();
-  uint16_t gridHeight = gridSize.GetHeight();
-
-  // Create vertices
-  Vector<Vector2> vertices;
-  vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
-  for(int y = 0; y < gridHeight + 1; ++y)
-  {
-    for(int x = 0; x < gridWidth + 1; ++x)
-    {
-      AddVertex(vertices, x, y);
-    }
-  }
-
-  // Create indices
-  Vector<unsigned short> indices;
-  indices.Reserve(gridWidth * gridHeight * 6);
-
-  unsigned int rowIdx     = 0;
-  unsigned int nextRowIdx = gridWidth + 1;
-  for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
-  {
-    for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
-    {
-      AddQuadIndices(indices, rowIdx, nextRowIdx);
-    }
-  }
-
-  return GenerateGeometry(vertices, indices);
-}
-
 Geometry VisualFactoryCache::GetNPatchGeometry(int index)
 {
   Geometry          geometry;
@@ -362,14 +270,14 @@ Geometry VisualFactoryCache::GetNPatchGeometry(int index)
       geometry = GetGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
       if(!geometry)
       {
-        geometry = CreateNPatchGeometry(Uint16Pair(3,3));
+        geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3,3));
         SaveGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry);
       }
     }
     else if(data->GetStretchPixelsX().Size() > 0 || data->GetStretchPixelsY().Size() > 0)
     {
       Uint16Pair gridSize(2 * data->GetStretchPixelsX().Size() + 1, 2 * data->GetStretchPixelsY().Size() + 1);
-      geometry = CreateNPatchGeometry(gridSize);
+      geometry = NPatchHelper::CreateGridGeometry(gridSize);
     }
   }
   else
@@ -378,7 +286,7 @@ Geometry VisualFactoryCache::GetNPatchGeometry(int index)
     geometry = GetGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
     if(!geometry)
     {
-      geometry = CreateNPatchGeometry(Uint16Pair(3,3));
+      geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3,3));
       SaveGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry);
     }
   }
@@ -401,7 +309,7 @@ Shader VisualFactoryCache::GetNPatchShader(int index)
     yStretchCount = data->GetStretchPixelsY().Count();
   }
 
-  if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0)))
+  if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0) || (xStretchCount == 1 && yStretchCount == 1)))
   {
     shader = GetShader(VisualFactoryCache::NINE_PATCH_SHADER);
     if(DALI_UNLIKELY(!shader))
@@ -423,37 +331,6 @@ Shader VisualFactoryCache::GetNPatchShader(int index)
   return shader;
 }
 
-void VisualFactoryCache::RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
-{
-  uint16_t     prevEnd     = 0;
-  uint16_t     prevFix     = 0;
-  uint16_t     prevStretch = 0;
-  unsigned int i           = 1;
-  for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
-  {
-    uint16_t start = it->GetX();
-    uint16_t end   = it->GetY();
-
-    uint16_t fix     = prevFix + start - prevEnd;
-    uint16_t stretch = prevStretch + end - start;
-
-    std::stringstream uniform;
-    uniform << uniformName << "[" << i << "]";
-    renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
-
-    prevEnd     = end;
-    prevFix     = fix;
-    prevStretch = stretch;
-  }
-
-  {
-    prevFix += imageExtent - prevEnd;
-    std::stringstream uniform;
-    uniform << uniformName << "[" << i << "]";
-    renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
-  }
-}
-
 void VisualFactoryCache::ApplyTextureAndUniforms(Renderer& renderer, int index)
 {
   const NPatchData* data;
@@ -461,38 +338,23 @@ void VisualFactoryCache::ApplyTextureAndUniforms(Renderer& renderer, int index)
   if(mNPatchLoader.GetNPatchData(mBrokenImageInfoContainer[index].npatchId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
   {
     textureSet = data->GetTextures();
-    mBrokenImageInfoContainer[index].texture = data->GetTextures().GetTexture(0);
-
-    if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
-    {
-      //special case for 9 patch
-      Uint16Pair stretchX = data->GetStretchPixelsX()[0];
-      Uint16Pair stretchY = data->GetStretchPixelsY()[0];
-
-      uint16_t stretchWidth  = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
-      uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
-
-      renderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
-      renderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
-      renderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
-      renderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
-    }
-    else
-    {
-      renderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
-      renderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
-
-      RegisterStretchProperties(renderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
-      RegisterStretchProperties(renderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
-    }
+    mBrokenImageInfoContainer[index].texture = textureSet.GetTexture(0);
+    NPatchHelper::ApplyTextureAndUniforms(renderer, data);
     renderer.SetTextures(textureSet);
   }
 }
 
 void VisualFactoryCache::UpdateBrokenImageRenderer(Renderer& renderer, const Vector2& size)
 {
+
+  bool useDefaultBrokenImage = false;
+  if(mBrokenImageInfoContainer.size() == 0)
+  {
+    useDefaultBrokenImage = true;
+  }
+
   // Load Information for broken image
-  for(uint32_t index = 0; index < mBrokenImageInfoContainer.size(); index++)
+  for(uint32_t index = 0; (index  < mBrokenImageInfoContainer.size()) && !useDefaultBrokenImage; index++)
   {
     if(mBrokenImageInfoContainer[index].width == 0 && mBrokenImageInfoContainer[index].height == 0)
     {
@@ -512,17 +374,36 @@ void VisualFactoryCache::UpdateBrokenImageRenderer(Renderer& renderer, const Vec
           }
           else
           {
-            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [path:%s] \n",mBrokenImageInfoContainer[index].url.c_str());
+            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+            useDefaultBrokenImage = true;
           }
         }
         else
         {
-          GetBrokenVisualImage(index);
+          if(!GetBrokenVisualImage(index))
+          {
+            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+            useDefaultBrokenImage = true;
+          }
         }
       }
     }
   }
 
+  if(!mUseDefaultBrokenImageOnly && useDefaultBrokenImage)
+  {
+    // Clear broken info
+    mBrokenImageInfoContainer.clear();
+
+    // assign for broken image
+    const int defaultBrokenIndex = 0;
+    mBrokenImageInfoContainer.assign(1, BrokenImageInfo());
+    mBrokenImageInfoContainer[defaultBrokenIndex].url = mDefaultBrokenImageUrl;
+    VisualUrl visualUrl(mBrokenImageInfoContainer[defaultBrokenIndex].url);
+    mBrokenImageInfoContainer[defaultBrokenIndex].visualType = visualUrl.GetType();
+    mUseDefaultBrokenImageOnly = true;
+  }
+
   // Set Texutre to renderer
   int brokenIndex = GetProperBrokenImageIndex(size);
   if(GetBrokenImageVisualType(brokenIndex) == VisualUrl::N_PATCH)
@@ -547,7 +428,7 @@ int32_t VisualFactoryCache::GetProperBrokenImageIndex(const Vector2& size)
 {
   // Sets the default broken type
   int32_t returnIndex = 0;
-  if((size.width == 0 || size.height == 0))
+  if((size.width == 0 || size.height == 0) || mUseDefaultBrokenImageOnly )
   {
     // To do : Need to add observer about size
     return returnIndex;
index deae0b0..b19bad4 100644 (file)
@@ -195,7 +195,7 @@ public:
    * @brief Set an image to be used when a visual has failed to correctly render
    * @param[in] brokenImageUrlList The broken image url list
    */
-  void SetBrokenImageUrl(const std::vector<std::string>& brokenImageUrlList);
+  void SetBrokenImageUrl(std::string& defaultBrokenUrl, const std::vector<std::string>& brokenImageUrlList);
 
   /**
    * @brief Update the broken image Renderer object
@@ -272,14 +272,6 @@ private:
   void ApplyTextureAndUniforms(Renderer& renderer, int index);
 
   /**
-   * @brief Creates a Npatch Geometry object
-   *
-   * @param[in] gridSize The gridSize for creating a geometry
-   * @return The Geometry for NPatch
-   */
-  Geometry CreateNPatchGeometry(Uint16Pair gridSize);
-
-  /**
    * @brief Gets a geometry for npatch image
    *
    * @param[in] index the index of broken image
@@ -296,16 +288,6 @@ private:
   Shader GetNPatchShader(int index);
 
   /**
-   * @brief Registers a properties for Stretch Ranges
-   *
-   * @param[in,out] renderer The renderer for broken image
-   * @param[in] uniformName The name of the uniform
-   * @param[in] stretchPixels The stretchable pixels in the cropped image space
-   * @param[in] imageExtent The imageExtent
-   */
-  void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
-
-  /**
    * @brief Returns a broken image type
    * @param[in] index BrokenImage index
    * @return The broken image type.
@@ -349,6 +331,8 @@ private:
   std::unique_ptr<VectorAnimationManager> mVectorAnimationManager;
   bool                                    mPreMultiplyOnLoad;
   std::vector<BrokenImageInfo>            mBrokenImageInfoContainer;
+  std::string                             mDefaultBrokenImageUrl;
+  bool                                    mUseDefaultBrokenImageOnly;
 };
 
 } // namespace Internal
index 112fdd3..4220b00 100644 (file)
@@ -377,20 +377,12 @@ void VisualFactory::SetBrokenImageUrl(Toolkit::StyleManager& styleManager)
   if(styleManager)
   {
     customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
-    if(customBrokenImageUrlList.size() == 0)
-    {
-      Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
-      config["brokenImageUrl"].Get(brokenImageUrl);
-      customBrokenImageUrlList.push_back(brokenImageUrl);
-    }
-    mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
-  }
-  else
-  {
-    // Set default image
-    customBrokenImageUrlList.push_back(brokenImageUrl);
-    mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
+    Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+    config["brokenImageUrl"].Get(brokenImageUrl);
   }
+
+  // Add default image
+  mFactoryCache->SetBrokenImageUrl(brokenImageUrl, customBrokenImageUrlList);
 }
 
 Internal::VisualFactoryCache& VisualFactory::GetFactoryCache()
index db99728..9c52f22 100644 (file)
@@ -566,7 +566,7 @@ void Control::OnPropertySet(Property::Index index, const Property::Value& proper
     }
     case Actor::Property::VISIBLE:
     {
-      if(Dali::Accessibility::IsUp())
+      if(Dali::Accessibility::IsUp() && !Self().GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN))
       {
         Dali::Accessibility::Accessible::Get(Self())->EmitVisible(Self().GetProperty(Actor::Property::VISIBLE).Get<bool>());
       }