(VectorBlobAtlas) Use Texture instead of BufferImage 84/235784/5
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 9 Jun 2020 19:01:40 +0000 (20:01 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 10 Jun 2020 16:30:27 +0000 (17:30 +0100)
Change-Id: Iee2f187789282c59503c5eaeec8c062e1ce3a375

build/tizen/CMakeLists.txt
dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.cpp
dali-toolkit/internal/text/rendering/vector-based/vector-blob-atlas.cpp
dali-toolkit/internal/text/rendering/vector-based/vector-blob-atlas.h

index d02db0b..808b36b 100644 (file)
@@ -152,11 +152,6 @@ IF( ENABLE_TRACE )
   ADD_DEFINITIONS("-DTRACE_ENABLED")
 ENDIF()
 
-# Platforms with highp shader support can use vector based text
-IF( "${PROFILE}" STREQUAL "UBUNTU" )
-  SET( ENABLE_VECTOR_BASED_TEXT_RENDERING 1 )
-ENDIF()
-
 # Set paths
 SET( toolkit_images_dir  ${ROOT_SRC_DIR}/dali-toolkit/styles/images-common )
 SET( toolkit_sounds_dir  ${ROOT_SRC_DIR}/dali-toolkit/sounds )
@@ -255,6 +250,11 @@ INCLUDE( ${ROOT_SRC_DIR}/dali-toolkit/devel-api/file.list )
 INCLUDE( ${ROOT_SRC_DIR}/dali-toolkit/third-party/file.list )
 INCLUDE( ${ROOT_SRC_DIR}/doc/file.list )
 
+# Platforms with highp shader support can use vector based text
+IF( ENABLE_VECTOR_BASED_TEXT_RENDERING )
+  INCLUDE( ${ROOT_SRC_DIR}/dali-toolkit/internal/text/rendering/vector-based/file.list )
+ENDIF()
+
 SET(LIBTYPE SHARED)
 IF(DEFINED STATIC)
   SET(LIBTYPE STATIC)
index 1d56ef5..4718b11 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.
@@ -191,7 +191,7 @@ Actor VectorBasedRenderer::Render( Text::ViewInterface& view,
 
   mImpl->mActor = Actor::New();
   mImpl->mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
-  mImpl->mActor.SetProperty( Actor::Property::SIZE, Vector2( view.GetControlSize() );
+  mImpl->mActor.SetProperty( Actor::Property::SIZE, Vector2( view.GetControlSize() ) );
   mImpl->mActor.SetProperty( Actor::Property::COLOR, Color::WHITE );
 #if defined(DEBUG_ENABLED)
   mImpl->mActor.SetProperty( Dali::Actor::Property::NAME, "Text renderable actor" );
index d9c0a7c..b17400c 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.
@@ -19,7 +19,6 @@
 #include <dali-toolkit/internal/text/rendering/vector-based/vector-blob-atlas.h>
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/images/texture-set-image.h>
 #include <dali/integration-api/debug.h>
 
 namespace
@@ -76,10 +75,10 @@ VectorBlobAtlas::VectorBlobAtlas( unsigned int textureWidth,
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "Blob atlas %p size %dx%d, item width %d, height quantum %d\n", this, textureWidth, textureHeight, itemWidth, itemHeightQuantum );
 
-  mAtlasTexture = BufferImage::New( textureWidth, textureHeight, Pixel::RGBA8888 );
+  mAtlasTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, textureWidth, textureHeight );
 
   mTextureSet = TextureSet::New();
-  TextureSetImage( mTextureSet, 0, mAtlasTexture );
+  mTextureSet.SetTexture(0, mAtlasTexture);
 }
 
 bool VectorBlobAtlas::IsFull() const
@@ -200,13 +199,15 @@ void VectorBlobAtlas::TexSubImage( unsigned int offsetX,
                                    unsigned int height,
                                    VectorBlob* blob )
 {
-  PixelBuffer* pixbuf = mAtlasTexture.GetBuffer();
+  const size_t size = width * height * 4;
+  uint8_t* pixbuf = new uint8_t[size];
+
   size_t pos;
   size_t dataIndex = 0;
-  for( size_t y= offsetY; y< height + offsetY; y++ )
+  for( size_t y = 0; y < height; y++ )
   {
     pos = y * mTextureWidth * 4;
-    for( size_t x = offsetX; x < width + offsetX; x++ )
+    for( size_t x = 0; x < width; x++ )
     {
       pixbuf[pos+x*4] =  0xFF & blob[dataIndex].r;
       pixbuf[pos+x*4+1] = 0xFF & blob[dataIndex].g;
@@ -216,7 +217,8 @@ void VectorBlobAtlas::TexSubImage( unsigned int offsetX,
     }
   }
 
-  mAtlasTexture.Update();
+  PixelData pixelData = PixelData::New(pixbuf, size, width, height, Pixel::RGBA8888, PixelData::DELETE_ARRAY);
+  mAtlasTexture.Upload(pixelData, 0u, 0u, offsetX, offsetY, width, height);
 }
 
 } // namespace Text
index 14af3bb..592d4e0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_VECTOR_BLOB_ATLAS_H
 
 /*
- * 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.
@@ -18,9 +18,9 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/images/buffer-image.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/rendering/shader.h>
+#include <dali/public-api/rendering/texture.h>
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
 
@@ -154,7 +154,7 @@ private:
   unsigned int mCursorX;
   unsigned int mCursorY;
 
-  BufferImage mAtlasTexture;
+  Texture mAtlasTexture;
 
   TextureSet mTextureSet;