DALi Version 1.2.29
[platform/core/uifw/dali-demo.git] / shared / utility.h
index 3285b98..76a814b 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_DEMO_UTILITY_H__
-#define __DALI_DEMO_UTILITY_H__
+#ifndef DALI_DEMO_UTILITY_H
+#define DALI_DEMO_UTILITY_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -19,9 +19,9 @@
  */
 
 #include <dali/dali.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali/devel-api/rendering/texture.h>
 #include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/public-api/rendering/texture.h>
 
 namespace DemoHelper
 {
@@ -36,19 +36,6 @@ Dali::PixelData LoadPixelData( const char* imagePath,
   return loader.GetPixelData();
 }
 
-
-Dali::Atlas LoadImage( const char* imagePath,
-                       Dali::ImageDimensions size = Dali::ImageDimensions(),
-                       Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
-                       Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT )
-{
-  Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode);
-  Dali::Atlas image  =Dali:: Atlas::New( pixelData.GetWidth(), pixelData.GetHeight(), pixelData.GetPixelFormat() );
-  image.Upload( pixelData, 0u, 0u );
-
-  return image;
-}
-
 Dali::Texture LoadTexture( const char* imagePath,
                            Dali::ImageDimensions size = Dali::ImageDimensions(),
                            Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
@@ -64,28 +51,41 @@ Dali::Texture LoadTexture( const char* imagePath,
   return texture;
 }
 
-/**
- * @brief Load an bitmap resource.
- *
- * If it is required to scaled-down to no more than the stage dimensions,
- * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at
- * load time to cover the entire stage with pixels with no borders,
- * and filter mode BOX_THEN_LINEAR to sample the image with
- * maximum quality.
- */
-
-Dali::Atlas LoadStageFillingImage( const char* imagePath )
-{
-  Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-  return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
-}
-
 Dali::Texture LoadStageFillingTexture( const char* imagePath )
 {
   Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
   return LoadTexture( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
 }
 
+Dali::Geometry CreateTexturedQuad()
+{
+  struct Vertex
+  {
+    Dali::Vector2 position;
+    Dali::Vector2 texCoord;
+  };
+
+  static const Vertex data[] = {{ Dali::Vector2( -0.5f, -0.5f ), Dali::Vector2( 0.0f, 0.0f ) },
+                                { Dali::Vector2(  0.5f, -0.5f ), Dali::Vector2( 1.0f, 0.0f ) },
+                                { Dali::Vector2( -0.5f,  0.5f ), Dali::Vector2( 0.0f, 1.0f ) },
+                                { Dali::Vector2(  0.5f,  0.5f ), Dali::Vector2( 1.0f, 1.0f ) }};
+
+  Dali::PropertyBuffer vertexBuffer;
+  Dali::Property::Map vertexFormat;
+  vertexFormat["aPosition"] = Dali::Property::VECTOR2;
+  vertexFormat["aTexCoord"] = Dali::Property::VECTOR2;
+
+  //Create a vertex buffer for vertex positions and texture coordinates
+  vertexBuffer = Dali::PropertyBuffer::New( vertexFormat );
+  vertexBuffer.SetData( data, 4u );
+
+  //Create the geometry
+  Dali::Geometry geometry = Dali::Geometry::New();
+  geometry.AddVertexBuffer( vertexBuffer );
+  geometry.SetType(Dali::Geometry::TRIANGLE_STRIP );
+
+  return geometry;
+}
 } // DemoHelper
 
-#endif // __DALI_DEMO_HELPER_VIEW_H__
+#endif // DALI_DEMO_UTILITY_H