#include <sstream>
#include <dali-toolkit-test-suite-utils.h>
#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/public-api/images/buffer-image.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-factory.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
const unsigned int TOTAL_PAGE_NUMBER = 20;
const Vector2 PAGE_SIZE( 300.f,400.f );
-const unsigned int IMAGE_WIDTH = 30;
-const unsigned int IMAGE_HEIGHT = 30;
-const Vector2 IMAGE_SIZE( static_cast<float>( IMAGE_WIDTH ), static_cast<float>(IMAGE_HEIGHT) );
const Vector2 SPINE_SHADOW_PARAMETER( 60.0f, 30.0f );
static bool gObjectCreatedCallBackCalled;
{
public:
- TestPageFactory(ToolkitTestApplication& application)
- : mApplication( application )
+ TestPageFactory(ToolkitTestApplication& application, bool returnValidTexture = true )
+ : mApplication( application ),
+ mValidTexture( returnValidTexture )
{
mTotalPageNumber = TOTAL_PAGE_NUMBER;
}
}
/**
- * Create an image to represent a page content.
+ * Create an texture to represent a page content.
* @param[in] pageId The ID of the page to create.
* @return An image, or an empty handle if the ID is out of range.
*/
- virtual Image NewPage( unsigned int pageId )
+ virtual Texture NewPage( unsigned int pageId )
{
- return BufferImage::WHITE();
+ if( mValidTexture )
+ {
+ return Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, 100, 100 );
+ }
+ return Texture(); // empty handle
}
private:
ToolkitTestApplication& mApplication;
unsigned int mTotalPageNumber;
+ bool mValidTexture;
};
}// namespace
DALI_TEST_CHECK( factory.GetExtension() == NULL );
END_TEST;
}
+
+int UtcDaliPageTurnEmptyTextureHandle(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliPageTurnEmptyTextureHandle ");
+
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
+
+ TestPageFactory factory(application, false); // returns empty handles
+ Vector2 size = Stage::GetCurrent().GetSize();
+ try
+ {
+ PageTurnView portraitView = PageTurnPortraitView::New( factory, size );
+ portraitView.SetParentOrigin( ParentOrigin::CENTER );
+ Stage::GetCurrent().Add( portraitView );
+
+ tet_result(TET_FAIL);
+ }
+ catch (DaliException& e)
+ {
+ DALI_TEST_ASSERT(e, "must pass in valid texture", TEST_LOCATION );
+ }
+ catch (...)
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/rendering/texture.h>
namespace Dali
{
{
/**
- * @brief PageFactory is an abstract interface for providing images to PageTurnView
+ * @brief PageFactory is an abstract interface for providing textures to PageTurnView
* Each page is identified by a unique ID, and has a linear order from 0 to GetNumberOfPages()-1
*
* @SINCE_1_1.4
/**
* @brief Virtual destructor
- * @SINCE_1_1.4
*/
virtual ~PageFactory(){};
* @brief Query the number of pages available from the factory.
*
* The maximum available page has an ID of GetNumberOfPages()-1.
- * @SINCE_1_1.4
* @return The page count.
*/
virtual unsigned int GetNumberOfPages() = 0;
/**
- * @brief Create an actor to represent the page content.
- * @SINCE_1_1.30
+ * @brief Return the texture for the page
*
- * If no valid image provided, a broken image is displayed.
- * For double-sided page( PageTurnLandscapeView ), the left half of image is used as page front side, and the right half as page back side.
+ * For double-sided page( PageTurnLandscapeView ), the left half of texture is used as page front side, and the right half as page back side.
+ *
+ * @note Must return a valid texture handle!
*
* @param[in] pageId The ID of the page to create.
* @return An actor, or an uninitialized pointer if the ID is out of range.
*/
- virtual Image NewPage( unsigned int pageId ) = 0;
+ virtual Texture NewPage( unsigned int pageId ) = 0;
/**
* @brief Retrieve the extension for this factory
- * @SINCE_1_1.30
*
* @return The extension if available, NULL otherwise.
*/
#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
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
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)
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);
{
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 )
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 );
}
}
~Page(){};
/**
- * Set the page image content
- * @param[in] image The content of the page.
+ * Set the page texture content
+ * @param[in] texture The content of the page.
*/
- void SetImage( Image image );
+ void SetTexture( Texture texture );
/**
* Apply an effect onto the page actor.