Merge "Ensuring test files match dali-core/adaptor" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 18 Jan 2021 16:30:22 +0000 (16:30 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 18 Jan 2021 16:30:22 +0000 (16:30 +0000)
12 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-view.cpp [changed mode: 0644->0755]
dali-toolkit/devel-api/controls/web-view/web-view.h [changed mode: 0644->0755]
dali-toolkit/internal/controls/web-view/web-view-impl.cpp [changed mode: 0644->0755]
dali-toolkit/internal/controls/web-view/web-view-impl.h [changed mode: 0644->0755]
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/texture-manager-impl.h
dali-toolkit/internal/visuals/visual-factory-cache.cpp

index 372aec9..9d7a582 100755 (executable)
@@ -73,6 +73,9 @@ public:
     , mDefaultTextEncodingName()
     , mDefaultFontSize( 16 )
     , mEvaluating( false )
+    , mScrollPosition( 0, 0 )
+    , mScrollSize( 500, 500 )
+    , mContentSize( 500, 500 )
   {
     gInstanceCount++;
     gInstance = this;
@@ -205,6 +208,39 @@ public:
     mDefaultFontSize = defaultFontSize;
   }
 
+  void ScrollBy( int dx, int dy )
+  {
+    mScrollPosition += Dali::Vector2( dx, dy );
+    if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+    {
+      gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
+    }
+  }
+
+  void SetScrollPosition( int x, int y )
+  {
+    mScrollPosition.x = x;
+    mScrollPosition.y = y;
+  }
+
+  void GetScrollPosition( int& x, int& y ) const
+  {
+    x = mScrollPosition.x;
+    y = mScrollPosition.y;
+  }
+
+  void GetScrollSize( int& w, int& h ) const
+  {
+    w = mScrollSize.width;
+    h = mScrollSize.height;
+  }
+
+  void GetContentSize( int& w, int& h ) const
+  {
+    w = mContentSize.width;
+    h = mContentSize.height;
+  }
+
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
   {
     return mPageLoadStartedSignal;
@@ -220,6 +256,11 @@ public:
     return mPageLoadErrorSignal;
   }
 
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+  {
+    return mScrollEdgeReachedSignal;
+  }
+
   std::string                                                mUrl;
   std::vector< std::string >                                 mHistory;
   size_t                                                     mCurrentPlusOnePos;
@@ -235,6 +276,11 @@ public:
   Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType    mPageLoadErrorSignal;
   std::vector< std::function< void( const std::string& ) > > mResultCallbacks;
   bool                                                       mEvaluating;
+
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+  Dali::Vector2                                               mScrollPosition;
+  Dali::Vector2                                               mScrollSize;
+  Dali::Vector2                                               mContentSize;
 };
 
 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
@@ -522,6 +568,31 @@ void WebEngine::SetDefaultFontSize( int defaultFontSize )
   Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
 }
 
+void WebEngine::ScrollBy( int dx, int dy )
+{
+  Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
+}
+
+void WebEngine::SetScrollPosition( int x, int y )
+{
+  Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollPosition( int& x, int& y ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollSize( int& w, int& h ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetScrollSize( w, h );
+}
+
+void WebEngine::GetContentSize( int& w, int& h ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetContentSize( w, h );
+}
+
 void WebEngine::SetSize( int width, int height )
 {
 }
@@ -555,5 +626,10 @@ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErro
   return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
 }
 
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
+}
+
 } // namespace Dali;
 
index 706f8da..2ad46f4 100644 (file)
@@ -1247,6 +1247,11 @@ int UtcDaliImageVisualSetInvalidSyncImage(void)
   application.SendNotification();
   application.Render();
 
+  // Check resource status
+  Visual::ResourceStatus status = actor.GetVisualResourceStatus(Control::CONTROL_PROPERTY_END_INDEX + 1);
+  DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+  // The broken image should be shown.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
 
index d9c34a6..0ca47b6 100644 (file)
@@ -39,6 +39,7 @@ const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
 
 static int gPageLoadStartedCallbackCalled = 0;
 static int gPageLoadFinishedCallbackCalled = 0;
+static int gScrollEdgeReachedCallbackCalled = 0;
 static int gEvaluateJavaScriptCallbackCalled = 0;
 static bool gTouched = false;
 
@@ -66,6 +67,11 @@ static void OnPageLoadFinished( WebView view, const std::string& url )
   gPageLoadFinishedCallbackCalled++;
 }
 
+static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
+{
+  gScrollEdgeReachedCallbackCalled++;
+}
+
 static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode )
 {
 }
@@ -491,6 +497,72 @@ int UtcDaliWebViewProperty8(void)
   END_TEST;
 }
 
+int UtcDaliWebViewProperty9(void)
+{
+  // SCROLL_POSITION
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  // Check default value
+  Dali::Vector2 output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
+
+  // Check Set/GetProperty
+  Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+  view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+  // Check default value of scroll size
+  output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
+  DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+  // Check default value of content size
+  output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
+  DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewScrollBy(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  // load url.
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
+  bool signal1 = false;
+  view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
+  DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
+
+  view.LoadUrl( TEST_URL1 );
+  Test::EmitGlobalTimerSignal();
+
+  // set scroll position.
+  Dali::Vector2 output = Dali::Vector2::ONE;
+  Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+  view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+  // scroll by and trigger scrollEdgeReached event.
+  view.ScrollBy( 50, 50 );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
+  DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
+  DALI_TEST_CHECK( signal1 );
+
+  END_TEST;
+}
+
 int UtcDaliWebViewEvaluteJavaScript(void)
 {
   ToolkitTestApplication application;
old mode 100644 (file)
new mode 100755 (executable)
index 7758f7b..338f8b9
@@ -93,6 +93,11 @@ void WebView::Resume()
   Dali::Toolkit::GetImpl(*this).Resume();
 }
 
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+  Dali::Toolkit::GetImpl( *this ).ScrollBy( deltaX, deltaY );
+}
+
 bool WebView::CanGoForward()
 {
   return Dali::Toolkit::GetImpl(*this).CanGoForward();
@@ -158,6 +163,11 @@ WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
   return Dali::Toolkit::GetImpl(*this).PageLoadErrorSignal();
 }
 
+WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+  return Dali::Toolkit::GetImpl( *this ).ScrollEdgeReachedSignal();
+}
+
 WebView::WebView(Internal::WebView& implementation)
 : Control(implementation)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 83b5ebd..f447eda
@@ -22,6 +22,7 @@
 #include <functional>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
 #include <dali-toolkit/public-api/controls/control.h>
 
 namespace Dali
@@ -173,7 +174,25 @@ public:
        * @details Name "defaultFontSize", type Property::INT.
        * @note Default is 16.
        */
-      DEFAULT_FONT_SIZE
+      DEFAULT_FONT_SIZE,
+
+      /**
+       * @brief The current position of scroll.
+       * @details Name "scrollPosition", type Property::VECTOR2.
+       */
+      SCROLL_POSITION,
+
+      /**
+       * @brief The current position of scroll.
+       * @details Name "scrollSize", type Property::VECTOR2. Read-only.
+       */
+      SCROLL_SIZE,
+
+      /**
+       * @brief The current position of scroll.
+       * @details Name "contentSize", type Property::VECTOR2. Read-only.
+       */
+      CONTENT_SIZE,
     };
   };
 
@@ -268,6 +287,11 @@ public:
    */
   typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
 
+  /**
+   * @brief WebView signal type related with scroll edge reached.
+   */
+  typedef Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)> WebViewScrollEdgeReachedSignalType;
+
 public:
   /**
    * @brief Creates an initialized WebView.
@@ -358,6 +382,13 @@ public:
   void Resume();
 
   /**
+   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   * @param[in] deltaX The delta x of scroll
+   * @param[in] deltaY The delta y of scroll
+   */
+  void ScrollBy( int deltaX, int deltaY );
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -458,6 +489,13 @@ public:
    */
   WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when scroll edge is reached.
+   *
+   * @return A signal object to connect with.
+   */
+  WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
 public: // Not intended for application developers
   /// @cond internal
   /**
old mode 100644 (file)
new mode 100755 (executable)
index 1c9d939..db14c27
@@ -72,10 +72,14 @@ DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript",        BOOLEAN
 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY  )
 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING,  DEFAULT_TEXT_ENCODING_NAME )
 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize",         INTEGER, DEFAULT_FONT_SIZE          )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition",          VECTOR2, SCROLL_POSITION            )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize",              VECTOR2, SCROLL_SIZE                )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize",             VECTOR2, CONTENT_SIZE               )
 
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadStarted",         PAGE_LOAD_STARTED_SIGNAL            )
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadFinished",        PAGE_LOAD_FINISHED_SIGNAL           )
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadError",           PAGE_LOAD_ERROR_SIGNAL              )
+DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "scrollEdgeReached",       SCROLL_EDGE_REACHED_SIGNAL          )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -145,6 +149,7 @@ void WebView::OnInitialize()
     mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
     mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
     mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
+    mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
   }
 }
 
@@ -218,6 +223,14 @@ void WebView::Resume()
   }
 }
 
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.ScrollBy( deltaX, deltaY );
+  }
+}
+
 bool WebView::CanGoForward()
 {
   return mWebEngine ? mWebEngine.CanGoForward() : false;
@@ -299,6 +312,11 @@ Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSi
   return mPageLoadErrorSignal;
 }
 
+Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+  return mScrollEdgeReachedSignal;
+}
+
 void WebView::OnPageLoadStarted( const std::string& url )
 {
   if( !mPageLoadStartedSignal.Empty() )
@@ -326,6 +344,15 @@ void WebView::OnPageLoadError( const std::string& url, int errorCode )
   }
 }
 
+void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
+{
+  if( !mScrollEdgeReachedSignal.Empty() )
+  {
+    Dali::Toolkit::WebView handle( GetOwner() );
+    mScrollEdgeReachedSignal.Emit( handle, edge );
+  }
+}
+
 bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   Dali::BaseHandle handle( object );
@@ -348,6 +375,11 @@ bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* t
     webView.PageLoadErrorSignal().Connect( tracker, functor );
     connected = true;
   }
+  else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
+  {
+    webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
+    connected = true;
+  }
 
   return connected;
 }
@@ -456,6 +488,15 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
+      case Toolkit::WebView::Property::SCROLL_POSITION:
+      {
+        Vector2 input;
+        if ( value.Get( input ) )
+        {
+          impl.SetScrollPosition( input.x, input.y );
+        }
+        break;
+      }
     }
   }
 }
@@ -511,6 +552,27 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
         value = impl.GetDefaultFontSize();
         break;
       }
+      case Toolkit::WebView::Property::SCROLL_POSITION:
+      {
+        int x, y;
+        impl.GetScrollPosition( x, y );
+        value = Vector2( x, y );
+        break;
+      }
+      case Toolkit::WebView::Property::SCROLL_SIZE:
+      {
+        int width, height;
+        impl.GetScrollSize( width, height );
+        value = Vector2( width, height );
+        break;
+      }
+      case Toolkit::WebView::Property::CONTENT_SIZE:
+      {
+        int width, height;
+        impl.GetContentSize( width, height );
+        value = Vector2( width, height );
+        break;
+      }
       default:
          break;
     }
@@ -561,6 +623,38 @@ void WebView::OnKeyInputFocusLost()
   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
 }
 
+void WebView::SetScrollPosition( int x, int y )
+{
+  if( mWebEngine )
+  {
+    mWebEngine.SetScrollPosition( x, y );
+  }
+}
+
+void WebView::GetScrollPosition( int& x, int& y ) const
+{
+  if( mWebEngine )
+  {
+    mWebEngine.GetScrollPosition( x, y );
+  }
+}
+
+void WebView::GetScrollSize( int& width, int& height ) const
+{
+  if( mWebEngine )
+  {
+    mWebEngine.GetScrollSize( width, height );
+  }
+}
+
+void WebView::GetContentSize( int& width, int& height ) const
+{
+  if( mWebEngine )
+  {
+    mWebEngine.GetContentSize( width, height );
+  }
+}
+
 Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
 {
   return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
old mode 100644 (file)
new mode 100755 (executable)
index 968b742..0769bad
@@ -93,6 +93,11 @@ public:
   void Resume();
 
   /**
+   * @copydoc Dali::Toolkit::WebView::ScrollBy()
+   */
+  void ScrollBy( int deltaX, int deltaY );
+
+  /**
    * @copydoc Dali::Toolkit::WebView::CanGoForward()
    */
   bool CanGoForward();
@@ -152,6 +157,11 @@ public:
    */
   Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
 
+  /**
+   * @copydoc Dali::Toolkit::WebView::ScrollEdgeReachedSignal()
+   */
+  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
 public: // Properties
 
   /**
@@ -231,6 +241,34 @@ private:
   WebView& operator=( const WebView& webView );
 
   /**
+   * @brief Sets an absolute scroll of the given view.
+   * @param[in] x The coordinate x of scroll
+   * @param[in] y The coordinate y of scroll
+   */
+  void SetScrollPosition( int x, int y );
+
+  /**
+   * @brief Gets the current scroll position of the given view.
+   * @param[out] x The coordinate x of scroll
+   * @param[out] y The coordinate y of scroll
+   */
+  void GetScrollPosition( int& x, int& y ) const;
+
+  /**
+   * @brief Gets the possible scroll size of the given view.
+   * @param[out] width The width of scroll size
+   * @param[out] height The height of scroll size
+   */
+  void GetScrollSize( int& width, int& height ) const;
+
+  /**
+   * @brief Gets the last known content's size.
+   * @param[out] width The width of content's size
+   * @param[out] height The height of content's size
+   */
+  void GetContentSize( int& width, int& height ) const;
+
+  /**
    * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
    * @see Toolkit::WebView::CacheModel::Type
    */
@@ -343,6 +381,12 @@ private:
    */
   void OnPageLoadError( const std::string& url, int errorCode );
 
+  /**
+   * @brief Callback function to be called when scroll edge is reached.
+   * @param[in] e The scroll edge reached.
+   */
+  void OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge );
+
 private:
 
   std::string                                            mUrl;
@@ -353,6 +397,7 @@ private:
   Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadStartedSignal;
   Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadFinishedSignal;
   Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
+  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
 };
 
 } // namespace Internal
index 0cd4c1b..3a91784 100644 (file)
@@ -143,32 +143,32 @@ ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
   return new ImageVisual( factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode );
 }
 
-ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
-                          ImageVisualShaderFactory& shaderFactory,
-                          const VisualUrl& imageUrl,
-                          ImageDimensions size,
-                          FittingMode::Type fittingMode,
-                          Dali::SamplingMode::Type samplingMode )
-: Visual::Base( factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE ),
-  mPixelArea( FULL_TEXTURE_RECT ),
+ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
+                         ImageVisualShaderFactory& shaderFactory,
+                         const VisualUrl&          imageUrl,
+                         ImageDimensions           size,
+                         FittingMode::Type         fittingMode,
+                         Dali::SamplingMode::Type  samplingMode)
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
+  mPixelArea(FULL_TEXTURE_RECT),
   mPlacementActor(),
-  mImageUrl( imageUrl ),
-  mMaskingData( ),
-  mDesiredSize( size ),
-  mTextureId( TextureManager::INVALID_TEXTURE_ID ),
+  mImageUrl(imageUrl),
+  mMaskingData(),
+  mDesiredSize(size),
+  mTextureId(TextureManager::INVALID_TEXTURE_ID),
   mTextures(),
-  mImageVisualShaderFactory( shaderFactory ),
-  mFittingMode( fittingMode ),
-  mSamplingMode( samplingMode ),
-  mWrapModeU( WrapMode::DEFAULT ),
-  mWrapModeV( WrapMode::DEFAULT ),
-  mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
-  mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED ),
-  mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
-  mAtlasRectSize( 0, 0 ),
-  mAttemptAtlasing( false ),
-  mLoading( false ),
-  mOrientationCorrection( true )
+  mImageVisualShaderFactory(shaderFactory),
+  mFittingMode(fittingMode),
+  mSamplingMode(samplingMode),
+  mWrapModeU(WrapMode::DEFAULT),
+  mWrapModeV(WrapMode::DEFAULT),
+  mLoadPolicy(Toolkit::ImageVisual::LoadPolicy::ATTACHED),
+  mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED),
+  mAtlasRect(0.0f, 0.0f, 0.0f, 0.0f),
+  mAtlasRectSize(0, 0),
+  mLoadState(TextureManager::LoadState::NOT_STARTED),
+  mAttemptAtlasing(false),
+  mOrientationCorrection(true)
 {
   EnablePreMultipliedAlpha( mFactoryCache.GetPreMultiplyOnLoad() );
 }
@@ -570,16 +570,29 @@ void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& t
     ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
     : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
-  textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
-                                         mMaskingData, IsSynchronousLoadingRequired(), mTextureId,
-                                         atlasRect, mAtlasRectSize, atlasing, mLoading, mWrapModeU,
-                                         mWrapModeV, textureObserver, atlasUploadObserver, atlasManager,
-                                         mOrientationCorrection, forceReload, preMultiplyOnLoad);
+  bool synchronousLoading = IsSynchronousLoadingRequired();
+  bool loadingStatus;
+
+  textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, mWrapModeU, mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
 
   if( textures )
   {
+    if(loadingStatus)
+    {
+      mLoadState = TextureManager::LoadState::LOADING;
+    }
+    else
+    {
+      mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+    }
+
     EnablePreMultipliedAlpha( preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD );
   }
+  else if(synchronousLoading)
+  {
+    // Synchronous loading is failed
+    mLoadState = TextureManager::LoadState::LOAD_FAILED;
+  }
 
   if( atlasing ) // Flag needs to be set before creating renderer
   {
@@ -666,7 +679,7 @@ void ImageVisual::DoSetOnScene( Actor& actor )
     mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
   }
 
-  if( mLoading == false )
+  if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
   {
     actor.AddRenderer( mImpl->mRenderer );
     mPlacementActor.Reset();
@@ -674,6 +687,19 @@ void ImageVisual::DoSetOnScene( Actor& actor )
     // Image loaded and ready to display
     ResourceReady( Toolkit::Visual::ResourceStatus::READY );
   }
+  else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
+  {
+    Texture brokenImage = mFactoryCache.GetBrokenVisualImage();
+
+    mTextures = TextureSet::New();
+    mTextures.SetTexture(0u, brokenImage);
+    mImpl->mRenderer.SetTextures(mTextures);
+
+    actor.AddRenderer(mImpl->mRenderer);
+    mPlacementActor.Reset();
+
+    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+  }
 }
 
 void ImageVisual::DoSetOffScene( Actor& actor )
@@ -686,9 +712,10 @@ void ImageVisual::DoSetOffScene( Actor& actor )
   {
     RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
     mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+    mLoadState = TextureManager::LoadState::NOT_STARTED;
   }
 
-  mLoading = false;
   mImpl->mRenderer.Reset();
   mPlacementActor.Reset();
 }
@@ -791,9 +818,10 @@ void ImageVisual::UploadCompleted()
     // reset the weak handle so that the renderer only get added to actor once
     mPlacementActor.Reset();
   }
+
   // Image loaded
   ResourceReady( Toolkit::Visual::ResourceStatus::READY );
-  mLoading = false;
+  mLoadState = TextureManager::LoadState::LOAD_FINISHED;
 }
 
 // From Texture Manager
@@ -844,10 +872,12 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
   if( loadingSuccess )
   {
     resourceStatus = Toolkit::Visual::ResourceStatus::READY;
+    mLoadState     = TextureManager::LoadState::LOAD_FINISHED;
   }
   else
   {
     resourceStatus = Toolkit::Visual::ResourceStatus::FAILED;
+    mLoadState     = TextureManager::LoadState::LOAD_FAILED;
   }
 
   // use geometry if needed
@@ -882,7 +912,6 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
 
   // Signal to observers ( control ) that resources are ready. Must be all resources.
   ResourceReady( resourceStatus );
-  mLoading = false;
 }
 
 void ImageVisual::RemoveTexture()
index 9ae50df..fb1a529 100644 (file)
@@ -350,13 +350,11 @@ private:
   Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
   Vector4 mAtlasRect;
   Dali::ImageDimensions mAtlasRectSize;
+  TextureManager::LoadState                       mLoadState;       ///< The texture loading state
   bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
-  bool mLoading;  ///< True if the texture is still loading.
   bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
 };
 
-
-
 } // namespace Internal
 
 } // namespace Toolkit
index bcde348..1db057b 100644 (file)
@@ -132,7 +132,6 @@ TextureManager::TextureManager()
   mExternalTextures(),
   mLifecycleObservers(),
   mLoadQueue(),
-  mBrokenImageUrl(""),
   mCurrentTextureId( 0 ),
   mQueueLoadFlag(false)
 {
@@ -163,18 +162,7 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
     }
     if( !pixelBuffer )
     {
-      // use broken image
-      pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
-      PixelData pixelData;
-      if( pixelBuffer )
-      {
-        pixelData = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
-      }
-      Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(),
-                                      pixelData.GetWidth(), pixelData.GetHeight() );
-      texture.Upload( pixelData );
-      textureSet = TextureSet::New();
-      textureSet.SetTexture( 0u, texture );
+      DALI_LOG_ERROR("TextureManager::LoadAnimatedImageTexture: Synchronous loading is failed\n");
     }
     else
     {
@@ -294,18 +282,7 @@ TextureSet TextureManager::LoadTexture(
     }
     if( !data )
     {
-      // use broken image
-      Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
-      if( pixelBuffer )
-      {
-        PreMultiply( pixelBuffer, preMultiplyOnLoad );
-        data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
-      }
-      Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, data.GetPixelFormat(),
-                                      data.GetWidth(), data.GetHeight() );
-      texture.Upload( data );
-      textureSet = TextureSet::New();
-      textureSet.SetTexture( 0u, texture );
+      DALI_LOG_ERROR("TextureManager::LoadTexture: Synchronous loading is failed\n");
     }
     else
     {
@@ -1376,11 +1353,6 @@ void TextureManager::AsyncLoadingHelper::AsyncLoadComplete(uint32_t           id
   mTextureManager.AsyncLoadComplete( mLoadingInfoContainer, id, pixelBuffer );
 }
 
-void TextureManager::SetBrokenImageUrl(const std::string& brokenImageUrl)
-{
-  mBrokenImageUrl = brokenImageUrl;
-}
-
 Geometry TextureManager::GetRenderGeometry(TextureId textureId, uint32_t& frontElements, uint32_t& backElements )
 {
   return RenderingAddOn::Get().IsValid() ?
index 89a8ed0..6e17945 100644 (file)
@@ -422,12 +422,6 @@ public:
   void RemoveObserver( TextureManager::LifecycleObserver& observer );
 
   /**
-   * @brief Set an image to be used when a visual has failed to correctly render
-   * @param[in] brokenImageUrl The broken image url.
-   */
-  void SetBrokenImageUrl(const std::string& brokenImageUrl);
-
-  /**
    * @brief Returns the geometry associated with texture.
    * @param[in] textureId Id of the texture
    * @param[out] frontElements number of front elements
@@ -897,7 +891,6 @@ private:  // Member Variables:
   std::vector< ExternalTextureInfo >            mExternalTextures;     ///< Externally provided textures
   Dali::Vector<LifecycleObserver*>              mLifecycleObservers;   ///< Lifecycle observers of texture manager
   Dali::Vector<LoadQueueElement>                mLoadQueue;            ///< Queue of textures to load after NotifyObservers
-  std::string                                   mBrokenImageUrl;       ///< Broken image url
   TextureId                                     mCurrentTextureId;     ///< The current value used for the unique Texture Id generation
   bool                                          mQueueLoadFlag;        ///< Flag that causes Load Textures to be queued.
 };
index bb6eb81..e6a0efd 100644 (file)
@@ -246,7 +246,6 @@ void VisualFactoryCache::SetBrokenImageUrl(const std::string& brokenImageUrl)
   }
 
   mAtlasManager->SetBrokenImage( mBrokenImageUrl );
-  mTextureManager.SetBrokenImageUrl( mBrokenImageUrl );
 }
 
 } // namespace Internal