From ad5116d49668a2b4a483352ad7ce45433cca78bd Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Thu, 7 Jul 2016 11:28:46 +0100 Subject: [PATCH] Modified font-client to generate PixelData objects instead of BufferImage Change-Id: I0178d645da49b0f7d599ec1e859fe30f3f0e86cb --- .../text-abstraction/font-client.cpp | 2 +- .../devel-api/text-abstraction/font-client.h | 3 +- .../text-abstraction/font-client-impl.cpp | 2 +- .../text-abstraction/font-client-impl.h | 2 +- .../font-client-plugin-impl.cpp | 38 ++++++------------- .../font-client-plugin-impl.h | 4 +- 6 files changed, 19 insertions(+), 32 deletions(-) diff --git a/text/dali/devel-api/text-abstraction/font-client.cpp b/text/dali/devel-api/text-abstraction/font-client.cpp index e805fb421..048a6f291 100644 --- a/text/dali/devel-api/text-abstraction/font-client.cpp +++ b/text/dali/devel-api/text-abstraction/font-client.cpp @@ -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 ); } diff --git a/text/dali/devel-api/text-abstraction/font-client.h b/text/dali/devel-api/text-abstraction/font-client.h index 56e9245dd..fc9442b19 100644 --- a/text/dali/devel-api/text-abstraction/font-client.h +++ b/text/dali/devel-api/text-abstraction/font-client.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -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. diff --git a/text/dali/internal/text-abstraction/font-client-impl.cpp b/text/dali/internal/text-abstraction/font-client-impl.cpp index 94d8bd361..42a2a8ad0 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.cpp +++ b/text/dali/internal/text-abstraction/font-client-impl.cpp @@ -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(); diff --git a/text/dali/internal/text-abstraction/font-client-impl.h b/text/dali/internal/text-abstraction/font-client-impl.h index 8d51498c5..783147ccc 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.h +++ b/text/dali/internal/text-abstraction/font-client-impl.h @@ -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() diff --git a/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp b/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp index d24f671b1..feaec0546 100644 --- a/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp +++ b/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp @@ -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; } diff --git a/text/dali/internal/text-abstraction/font-client-plugin-impl.h b/text/dali/internal/text-abstraction/font-client-plugin-impl.h index 517a265d3..4f191a660 100644 --- a/text/dali/internal/text-abstraction/font-client-plugin-impl.h +++ b/text/dali/internal/text-abstraction/font-client-plugin-impl.h @@ -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. -- 2.34.1