Updated Gradient renderer to use SetTexture 89/79189/1
authorTom Robinson <tom.robinson@samsung.com>
Fri, 8 Jul 2016 14:27:38 +0000 (15:27 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Fri, 8 Jul 2016 14:27:38 +0000 (15:27 +0100)
Change-Id: Idefa4088fa1d008768fb9bce30139b30d5fb8c9c

dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp
dali-toolkit/internal/controls/renderers/gradient/gradient.cpp
dali-toolkit/internal/controls/renderers/gradient/gradient.h

index 637dd6b..f64ad61 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2015 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -326,8 +326,8 @@ void GradientRenderer::InitializeRenderer()
 
   //Set up the texture set
   TextureSet textureSet = TextureSet::New();
 
   //Set up the texture set
   TextureSet textureSet = TextureSet::New();
-  Dali::BufferImage lookupTexture = mGradient->GenerateLookupTexture();
-  textureSet.SetImage( 0u, lookupTexture );
+  Dali::Texture lookupTexture = mGradient->GenerateLookupTexture();
+  textureSet.SetTexture( 0u, lookupTexture );
   Dali::WrapMode::Type wrap = GetWrapMode( mGradient->GetSpreadMethod() );
   Sampler sampler = Sampler::New();
   sampler.SetWrapMode(  wrap, wrap  );
   Dali::WrapMode::Type wrap = GetWrapMode( mGradient->GetSpreadMethod() );
   Sampler sampler = Sampler::New();
   sampler.SetWrapMode(  wrap, wrap  );
index d87d132..e070754 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2015 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ const Matrix3& Gradient::GetAlignmentTransform() const
  *  If the stops have not covered the whole zero to one range,
  *  the REPEAT spread behaves different from the two others in the lookup texture generation.
  */
  *  If the stops have not covered the whole zero to one range,
  *  the REPEAT spread behaves different from the two others in the lookup texture generation.
  */
-BufferImage Gradient::GenerateLookupTexture()
+Dali::Texture Gradient::GenerateLookupTexture()
 {
   std::sort( mGradientStops.Begin(), mGradientStops.End() );
 
 {
   std::sort( mGradientStops.Begin(), mGradientStops.End() );
 
@@ -133,8 +133,11 @@ BufferImage Gradient::GenerateLookupTexture()
    * Generate the pixels with the color transit from one stop to next.
    */
   unsigned int resolution = EstimateTextureResolution();
    * Generate the pixels with the color transit from one stop to next.
    */
   unsigned int resolution = EstimateTextureResolution();
-  BufferImage texture = BufferImage::New( resolution, 1 );
-  PixelBuffer* pixels = texture.GetBuffer();
+
+  unsigned int bufferSize = resolution * 4u;
+  unsigned char* pixels = new unsigned char[ bufferSize ];
+  PixelData pixelData = PixelData::New( pixels, bufferSize, resolution, 1u, Pixel::RGBA8888, PixelData::DELETE_ARRAY );
+
   int segmentStart = 0;
   int segmentEnd = 0;
   int k = 0;
   int segmentStart = 0;
   int segmentEnd = 0;
   int k = 0;
@@ -161,6 +164,9 @@ BufferImage Gradient::GenerateLookupTexture()
     segmentStart = segmentEnd;
   }
 
     segmentStart = segmentEnd;
   }
 
+  Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, resolution, 1u );
+  texture.Upload( pixelData );
+
   // remove the stops added temporarily for generating the pixels, as the spread method might get changed later
   if( tempLastStop )
   {
   // remove the stops added temporarily for generating the pixels, as the spread method might get changed later
   if( tempLastStop )
   {
index 36e6ee4..64fd6b5 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_INTERNAL_GRADIENT_H__
 
 /*
 #define __DALI_TOOLKIT_INTERNAL_GRADIENT_H__
 
 /*
- * Copyright (c) 2015 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/images/buffer-image.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/images/buffer-image.h>
+#include <dali/devel-api/rendering/texture.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -130,9 +131,9 @@ public:
 
   /**
    * Generate the lookup texture with the gradient stops.
 
   /**
    * Generate the lookup texture with the gradient stops.
-   * @return the lookup texture which transit smoothly between stops.
+   * @return The lookup texture which transit smoothly between stops.
    */
    */
-  BufferImage GenerateLookupTexture();
+  Dali::Texture GenerateLookupTexture();
 
 private:
 
 
 private: