Merge "Fix PageFactory to take in Texture rather than Image" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / page-turn-view / page-turn-view-impl.cpp
index 112fa05..3eb9ab0 100644 (file)
 #include <cstring> // for strcmp
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/images/resource-image.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
-#include <dali/devel-api/images/texture-set-image.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -39,9 +37,6 @@ using namespace Dali;
 
 namespace //Unnamed namespace
 {
-// broken image is loaded if there is no valid image provided for the page
-const char * const BROKEN_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
-
 // properties set on shader, these properties have the constant value in regardless of the page status
 const char * const PROPERTY_SPINE_SHADOW ( "uSpineShadowParameter" ); // uniform for both spine and turn effect
 
@@ -282,14 +277,13 @@ PageTurnView::Page::Page()
   propertyTurnDirection = actor.RegisterProperty(PROPERTY_TURN_DIRECTION, -1.f);
 }
 
-void PageTurnView::Page::SetImage( Image image  )
+void PageTurnView::Page::SetTexture( Texture texture )
 {
   if( !textureSet )
   {
     textureSet = TextureSet::New();
   }
-
-  TextureSetImage( textureSet, 0u, image );
+  textureSet.SetTexture( 0u, texture );
 }
 
 void PageTurnView::Page::UseEffect(Shader newShader)
@@ -398,7 +392,7 @@ void PageTurnView::OnInitialize()
     Self().Add( mPages[i].actor );
   }
 
-  // create the layer for turning images
+  // create the layer for turning pages
   mTurningPageLayer = Layer::New();
   mTurningPageLayer.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
   mTurningPageLayer.SetBehavior(Layer::LAYER_3D);
@@ -584,13 +578,9 @@ void PageTurnView::AddPage( int pageIndex )
   {
     int index = pageIndex % NUMBER_OF_CACHED_PAGES;
 
-    Image newPageImage;
-    newPageImage = mPageFactory->NewPage( pageIndex );
-
-    if( !newPageImage ) // load the broken image
-    {
-      newPageImage = ResourceImage::New( BROKEN_IMAGE_URL );
-    }
+    Texture newPage;
+    newPage = mPageFactory->NewPage( pageIndex );
+    DALI_ASSERT_ALWAYS( newPage && "must pass in valid texture" );
 
     bool isLeftSide = ( pageIndex < mCurrentPageIndex );
     if( mPages[index].isTurnBack != isLeftSide )
@@ -602,11 +592,11 @@ void PageTurnView::AddPage( int pageIndex )
     mPages[index].actor.SetOrientation( Degree( degree ), Vector3::YAXIS );
     mPages[index].actor.SetVisible( false );
     mPages[index].UseEffect( mSpineEffectShader, mGeometry );
-    mPages[index].SetImage( newPageImage );
+    mPages[index].SetTexture( newPage );
 
     // For Portrait, nothing to do
     // For Landscape, set the parent origin to CENTER
-     OnAddPage( mPages[index].actor, isLeftSide );
+    OnAddPage( mPages[index].actor, isLeftSide );
   }
 }