Modified font-client to generate PixelData objects instead of BufferImage 21/78921/2
authorFerran Sole <ferran.sole@samsung.com>
Thu, 7 Jul 2016 10:28:46 +0000 (11:28 +0100)
committerFerran Sole <ferran.sole@samsung.com>
Fri, 8 Jul 2016 13:00:30 +0000 (06:00 -0700)
Change-Id: I0178d645da49b0f7d599ec1e859fe30f3f0e86cb

text/dali/devel-api/text-abstraction/font-client.cpp
text/dali/devel-api/text-abstraction/font-client.h
text/dali/internal/text-abstraction/font-client-impl.cpp
text/dali/internal/text-abstraction/font-client-impl.h
text/dali/internal/text-abstraction/font-client-plugin-impl.cpp
text/dali/internal/text-abstraction/font-client-plugin-impl.h

index e805fb421c24340d91b486413df0d3b6d4213c0c..048a6f2918456739e80113a1847ef09b0f9683c0 100644 (file)
@@ -153,7 +153,7 @@ bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType typ
   return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal );
 }
 
-BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
+PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
 {
   return GetImplementation(*this).CreateBitmap( fontId, glyphIndex );
 }
index 56e9245ddd16482ffe4f1bb0f90cab76c9228b14..fc9442b195e29b859f01547e90f6f50c1d08b978 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/images/buffer-image.h>
+#include <dali/devel-api/images/pixel-data.h>
 #include <dali/public-api/object/base-handle.h>
 #include <dali/devel-api/text-abstraction/font-list.h>
 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
@@ -302,7 +303,7 @@ public:
    * @param[in] glyphIndex The index of a glyph within the specified font.
    * @return A valid BufferImage, or an empty handle if the glyph could not be rendered.
    */
-  BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+  PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
 
   /**
    * @brief Create a vector representation of a glyph.
index 94d8bd361a2bc9a5f62850f656a8a61e25363cd0..42a2a8ad03db07d1f4991b9ca5aae7ad1d945c2b 100644 (file)
@@ -214,7 +214,7 @@ bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType typ
   return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
 }
 
-BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
+PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
 {
   CreatePlugin();
 
index 8d51498c5ddab9f416f9b91024ccec6271fbcde2..783147cccab1d46f731af3df7ed50377899690ca 100644 (file)
@@ -156,7 +156,7 @@ public:
   /**
    * @copydoc Dali::FontClient::CreateBitmap()
    */
-  BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+  PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
 
   /**
    * @copydoc Dali::FontClient::CreateVectorBlob()
index d24f671b1e1b9b621b0017ef3224451240490cff..feaec05466ba5e765481f6672bbd7251027aceee 100644 (file)
@@ -459,7 +459,7 @@ FontId FontClient::Plugin::FindFontForCharacter( const FontList& fontList,
 
       if( preferColor )
       {
-        BufferImage bitmap = CreateBitmap( fontId, GetGlyphIndex(fontId,charcode) );
+        PixelData bitmap = CreateBitmap( fontId, GetGlyphIndex(fontId,charcode) );
         if( bitmap &&
             Pixel::BGRA8888 == bitmap.GetPixelFormat() )
         {
@@ -871,10 +871,10 @@ bool FontClient::Plugin::GetVectorMetrics( GlyphInfo* array,
 #endif
 }
 
-BufferImage FontClient::Plugin::CreateBitmap( FontId fontId,
+PixelData FontClient::Plugin::CreateBitmap( FontId fontId,
                                               GlyphIndex glyphIndex )
 {
-  BufferImage bitmap;
+  PixelData bitmap;
 
   if( fontId > 0 &&
       fontId-1 < mFontCache.size() )
@@ -1264,7 +1264,7 @@ FontId FontClient::Plugin::CreateFont( const FontPath& path,
   return id;
 }
 
-void FontClient::Plugin::ConvertBitmap( BufferImage& destBitmap,
+void FontClient::Plugin::ConvertBitmap( PixelData& destBitmap,
                                         FT_Bitmap srcBitmap )
 {
   if( srcBitmap.width*srcBitmap.rows > 0 )
@@ -1275,17 +1275,10 @@ void FontClient::Plugin::ConvertBitmap( BufferImage& destBitmap,
       {
         if( srcBitmap.pitch == static_cast< int >( srcBitmap.width ) )
         {
-          destBitmap = BufferImage::New( srcBitmap.width, srcBitmap.rows, Pixel::L8 );
-
-          PixelBuffer* destBuffer = destBitmap.GetBuffer();
-          if( destBuffer )
-          {
-            memcpy( destBuffer, srcBitmap.buffer, srcBitmap.width*srcBitmap.rows );
-          }
-          else
-          {
-            DALI_LOG_ERROR( "GetBuffer returns null\n" );
-          }
+          unsigned int bufferSize( srcBitmap.width * srcBitmap.rows );
+          unsigned char* buffer = new unsigned char[bufferSize];
+          memcpy( buffer, srcBitmap.buffer,bufferSize );
+          destBitmap = PixelData::New( buffer, bufferSize, srcBitmap.width, srcBitmap.rows, Pixel::L8, PixelData::DELETE_ARRAY );
         }
         break;
       }
@@ -1295,17 +1288,10 @@ void FontClient::Plugin::ConvertBitmap( BufferImage& destBitmap,
       {
         if ( srcBitmap.pitch == static_cast< int >( srcBitmap.width << 2 ) )
         {
-          destBitmap = BufferImage::New( srcBitmap.width, srcBitmap.rows, Pixel::BGRA8888 );
-
-          PixelBuffer* destBuffer = destBitmap.GetBuffer();
-          if( destBuffer )
-          {
-            memcpy( destBuffer, srcBitmap.buffer, srcBitmap.width*srcBitmap.rows*4 );
-          }
-          else
-          {
-            DALI_LOG_ERROR( "GetBuffer returns null\n" );
-          }
+          unsigned int bufferSize( srcBitmap.width * srcBitmap.rows * 4 );
+          unsigned char* buffer = new unsigned char[bufferSize];
+          memcpy( buffer, srcBitmap.buffer,bufferSize );
+          destBitmap = PixelData::New( buffer, bufferSize, srcBitmap.width, srcBitmap.rows, Pixel::BGRA8888, PixelData::DELETE_ARRAY );
         }
         break;
       }
index 517a265d3750b1ead44244645ea81ecccb33af2c..4f191a660fe6db7a41ff7f82a7cdc2c339f700d8 100644 (file)
@@ -275,7 +275,7 @@ struct FontClient::Plugin
   /**
    * @copydoc Dali::FontClient::CreateBitmap()
    */
-  BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+  PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
 
   /**
    * @copydoc Dali::FontClient::CreateVectorBlob()
@@ -364,7 +364,7 @@ private:
    * @param[in] destBitmap
    * @param[in] srcBitmap
    */
-  void ConvertBitmap( BufferImage& destBitmap, FT_Bitmap srcBitmap );
+  void ConvertBitmap( PixelData& destBitmap, FT_Bitmap srcBitmap );
 
   /**
    * @brief Finds in the cache if there is a triplet with the path to the font file name, the font point size and the face index.