Commit 893be957bad4f117685d0efe9c912b662e322585

Authored by Adeel Kazmi
Committed by Gerrit Code Review
2 parents 87b66bed bfdbfef7

Merge "Fix PageFactory to take in Texture rather than Image" into devel/master

examples/page-turn-view/page-turn-view-example.cpp
@@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
21 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h> 21 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
22 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h> 22 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
23 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h> 23 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h>
24 -#include <dali/devel-api/images/atlas.h>  
25 24
26 #include <assert.h> 25 #include <assert.h>
27 #include <cstdlib> 26 #include <cstdlib>
@@ -71,19 +70,19 @@ const char* PAGE_IMAGES_LANDSCAPE[] = @@ -71,19 +70,19 @@ const char* PAGE_IMAGES_LANDSCAPE[] =
71 }; 70 };
72 const unsigned int NUMBER_OF_LANDSCAPE_IMAGE( sizeof(PAGE_IMAGES_LANDSCAPE) / sizeof(PAGE_IMAGES_LANDSCAPE[0]) ); 71 const unsigned int NUMBER_OF_LANDSCAPE_IMAGE( sizeof(PAGE_IMAGES_LANDSCAPE) / sizeof(PAGE_IMAGES_LANDSCAPE[0]) );
73 72
74 -Atlas LoadImages( const char*imagePath1, const char* imagePath2 ) 73 +Texture LoadTextures( const char* imagePath1, const char* imagePath2 )
75 { 74 {
76 PixelData pixelData1 = DemoHelper::LoadPixelData( imagePath1, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT ); 75 PixelData pixelData1 = DemoHelper::LoadPixelData( imagePath1, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
77 PixelData pixelData2 = DemoHelper::LoadPixelData( imagePath2, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT ); 76 PixelData pixelData2 = DemoHelper::LoadPixelData( imagePath2, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
78 77
79 - unsigned int width = pixelData1.GetWidth()+pixelData2.GetWidth(); 78 + unsigned int width = pixelData1.GetWidth() + pixelData2.GetWidth();
80 unsigned int height = pixelData1.GetHeight() > pixelData2.GetHeight() ? pixelData1.GetHeight() : pixelData2.GetHeight(); 79 unsigned int height = pixelData1.GetHeight() > pixelData2.GetHeight() ? pixelData1.GetHeight() : pixelData2.GetHeight();
81 80
82 - Atlas image = Atlas::New( width, height );  
83 - image.Upload( pixelData1, 0u, 0u );  
84 - image.Upload( pixelData2, pixelData1.GetWidth(), 0u ); 81 + Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height );
  82 + texture.Upload( pixelData1 );
  83 + texture.Upload( pixelData2, 0u, 0u, pixelData1.GetWidth(), 0u, pixelData2.GetWidth(), pixelData2.GetHeight() );
85 84
86 - return image; 85 + return texture;
87 } 86 }
88 87
89 }// end LOCAL STUFF 88 }// end LOCAL STUFF
@@ -99,21 +98,21 @@ class PortraitPageFactory : public PageFactory @@ -99,21 +98,21 @@ class PortraitPageFactory : public PageFactory
99 return 10*NUMBER_OF_PORTRAIT_IMAGE + 1; 98 return 10*NUMBER_OF_PORTRAIT_IMAGE + 1;
100 } 99 }
101 /** 100 /**
102 - * Create an image to represent a page. 101 + * Create an texture to represent a page.
103 * @param[in] pageId The ID of the page to create. 102 * @param[in] pageId The ID of the page to create.
104 - * @return An image, or an uninitialized pointer if the ID is out of range. 103 + * @return A texture, or an uninitialized handle if the ID is out of range.
105 */ 104 */
106 - virtual Image NewPage( unsigned int pageId ) 105 + virtual Texture NewPage( unsigned int pageId )
107 { 106 {
108 - Atlas page; 107 + Texture page;
109 108
110 if( pageId == 0 ) 109 if( pageId == 0 )
111 { 110 {
112 - page = DemoHelper::LoadImage( BOOK_COVER_PORTRAIT ); 111 + page = DemoHelper::LoadTexture( BOOK_COVER_PORTRAIT );
113 } 112 }
114 else 113 else
115 { 114 {
116 - page = DemoHelper::LoadImage( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ); 115 + page = DemoHelper::LoadTexture( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] );
117 } 116 }
118 117
119 return page; 118 return page;
@@ -132,22 +131,21 @@ class LandscapePageFactory : public PageFactory @@ -132,22 +131,21 @@ class LandscapePageFactory : public PageFactory
132 return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1; 131 return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1;
133 } 132 }
134 /** 133 /**
135 - * Create an image to represent a page. 134 + * Create an texture to represent a page.
136 * @param[in] pageId The ID of the page to create. 135 * @param[in] pageId The ID of the page to create.
137 - * @return An image, or an uninitialized pointer if the ID is out of range. 136 + * @return A texture, or an uninitialized handle if the ID is out of range.
138 */ 137 */
139 - virtual Image NewPage( unsigned int pageId ) 138 + virtual Texture NewPage( unsigned int pageId )
140 { 139 {
141 -  
142 - Atlas page; 140 + Texture page;
143 if( pageId == 0 ) 141 if( pageId == 0 )
144 { 142 {
145 - page = LoadImages( BOOK_COVER_LANDSCAPE, BOOK_COVER_BACK_LANDSCAPE ); 143 + page = LoadTextures( BOOK_COVER_LANDSCAPE, BOOK_COVER_BACK_LANDSCAPE );
146 } 144 }
147 else 145 else
148 { 146 {
149 unsigned int imageId = (pageId-1)*2; 147 unsigned int imageId = (pageId-1)*2;
150 - page = LoadImages( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] ); 148 + page = LoadTextures( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] );
151 } 149 }
152 150
153 return page; 151 return page;
@@ -157,8 +155,8 @@ class LandscapePageFactory : public PageFactory @@ -157,8 +155,8 @@ class LandscapePageFactory : public PageFactory
157 /** 155 /**
158 * This example shows how to use the page turn UI control to implement the page-turn demo 156 * This example shows how to use the page turn UI control to implement the page-turn demo
159 * The effect follows the pan gesture to animate the page 157 * The effect follows the pan gesture to animate the page
160 - * Pan the image inwards, the page will bent,  
161 - * Depends on the distance of the panning, the image might turn over or slide back 158 + * Pan the page inwards, the page will bent,
  159 + * Depends on the distance of the panning, the page might turn over or slide back
162 * Also, in portrait view, the pan gesture outwards from position near the spine could turn the previous page back 160 * Also, in portrait view, the pan gesture outwards from position near the spine could turn the previous page back
163 * Allows to turn multiple pages one by one quickly towards the same direction, multiple animations are launched in this case 161 * Allows to turn multiple pages one by one quickly towards the same direction, multiple animations are launched in this case
164 */ 162 */
shared/utility.h
@@ -37,17 +37,15 @@ Dali::PixelData LoadPixelData( const char* imagePath, @@ -37,17 +37,15 @@ Dali::PixelData LoadPixelData( const char* imagePath,
37 return loader.GetPixelData(); 37 return loader.GetPixelData();
38 } 38 }
39 39
40 -  
41 -Dali::Atlas LoadImage( const char* imagePath, 40 +/**
  41 + * @deprecated, dont use this anymore
  42 + */
  43 +Dali::Image LoadImage( const char* imagePath,
42 Dali::ImageDimensions size = Dali::ImageDimensions(), 44 Dali::ImageDimensions size = Dali::ImageDimensions(),
43 Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT, 45 Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
44 Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT ) 46 Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT )
45 { 47 {
46 - Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode);  
47 - Dali::Atlas image =Dali:: Atlas::New( pixelData.GetWidth(), pixelData.GetHeight(), pixelData.GetPixelFormat() );  
48 - image.Upload( pixelData, 0u, 0u );  
49 -  
50 - return image; 48 + return Dali::ResourceImage::New( imagePath, size, fittingMode, samplingMode );
51 } 49 }
52 50
53 Dali::Texture LoadTexture( const char* imagePath, 51 Dali::Texture LoadTexture( const char* imagePath,
@@ -67,6 +65,7 @@ Dali::Texture LoadTexture( const char* imagePath, @@ -67,6 +65,7 @@ Dali::Texture LoadTexture( const char* imagePath,
67 65
68 /** 66 /**
69 * @brief Load an bitmap resource. 67 * @brief Load an bitmap resource.
  68 + * @deprecated, dont use this anymore
70 * 69 *
71 * If it is required to scaled-down to no more than the stage dimensions, 70 * If it is required to scaled-down to no more than the stage dimensions,
72 * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at 71 * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at
@@ -75,7 +74,7 @@ Dali::Texture LoadTexture( const char* imagePath, @@ -75,7 +74,7 @@ Dali::Texture LoadTexture( const char* imagePath,
75 * maximum quality. 74 * maximum quality.
76 */ 75 */
77 76
78 -Dali::Atlas LoadStageFillingImage( const char* imagePath ) 77 +Dali::Image LoadStageFillingImage( const char* imagePath )
79 { 78 {
80 Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); 79 Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
81 return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); 80 return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );