Updates following rename of PropertyBuffer to VertexBuffer
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / vector-based / vector-based-renderer.cpp
index 82bf555..d7b245d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 #include <dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.h>
 
 // EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/geometry.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/public-api/rendering/renderer.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/glyph-run.h>
@@ -64,7 +64,7 @@ void AddVertex( Vector<Vertex2D>& vertices, float x, float y, float u, float v,
   vertices.PushBack( meshVertex );
 }
 
-void AddTriangle( Vector<unsigned int>& indices, unsigned int v0, unsigned int v1, unsigned int v2 )
+void AddTriangle( Vector<unsigned short>& indices, unsigned int v0, unsigned int v1, unsigned int v2 )
 {
   indices.PushBack( v0 );
   indices.PushBack( v1 );
@@ -79,7 +79,7 @@ bool CreateGeometry( const Vector<GlyphInfo>& glyphs,
                      VectorBlobAtlas& atlas,
                      Dali::TextAbstraction::FontClient& fontClient,
                      Vector< Vertex2D >& vertices,
-                     Vector< unsigned int >& indices,
+                     Vector< unsigned short >& indices,
                      const Vector4* const colorsBuffer,
                      const ColorIndex* const colorIndicesBuffer,
                      const Vector4& defaultColor )
@@ -161,7 +161,6 @@ struct VectorBasedRenderer::Impl
     mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
     mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
     mQuadVertexFormat[ "aColor" ] = Property::VECTOR4;
-    mQuadIndexFormat[ "indices" ] = Property::INTEGER;
   }
 
   Actor mActor;                            ///< The actor parent which renders the text
@@ -169,7 +168,6 @@ struct VectorBasedRenderer::Impl
   TextAbstraction::FontClient mFontClient; ///> The font client used to supply glyph information
 
   Property::Map mQuadVertexFormat;         ///> Describes the vertex format for text
-  Property::Map mQuadIndexFormat;          ///> Describes the index format for text
 
   Shader mShaderEffect;
 
@@ -183,16 +181,20 @@ Text::RendererPtr VectorBasedRenderer::New()
   return Text::RendererPtr( new VectorBasedRenderer() );
 }
 
-Actor VectorBasedRenderer::Render( Text::ViewInterface& view, int /*depth*/ )
+Actor VectorBasedRenderer::Render( Text::ViewInterface& view,
+                                   Actor textControl,
+                                   Property::Index animatablePropertyIndex,
+                                   float& alignmentOffset,
+                                   int /*depth*/ )
 {
   UnparentAndReset( mImpl->mActor );
 
   mImpl->mActor = Actor::New();
-  mImpl->mActor.SetParentOrigin( ParentOrigin::CENTER );
-  mImpl->mActor.SetSize( view.GetControlSize() );
-  mImpl->mActor.SetColor( Color::WHITE );
+  mImpl->mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+  mImpl->mActor.SetProperty( Actor::Property::SIZE, Vector2( view.GetControlSize() ) );
+  mImpl->mActor.SetProperty( Actor::Property::COLOR, Color::WHITE );
 #if defined(DEBUG_ENABLED)
-  mImpl->mActor.SetName( "Text renderable actor" );
+  mImpl->mActor.SetProperty( Dali::Actor::Property::NAME, "Text renderable actor" );
 #endif
 
   Length numberOfGlyphs = view.GetNumberOfGlyphs();
@@ -207,8 +209,10 @@ Actor VectorBasedRenderer::Render( Text::ViewInterface& view, int /*depth*/ )
 
     numberOfGlyphs = view.GetGlyphs( glyphs.Begin(),
                                      positions.Begin(),
+                                     alignmentOffset,
                                      0u,
                                      numberOfGlyphs );
+
     glyphs.Resize( numberOfGlyphs );
     positions.Resize( numberOfGlyphs );
 
@@ -217,10 +221,10 @@ Actor VectorBasedRenderer::Render( Text::ViewInterface& view, int /*depth*/ )
     const Vector4& defaultColor = view.GetTextColor();
 
     Vector< Vertex2D > vertices;
-    Vector< unsigned int > indices;
+    Vector< unsigned short > indices;
 
     const Vector2& controlSize = view.GetControlSize();
-    float xOffset = controlSize.width  * -0.5f;
+    float xOffset = -alignmentOffset + controlSize.width * -0.5f;
     float yOffset = controlSize.height * -0.5f;
 
     if( ! mImpl->mAtlas ||
@@ -271,15 +275,14 @@ Actor VectorBasedRenderer::Render( Text::ViewInterface& view, int /*depth*/ )
 
     if( 0 != vertices.Count() )
     {
-      PropertyBuffer quadVertices = PropertyBuffer::New( mImpl->mQuadVertexFormat );
-      PropertyBuffer quadIndices = PropertyBuffer::New( mImpl->mQuadIndexFormat );
+      VertexBuffer quadVertices = VertexBuffer::New( mImpl->mQuadVertexFormat );
 
       quadVertices.SetData( &vertices[ 0 ], vertices.Size() );
-      quadIndices.SetData( &indices[ 0 ], indices.Size() );
+
 
       Geometry quadGeometry = Geometry::New();
       quadGeometry.AddVertexBuffer( quadVertices );
-      quadGeometry.SetIndexBuffer( quadIndices );
+      quadGeometry.SetIndexBuffer( &indices[ 0 ], indices.Size() );
 
       TextureSet texture = mImpl->mAtlas->GetTextureSet();
 
@@ -304,4 +307,3 @@ VectorBasedRenderer::~VectorBasedRenderer()
 {
   delete mImpl;
 }
-