*/
// CLASS HEADER
-#include "primitive-renderer.h"
+#include "primitive-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/constants.h>
//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+#include <dali-toolkit/internal/controls/renderers/visual-string-constants.h>
+#include <dali-toolkit/internal/controls/renderers/visual-data-impl.h>
namespace Dali
{
} // namespace
-PrimitiveRenderer::PrimitiveRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+PrimitiveVisual::PrimitiveVisual( VisualFactoryCache& factoryCache )
+: Visual( factoryCache ),
mColor( DEFAULT_COLOR ),
mScaleDimensions( Vector3::ONE ),
mScaleTopRadius( DEFAULT_SCALE_TOP_RADIUS ),
{
}
-PrimitiveRenderer::~PrimitiveRenderer()
+PrimitiveVisual::~PrimitiveVisual()
{
}
-void PrimitiveRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void PrimitiveVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
//Find out which shape to renderer.
Property::Value* primitiveType = propertyMap.Find( PRIMITIVE_SHAPE );
}
else
{
- DALI_LOG_ERROR( "No known shape in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "No known shape in PrimitiveVisual.\n" );
}
}
else
{
- DALI_LOG_ERROR( "Invalid type for shape in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for shape in PrimitiveVisual.\n" );
}
}
else
{
- DALI_LOG_ERROR( "Fail to provide shape to the PrimitiveRenderer object.\n" );
+ DALI_LOG_ERROR( "Fail to provide shape to the PrimitiveVisual object.\n" );
}
//Read in other potential properties.
Property::Value* color = propertyMap.Find( SHAPE_COLOR );
if( color && !color->Get( mColor ) )
{
- DALI_LOG_ERROR( "Invalid type for color in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for color in PrimitiveVisual.\n" );
}
Property::Value* slices = propertyMap.Find( SLICES );
}
else
{
- DALI_LOG_ERROR( "Invalid type for slices in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for slices in PrimitiveVisual.\n" );
}
}
}
else
{
- DALI_LOG_ERROR( "Invalid type for stacks in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for stacks in PrimitiveVisual.\n" );
}
}
Property::Value* scaleTop = propertyMap.Find( SCALE_TOP_RADIUS );
if( scaleTop && !scaleTop->Get( mScaleTopRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale top radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale top radius in PrimitiveVisual.\n" );
}
Property::Value* scaleBottom = propertyMap.Find( SCALE_BOTTOM_RADIUS );
if( scaleBottom && !scaleBottom->Get( mScaleBottomRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale bottom radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale bottom radius in PrimitiveVisual.\n" );
}
Property::Value* scaleHeight = propertyMap.Find( SCALE_HEIGHT );
if( scaleHeight && !scaleHeight->Get( mScaleHeight ) )
{
- DALI_LOG_ERROR( "Invalid type for scale height in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale height in PrimitiveVisual.\n" );
}
Property::Value* scaleRadius = propertyMap.Find( SCALE_RADIUS );
if( scaleRadius && !scaleRadius->Get( mScaleRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale radius in PrimitiveVisual.\n" );
}
Property::Value* dimensions = propertyMap.Find( SCALE_DIMENSIONS );
}
else
{
- DALI_LOG_ERROR( "Invalid type for scale dimensions in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale dimensions in PrimitiveVisual.\n" );
}
}
}
else
{
- DALI_LOG_ERROR( "Invalid type for bevel percentage in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for bevel percentage in PrimitiveVisual.\n" );
}
}
}
else
{
- DALI_LOG_ERROR( "Invalid type for bevel smoothness in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for bevel smoothness in PrimitiveVisual.\n" );
}
}
{
if( !lightPosition->Get( mLightPosition ) )
{
- DALI_LOG_ERROR( "Invalid value passed for light position in MeshRenderer object.\n" );
+ DALI_LOG_ERROR( "Invalid value passed for light position in MeshVisual object.\n" );
mLightPosition = Vector3::ZERO;
}
}
}
}
-void PrimitiveRenderer::SetSize( const Vector2& size )
+void PrimitiveVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::SetSize( size );
// ToDo: renderer responds to the size change
}
-void PrimitiveRenderer::SetClipRect( const Rect<int>& clipRect )
+void PrimitiveVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void PrimitiveRenderer::SetOffset( const Vector2& offset )
+void PrimitiveVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-void PrimitiveRenderer::DoSetOnStage( Actor& actor )
+void PrimitiveVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void PrimitiveRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
map.Insert( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
}
-void PrimitiveRenderer::InitializeRenderer()
+void PrimitiveVisual::InitializeRenderer()
{
if( !mGeometry )
{
mImpl->mRenderer = Renderer::New( mGeometry, mShader );
}
-void PrimitiveRenderer::UpdateShaderUniforms()
+void PrimitiveVisual::UpdateShaderUniforms()
{
Stage stage = Stage::GetCurrent();
float width = stage.GetSize().width;
mShader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, mObjectDimensions );
}
-void PrimitiveRenderer::CreateShader()
+void PrimitiveVisual::CreateShader()
{
mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
UpdateShaderUniforms();
}
-void PrimitiveRenderer::CreateGeometry()
+void PrimitiveVisual::CreateGeometry()
{
Dali::Vector<Vertex> vertices;
Dali::Vector<unsigned short> indices;
mGeometry.SetIndexBuffer( &indices[0], indices.Size() );
}
-void PrimitiveRenderer::CreateSphere( Vector<Vertex>& vertices, Vector<unsigned short>& indices, int slices, int stacks )
+void PrimitiveVisual::CreateSphere( Vector<Vertex>& vertices, Vector<unsigned short>& indices, int slices, int stacks )
{
ComputeSphereVertices( vertices, slices, stacks );
FormSphereTriangles( indices, slices, stacks );
mObjectDimensions = Vector3::ONE;
}
-void PrimitiveRenderer::CreateConic( Vector<Vertex>& vertices, Vector<unsigned short>& indices, float scaleTopRadius,
+void PrimitiveVisual::CreateConic( Vector<Vertex>& vertices, Vector<unsigned short>& indices, float scaleTopRadius,
float scaleBottomRadius, float scaleHeight, int slices )
{
ComputeConicVertices( vertices, scaleTopRadius, scaleBottomRadius, scaleHeight, slices );
xDimension / largestDimension );
}
-void PrimitiveRenderer::CreateBevelledCube( Vector<Vertex>& vertices, Vector<unsigned short>& indices,
+void PrimitiveVisual::CreateBevelledCube( Vector<Vertex>& vertices, Vector<unsigned short>& indices,
Vector3 dimensions, float bevelPercentage, float bevelSmoothness )
{
dimensions.Normalize();
mObjectDimensions = dimensions;
}
-void PrimitiveRenderer::ComputeCircleTables( Vector<float>& sinTable, Vector<float>& cosTable, int divisions,
+void PrimitiveVisual::ComputeCircleTables( Vector<float>& sinTable, Vector<float>& cosTable, int divisions,
bool halfCircle )
{
if( divisions < 0 )
}
}
-void PrimitiveRenderer::ComputeSphereVertices( Vector<Vertex>& vertices, int slices, int stacks )
+void PrimitiveVisual::ComputeSphereVertices( Vector<Vertex>& vertices, int slices, int stacks )
{
//Tables for calculating slices angles and stacks angles, respectively.
Vector<float> sinTable1;
vertices[vertexIndex].normal = Vector3( 0.0, -1.0, 0.0 );
}
-void PrimitiveRenderer::FormSphereTriangles( Vector<unsigned short>& indices, int slices, int stacks )
+void PrimitiveVisual::FormSphereTriangles( Vector<unsigned short>& indices, int slices, int stacks )
{
if( stacks <= 1 )
{
}
}
-void PrimitiveRenderer::ComputeConicVertices( Vector<Vertex>& vertices, float scaleTopRadius,
+void PrimitiveVisual::ComputeConicVertices( Vector<Vertex>& vertices, float scaleTopRadius,
float scaleBottomRadius, float scaleHeight, int slices )
{
int vertexIndex = 0; //Track progress through vertices.
vertexIndex++;
}
-void PrimitiveRenderer::FormConicTriangles( Vector<unsigned short>& indices, float scaleTopRadius,
+void PrimitiveVisual::FormConicTriangles( Vector<unsigned short>& indices, float scaleTopRadius,
float scaleBottomRadius, int slices )
{
int indiceIndex = 0; //Track progress through indices.
}
}
-void PrimitiveRenderer::ComputeCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions )
+void PrimitiveVisual::ComputeCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions )
{
int numVertices = 4 * 6; //Four per face.
int vertexIndex = 0; //Tracks progress through vertices.
}
-void PrimitiveRenderer::FormCubeTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormCubeTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 12;
int triangleIndex = 0; //Track progress through indices.
indices[triangleIndex + 5] = 20;
}
-void PrimitiveRenderer::ComputeOctahedronVertices( Vector<Vertex>& vertices, Vector3 dimensions, float smoothness )
+void PrimitiveVisual::ComputeOctahedronVertices( Vector<Vertex>& vertices, Vector3 dimensions, float smoothness )
{
int numVertices = 3 * 8; //Three per face
int vertexIndex = 0; //Tracks progress through vertices.
}
}
-void PrimitiveRenderer::FormOctahedronTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormOctahedronTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 8;
int numIndices = numTriangles * 3;
}
}
-void PrimitiveRenderer::ComputeBevelledCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions,
+void PrimitiveVisual::ComputeBevelledCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions,
float bevelPercentage, float bevelSmoothness )
{
int numPositions = 24;
normalIndex++;
}
-void PrimitiveRenderer::FormBevelledCubeTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormBevelledCubeTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 44; //(Going from top to bottom, that's 2 + 12 + 16 + 12 + 2)
int indiceIndex = 0; //Track progress through indices.