OSDN Git Service

just use an object for the raster pool and struct
authorIvailo Monev <xakepa10@laimg.moc>
Sat, 24 Sep 2016 23:48:09 +0000 (23:48 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sat, 24 Sep 2016 23:48:09 +0000 (23:48 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/painting/qgrayraster.c
src/gui/painting/qpaintengine_raster.cpp
src/gui/painting/qpaintengine_raster_p.h
src/gui/painting/qrasterdefs_p.h

index 1436dab..b57418e 100644 (file)
 
 #define QT_FT_UINT_MAX  UINT_MAX
 
-#define qt_ft_memset   memset
 #define qt_ft_setjmp   setjmp
 #define qt_ft_longjmp  longjmp
 #define qt_ft_jmp_buf  jmp_buf
 
   /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
   /****                         a static object.                  *****/
+  static TRaster raster;
+  static char raster_pool[RASTER_POOL_SIZE];
 
-  int gray_raster_new( QT_FT_Raster*  araster )
+  void gray_raster_reset( )
   {
-    *araster = malloc(sizeof(TRaster));
-    if (!*araster) {
-        *araster = 0;
-        return ErrRaster_Memory_Overflow;
-    }
-    qt_ft_memset(*araster, 0, sizeof(TRaster));
-
-    return 0;
-  }
-
-
-  void gray_raster_reset( QT_FT_Raster  raster, char* pool_base )
-  {
-    PRaster  rast = (PRaster)raster;
-    if ( raster && pool_base )
-    {
-      rast->worker      = (PWorker)pool_base;
-      rast->buffer      = pool_base +
-                            ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) &
-                            ~( sizeof ( TCell ) - 1 ) );
-      rast->buffer_size = ( ( pool_base + RASTER_POOL_SIZE ) -
-                            rast->buffer ) & ~( sizeof ( TCell ) - 1 );
-      rast->band_size   = rast->buffer_size / ( sizeof ( TCell ) * 8 );
-    }
-    else
-    {
-      rast->buffer      = NULL;
-      rast->buffer_size = 0;
-      rast->worker      = NULL;
-    }
+    raster.worker      = (PWorker)raster_pool;
+    raster.buffer      = raster_pool +
+                          ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) &
+                          ~( sizeof ( TCell ) - 1 ) );
+    raster.buffer_size = ( ( raster_pool + RASTER_POOL_SIZE ) -
+                          raster.buffer ) & ~( sizeof ( TCell ) - 1 );
+    raster.band_size   = raster.buffer_size / ( sizeof ( TCell ) * 8 );
   }
 
-  int gray_raster_render( QT_FT_Raster                  raster,
-                      const QT_FT_Raster_Params*  params )
+  int gray_raster_render( const QT_FT_Raster_Params*  params )
   {
     const QT_FT_Outline*  outline    = (const QT_FT_Outline*)params->source;
     PWorker            worker;
 
 
-    if ( !raster || !raster->buffer || !raster->buffer_size )
+    if ( !raster.buffer || !raster.buffer_size )
       return ErrRaster_Invalid_Argument;
 
-    if ( raster->worker )
-      raster->worker->skip_spans = params->skip_spans;
+    if ( raster.worker )
+      raster.worker->skip_spans = params->skip_spans;
 
     /* return immediately if the outline is empty */
     if ( !outline || outline->n_points == 0 || outline->n_contours <= 0 )
            outline->contours[outline->n_contours - 1] + 1 )
       return ErrRaster_Invalid_Outline;
 
-    worker = raster->worker;
+    worker = raster.worker;
 
     /* compute clipping box */
     ras.clip_box = params->clip_box;
 
     /* initialize the cells table */
-    ras.buffer      = raster->buffer;
-    ras.buffer_size = raster->buffer_size;
+    ras.buffer      = raster.buffer;
+    ras.buffer_size = raster.buffer_size;
 
-    ras.ycells      = (PCell*) raster->buffer;
+    ras.ycells      = (PCell*) raster.buffer;
     ras.cells       = NULL;
     ras.max_cells   = 0;
     ras.num_cells   = 0;
     ras.invalid     = 1;
 
     ras.outline   = *outline;
-    ras.band_size = raster->band_size;
+    ras.band_size = raster.band_size;
 
     ras.render_span      = (QT_FT_SpanFunc)params->gray_spans;
     ras.render_span_data = params->user;
index 61e0b9c..76b87c0 100644 (file)
@@ -167,18 +167,6 @@ static void qt_ft_outline_cubic_to(qfixed c1x, qfixed c1y,
 QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() :
     QPaintEngineExPrivate()
 {
-    // The antialiasing raster.
-    grayRaster = new QT_FT_Raster;
-    Q_CHECK_PTR(grayRaster);
-    if (gray_raster_new(grayRaster)) {
-        // an error creating the raster is caused by a bad malloc
-        QT_THROW(std::bad_alloc());
-    }
-}
-
-QRasterPaintEnginePrivate::~QRasterPaintEnginePrivate()
-{
-    free(grayRaster);
 }
 
 /*!
@@ -3080,8 +3068,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
         return;
     }
 
-    char pool_base[RASTER_POOL_SIZE];
-    gray_raster_reset(*grayRaster, pool_base);
+    gray_raster_reset();
 
     QT_FT_BBox clip_box = { deviceRect.x(),
                             deviceRect.y(),
@@ -3095,7 +3082,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
     rasterParams.clip_box = clip_box;
     rasterParams.gray_spans = callback;
     rasterParams.skip_spans = 0;
-    gray_raster_render(*grayRaster, &rasterParams);
+    gray_raster_render(&rasterParams);
 }
 
 QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
index ab78486..58e5381 100644 (file)
@@ -266,7 +266,6 @@ class QRasterPaintEnginePrivate : public QPaintEngineExPrivate
     Q_DECLARE_PUBLIC(QRasterPaintEngine)
 public:
     QRasterPaintEnginePrivate();
-    ~QRasterPaintEnginePrivate();
 
     void rasterizeLine_dashed(QLineF line, qreal width,
                               int *dashIndex, qreal *dashOffset, bool *inDash);
@@ -308,8 +307,6 @@ public:
     QStroker basicStroker;
     QScopedPointer<QDashStroker> dashStroker;
 
-    QT_FT_Raster* grayRaster;
-
     QSpanData image_filler;
     QSpanData image_filler_xform;
     QSpanData solid_color_filler;
index 68e8e58..dc6d041 100644 (file)
@@ -423,26 +423,6 @@ QT_FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Func>                                                                */
-  /*    gray_raster_new                                                    */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    A function used to create a new raster object.                     */
-  /*                                                                       */
-  /* <Output>                                                              */
-  /*    raster :: A handle to the new raster object.                       */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    Error code.  0 means success.                                      */
-  /*                                                                       */
-#ifdef __cplusplus
-  extern "C"
-#endif
-  int gray_raster_new( QT_FT_Raster*  raster );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Func>                                                                */
   /*    gray_raster_reset                                                  */
   /*                                                                       */
   /* <Description>                                                         */
@@ -454,11 +434,6 @@ QT_FT_BEGIN_HEADER
   /*    This function is called each time the render pool changes, or just */
   /*    after a new raster object is created.                              */
   /*                                                                       */
-  /* <Input>                                                               */
-  /*    raster    :: A handle to the new raster object.                    */
-  /*                                                                       */
-  /*    pool_base :: The address in memory of the render pool.             */
-  /*                                                                       */
   /* <Note>                                                                */
   /*    Rasters can ignore the render pool and rely on dynamic memory      */
   /*    allocation if they want to (a handle to the memory allocator is    */
@@ -468,7 +443,7 @@ QT_FT_BEGIN_HEADER
 #ifdef __cplusplus
   extern "C"
 #endif
-  void gray_raster_reset( QT_FT_Raster       raster, char*  pool);
+  void gray_raster_reset( );
 
 
   /*************************************************************************/
@@ -508,8 +483,7 @@ QT_FT_BEGIN_HEADER
 #ifdef __cplusplus
   extern "C"
 #endif
-  int gray_raster_render( QT_FT_Raster          raster,
-                           const QT_FT_Raster_Params*  params );
+  int gray_raster_render( const QT_FT_Raster_Params*  params );
 
   /*************************************************************************/
   /*                                                                       */