summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubhransu Mohanty <sub.mohanty@samsung.com>2015-08-17 13:13:38 +0900
committerCedric BAIL <cedric@osg.samsung.com>2015-08-19 14:56:11 +0200
commit146f3c52b50cde7d356e904858ac9aad7fa6710a (patch)
tree1c6ae22ceb7d601d8f9a861f6e49b306eb7888da
parentad3ae08b82d3b53467f44261c61957fefc24f9d7 (diff)
ector: now software rasterizer allocates memory on stack to work in multi threading env.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/ector/software/ector_software_rasterizer.c5
-rw-r--r--src/lib/ector/software/sw_ft_raster.c59
2 files changed, 17 insertions, 47 deletions
diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c
index d98a8dc54a..47a0cae07d 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -304,14 +304,10 @@ _adjust_span_fill_methods(Span_Data *spdata)
304 } 304 }
305} 305}
306 306
307
308
309void ector_software_rasterizer_init(Software_Rasterizer *rasterizer) 307void ector_software_rasterizer_init(Software_Rasterizer *rasterizer)
310{ 308{
311 // initialize the rasterizer and stroker 309 // initialize the rasterizer and stroker
312 unsigned char* renderPool = (unsigned char*) malloc(1024 * 100);
313 sw_ft_grays_raster.raster_new(&rasterizer->raster); 310 sw_ft_grays_raster.raster_new(&rasterizer->raster);
314 sw_ft_grays_raster.raster_reset(rasterizer->raster, renderPool, 1024*100);
315 311
316 SW_FT_Stroker_New(&rasterizer->stroker); 312 SW_FT_Stroker_New(&rasterizer->stroker);
317 SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0); 313 SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0);
@@ -327,7 +323,6 @@ void ector_software_rasterizer_done(Software_Rasterizer *rasterizer)
327{ 323{
328 sw_ft_grays_raster.raster_done(rasterizer->raster); 324 sw_ft_grays_raster.raster_done(rasterizer->raster);
329 SW_FT_Stroker_Done(rasterizer->stroker); 325 SW_FT_Stroker_Done(rasterizer->stroker);
330 //TODO free the pool memory
331} 326}
332 327
333 328
diff --git a/src/lib/ector/software/sw_ft_raster.c b/src/lib/ector/software/sw_ft_raster.c
index f20a881d1e..38b85392d4 100644
--- a/src/lib/ector/software/sw_ft_raster.c
+++ b/src/lib/ector/software/sw_ft_raster.c
@@ -104,7 +104,9 @@ typedef ptrdiff_t SW_FT_PtrDist;
104#define SW_FT_ERROR( x ) do { } while ( 0 ) /* nothing */ 104#define SW_FT_ERROR( x ) do { } while ( 0 ) /* nothing */
105#define SW_FT_THROW( e ) SW_FT_ERR_CAT( ErrRaster_, e ) 105#define SW_FT_THROW( e ) SW_FT_ERR_CAT( ErrRaster_, e )
106 106
107 107 /* The size in bytes of the render pool used by the scan-line converter */
108 /* to do all of its work. */
109#define SW_FT_RENDER_POOL_SIZE 16384L
108 110
109typedef int 111typedef int
110(*SW_FT_Outline_MoveToFunc)( const SW_FT_Vector* to, 112(*SW_FT_Outline_MoveToFunc)( const SW_FT_Vector* to,
@@ -383,11 +385,7 @@ typedef struct SW_FT_Outline_Funcs_
383 385
384 typedef struct gray_TRaster_ 386 typedef struct gray_TRaster_
385 { 387 {
386 void* buffer;
387 long buffer_size;
388 int band_size;
389 void* memory; 388 void* memory;
390 gray_PWorker worker;
391 389
392 } gray_TRaster, *gray_PRaster; 390 } gray_TRaster, *gray_PRaster;
393 391
@@ -1719,16 +1717,20 @@ typedef struct SW_FT_Outline_Funcs_
1719 return 0; 1717 return 0;
1720 } 1718 }
1721 1719
1722
1723 static int 1720 static int
1724 gray_raster_render( gray_PRaster raster, 1721 gray_raster_render( gray_PRaster raster,
1725 const SW_FT_Raster_Params* params ) 1722 const SW_FT_Raster_Params* params )
1726 { 1723 {
1727 const SW_FT_Outline* outline = (const SW_FT_Outline*)params->source; 1724 const SW_FT_Outline* outline = (const SW_FT_Outline*)params->source;
1728 gray_PWorker worker;
1729 1725
1726 gray_TWorker worker[1];
1730 1727
1731 if ( !raster || !raster->buffer || !raster->buffer_size ) 1728 TCell buffer[SW_FT_RENDER_POOL_SIZE / sizeof ( TCell )];
1729 long buffer_size = sizeof ( buffer );
1730 int band_size = (int)( buffer_size /
1731 (long)( sizeof ( TCell ) * 8 ) );
1732
1733 if ( !raster)
1732 return SW_FT_THROW( Invalid_Argument ); 1734 return SW_FT_THROW( Invalid_Argument );
1733 1735
1734 if ( !outline ) 1736 if ( !outline )
@@ -1745,8 +1747,6 @@ typedef struct SW_FT_Outline_Funcs_
1745 outline->contours[outline->n_contours - 1] + 1 ) 1747 outline->contours[outline->n_contours - 1] + 1 )
1746 return SW_FT_THROW( Invalid_Outline ); 1748 return SW_FT_THROW( Invalid_Outline );
1747 1749
1748 worker = raster->worker;
1749
1750 /* this version does not support monochrome rendering */ 1750 /* this version does not support monochrome rendering */
1751 if ( !( params->flags & SW_FT_RASTER_FLAG_AA ) ) 1751 if ( !( params->flags & SW_FT_RASTER_FLAG_AA ) )
1752 return SW_FT_THROW( Invalid_Mode ); 1752 return SW_FT_THROW( Invalid_Mode );
@@ -1761,13 +1761,14 @@ typedef struct SW_FT_Outline_Funcs_
1761 ras.clip_box.yMax = 32767L; 1761 ras.clip_box.yMax = 32767L;
1762 } 1762 }
1763 1763
1764 gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size ); 1764 gray_init_cells( RAS_VAR_ buffer, buffer_size );
1765 1765
1766 ras.outline = *outline; 1766 ras.outline = *outline;
1767 ras.num_cells = 0; 1767 ras.num_cells = 0;
1768 ras.invalid = 1; 1768 ras.invalid = 1;
1769 ras.band_size = raster->band_size; 1769 ras.band_size = band_size;
1770 ras.num_gray_spans = 0; 1770 ras.num_gray_spans = 0;
1771 ras.span_y = 0;
1771 1772
1772 ras.render_span = (SW_FT_Raster_Span_Func)params->gray_spans; 1773 ras.render_span = (SW_FT_Raster_Span_Func)params->gray_spans;
1773 ras.render_span_data = params->user; 1774 ras.render_span_data = params->user;
@@ -1775,7 +1776,6 @@ typedef struct SW_FT_Outline_Funcs_
1775 return gray_convert_glyph( RAS_VAR ); 1776 return gray_convert_glyph( RAS_VAR );
1776 } 1777 }
1777 1778
1778
1779 /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/ 1779 /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
1780 /**** a static object. *****/ 1780 /**** a static object. *****/
1781 1781
@@ -1803,34 +1803,9 @@ typedef struct SW_FT_Outline_Funcs_
1803 char* pool_base, 1803 char* pool_base,
1804 long pool_size ) 1804 long pool_size )
1805 { 1805 {
1806 gray_PRaster rast = (gray_PRaster)raster; 1806 SW_FT_UNUSED( raster );
1807 1807 SW_FT_UNUSED( pool_base );
1808 1808 SW_FT_UNUSED( pool_size );
1809 if ( raster )
1810 {
1811 if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 )
1812 {
1813 gray_PWorker worker = (gray_PWorker)pool_base;
1814
1815
1816 rast->worker = worker;
1817 rast->buffer = pool_base +
1818 ( ( sizeof ( gray_TWorker ) +
1819 sizeof ( TCell ) - 1 ) &
1820 ~( sizeof ( TCell ) - 1 ) );
1821 rast->buffer_size = (long)( ( pool_base + pool_size ) -
1822 (char*)rast->buffer ) &
1823 ~( sizeof ( TCell ) - 1 );
1824 rast->band_size = (int)( rast->buffer_size /
1825 ( sizeof ( TCell ) * 8 ) );
1826 }
1827 else
1828 {
1829 rast->buffer = NULL;
1830 rast->buffer_size = 0;
1831 rast->worker = NULL;
1832 }
1833 }
1834 } 1809 }
1835 1810
1836 1811