22 #include "wx/wfstream.h" 
   25 #include "wx/strconv.h" 
   26 #include <wx/tokenzr.h> 
   33 #if wxART2D_USE_AGGDRAWER 
   40 #define pix_format agg::pix_format_rgb24
 
   42 typedef agg::pixfmt_rgb24 pixfmt;
 
   44 typedef agg::pixfmt_rgb24_pre pixfmt_pre;
 
   47 #define pixfmt_gamma agg::pixfmt_rgb24_gamma
 
   49 typedef agg::order_rgb component_order;
 
   52 #include "agg_basics.h" 
   58 #error This source file should not be compiled ! 
   62 a2dAggDrawerBase::a2dAggDrawerBase( 
int width, 
int height )
 
   68     m_fillGradientMatrix(),
 
   69     m_lineGradientMatrix(),
 
   70     m_fillGradientD1( 0.0 ),
 
   71     m_lineGradientD1( 0.0 ),
 
   72     m_fillGradientD2( 100.0 ),
 
   73     m_lineGradientD2( 100.0 ),
 
   74     m_fillGradientInterpolator( m_fillGradientMatrix ),
 
   75     m_lineGradientInterpolator( m_lineGradientMatrix ),
 
   76     m_linearGradientFunction(),
 
   77     m_radialGradientFunction(),
 
   84 a2dAggDrawerBase::a2dAggDrawerBase( 
const wxSize& size )
 
   90     m_fillGradientMatrix(),
 
   91     m_lineGradientMatrix(),
 
   92     m_fillGradientD1( 0.0 ),
 
   93     m_lineGradientD1( 0.0 ),
 
   94     m_fillGradientD2( 100.0 ),
 
   95     m_lineGradientD2( 100.0 ),
 
   96     m_fillGradientInterpolator( m_fillGradientMatrix ),
 
   97     m_lineGradientInterpolator( m_lineGradientMatrix ),
 
   98     m_linearGradientFunction(),
 
   99     m_radialGradientFunction(),
 
  106 a2dAggDrawerBase::a2dAggDrawerBase( 
const wxBitmap& bitmap )
 
  112     m_fillGradientMatrix(),
 
  113     m_lineGradientMatrix(),
 
  114     m_fillGradientD1( 0.0 ),
 
  115     m_lineGradientD1( 0.0 ),
 
  116     m_fillGradientD2( 100.0 ),
 
  117     m_lineGradientD2( 100.0 ),
 
  118     m_fillGradientInterpolator( m_fillGradientMatrix ),
 
  119     m_lineGradientInterpolator( m_lineGradientMatrix ),
 
  120     m_linearGradientFunction(),
 
  121     m_radialGradientFunction(),
 
  122     a2dDrawer2D( bitmap.GetWidth(), bitmap.GetHeight() )
 
  134     m_fillGradientMatrix(),
 
  135     m_lineGradientMatrix(),
 
  136     m_fillGradientD1( 0.0 ),
 
  137     m_lineGradientD1( 0.0 ),
 
  138     m_fillGradientD2( 100.0 ),
 
  139     m_lineGradientD2( 100.0 ),
 
  140     m_fillGradientInterpolator( m_fillGradientMatrix ),
 
  141     m_lineGradientInterpolator( m_lineGradientMatrix ),
 
  142     m_linearGradientFunction(),
 
  143     m_radialGradientFunction(),
 
  146     m_ownsBuffer = 
false;
 
  147     m_preStroke = other.m_preStroke;
 
  157 agg::trans_affine a2dAggDrawerBase::_get_agg_user_to_device_transform()
 const 
  160     return agg::trans_affine(
 
  161                rmtx( 0, 0 ), rmtx( 0, 1 ),
 
  162                rmtx( 1, 0 ), rmtx( 1, 1 ),
 
  163                rmtx( 2, 0 ), rmtx( 2, 1 ) );
 
  175     wxASSERT_MSG( 
m_beginDraw_endDraw >= 0, wxT( 
"a2dDcDrawer, unbalanced BeginDraw EndDraw" ) );
 
  179         m_deviceDC = 
new wxClientDC( 
m_display );
 
  195     wxASSERT_MSG( 
m_beginDraw_endDraw >= 0, wxT( 
"a2dDcDrawer, unbalanced BeginDraw EndDraw" ) );
 
  205 void a2dAggDrawerBase::DoSetDrawStyle( 
a2dDrawStyle drawstyle )
 
  214             m_blendMode = agg::comp_op_invert;
 
  220             m_blendMode = agg::end_of_comp_op_e;
 
  226             m_blendMode = agg::end_of_comp_op_e;
 
  232             m_blendMode = agg::comp_op_invert;
 
  238             m_blendMode = agg::end_of_comp_op_e;
 
  249             m_blendMode = agg::end_of_comp_op_e;
 
  254             m_blendMode = agg::comp_op_invert;
 
  267         m_strokewidthDev = 1;
 
  310             m_strokewidthDev = 1;
 
  312             m_join = agg::round_join;
 
  313             m_cap = agg::round_cap;
 
  319                 case wxJOIN_MITER: m_join = agg::miter_join;
 
  321                 case wxJOIN_ROUND: m_join = agg::round_join;
 
  323                 case wxJOIN_BEVEL: m_join = agg::bevel_join;
 
  325                 default: m_join = agg::round_join;
 
  329                 case wxCAP_BUTT: m_cap = agg::butt_cap;
 
  331                 case wxCAP_ROUND: m_cap = agg::round_cap;
 
  333                 case wxCAP_PROJECTING: m_cap = agg::square_cap;
 
  335                 default: m_cap = agg::round_cap;
 
  343                 m_strokewidthDev = !m_strokewidthDev ? 1 : m_strokewidthDev;
 
  350                 if ( !m_strokewidthDev )
 
  352                     m_strokewidthDev = 1;
 
  374                 m_pattern = wxImage( BDIAGONAL_HATCH_XPM );
 
  377                 m_pattern = wxImage( CROSSDIAG_HATCH_XPM );
 
  380                 m_pattern = wxImage( FDIAGONAL_HATCH_XPM );
 
  383                 m_pattern = wxImage( CROSS_HATCH_XPM );
 
  386                 m_pattern = wxImage( HORIZONTAL_HATCH_XPM );
 
  389                 m_pattern = wxImage( VERTICAL_HATCH_XPM );
 
  395             m_pattern.Replace( 0, 0, 0,
 
  400             m_pattern_rbuf.attach( m_pattern.GetData(), m_pattern.GetWidth(), m_pattern.GetHeight(), m_pattern.GetWidth() * 3 );
 
  405         bool nohatch = 
false;
 
  409                 m_pattern = wxImage( BDIAGONAL_HATCH_XPM );
 
  412                 m_pattern = wxImage( CROSSDIAG_HATCH_XPM );
 
  415                 m_pattern = wxImage( FDIAGONAL_HATCH_XPM );
 
  418                 m_pattern = wxImage( CROSS_HATCH_XPM );
 
  421                 m_pattern = wxImage( HORIZONTAL_HATCH_XPM );
 
  424                 m_pattern = wxImage( VERTICAL_HATCH_XPM );
 
  430         m_pattern.Replace( 255, 255, 255,
 
  435         m_pattern.Replace( 0, 0, 0,
 
  440         m_pattern_rbuf.attach( m_pattern.GetData(), m_pattern.GetWidth(), m_pattern.GetHeight(), m_pattern.GetWidth() * 3 );
 
  452                 static const int MASK_RED = 1;
 
  453                 static const int MASK_GREEN = 2;
 
  454                 static const int MASK_BLUE = 3;
 
  457                 m_pattern.Replace( MASK_RED, MASK_GREEN, MASK_BLUE,
 
  462                 m_pattern_rbuf.attach( m_pattern.GetData(), m_pattern.GetWidth(), m_pattern.GetHeight(), m_pattern.GetWidth() * 3 );
 
  477         double profile = 1.0;
 
  485         int startGradient = 128 - int( profile * 128.0 );
 
  486         int endGradient   = 128 + int( profile * 128.0 );
 
  487         if ( endGradient <= startGradient ) endGradient = startGradient + 1;
 
  488         double k = 1.0 / double( endGradient - startGradient );
 
  489         for ( i = 0; i < startGradient; i++ )
 
  491             m_fillGradient[i] = c1;
 
  493         for ( ; i < endGradient; i++ )
 
  495             m_fillGradient[i] = c1.gradient( c2, 
double( i - startGradient ) * k );
 
  497         for ( ; i < 256; i++ )
 
  499             m_fillGradient[i] = c2;
 
  501         double angle = atan2( y2 - y1, x2 - x1 );
 
  502         m_fillGradientMatrix.reset();
 
  503         m_fillGradientMatrix *= agg::trans_affine_rotation( angle );
 
  504         m_fillGradientMatrix *= agg::trans_affine_translation( x1, y1 );
 
  505         m_fillGradientMatrix *= _get_agg_user_to_device_transform();
 
  506         m_fillGradientMatrix.invert();
 
  507         m_fillGradientD1 = 0;
 
  508         m_fillGradientD2 = sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) );
 
  512         double profile = 1.0;
 
  522         int startGradient = 128 - int( profile * 127.0 );
 
  523         int endGradient   = 128 + int( profile * 127.0 );
 
  524         if ( endGradient <= startGradient ) endGradient = startGradient + 1;
 
  525         double k = 1.0 / double( endGradient - startGradient );
 
  526         for ( i = 0; i < startGradient; i++ )
 
  528             m_fillGradient[i] = c1;
 
  530         for ( ; i < endGradient; i++ )
 
  532             m_fillGradient[i] = c1.gradient( c2, 
double( i - startGradient ) * k );
 
  534         for ( ; i < 256; i++ )
 
  536             m_fillGradient[i] = c2;
 
  540         m_fillGradientMatrix.reset();
 
  541         m_fillGradientMatrix *= agg::trans_affine_translation( x, y );
 
  542         m_fillGradientMatrix.invert();
 
  543         m_fillGradientD1 = 0;
 
  549     unsigned int n = points->size();
 
  567     wxPoint* intCPoints = 
new wxPoint[n];
 
  569     for ( i = 0; i < n; i++ )
 
  575     m_clip = wxRegion( n, intCPoints, fillStyle );
 
  583     wxRegion* push = 
new wxRegion( m_clip );
 
  595     unsigned int n = points->size();
 
  613     wxPoint* intCPoints = 
new wxPoint[n];
 
  615     for ( i = 0; i < n; i++ )
 
  621     wxRegion add = wxRegion( n, intCPoints, fillStyle );
 
  631         totaladd.Union( add );
 
  633     if ( !m_clip.Empty() )
 
  636         switch ( clipoperation )
 
  639                 result = m_clip.Intersect( totaladd );
 
  643                 result = m_clip.Union( totaladd );
 
  647                 result = m_clip.Xor( totaladd );
 
  651                 result = m_clip.Subtract( totaladd );
 
  693     m_clip = wxRegion( minx, miny, width, height );
 
  710         m_clip = wxRegion( iminx, imaxy, imaxx - iminx, iminy - imaxy );
 
  711         m_clipboxdev = wxRect( iminx, imaxy, imaxx - iminx, iminy - imaxy );
 
  715         m_clip = wxRegion( iminx, iminy, imaxx - iminx, imaxy - iminy );
 
  716         m_clipboxdev = wxRect( iminx, iminy, imaxx - iminx, imaxy - iminy );
 
  734 int a2dAggDrawerBase::ToAggPath( 
a2dVertexArray* points, 
bool transform )
 
  736     unsigned int segments = 0;
 
  740     unsigned int count = 0;
 
  741     double x, y, lastx, lasty;
 
  743     for ( i = 0; i < points->size(); i++ )
 
  747         if ( !seg->GetArc() )
 
  758             if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  761                     m_path.move_to( x, y );
 
  763                     m_path.line_to( x, y );
 
  773             double radius, center_x, center_y, beginrad, midrad, endrad, phit;
 
  775             if ( cseg->
CalcR( *( points->Item( i ? i - 1 : 0 ) ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
 
  778                 unsigned int segments;
 
  782                 double theta = beginrad;
 
  786                 for ( step = 0; step < segments + 1; step++ )
 
  792                         x = center_x + radius * cos ( theta );
 
  793                         y = center_y + radius * sin ( theta );
 
  796                     if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  799                             m_path.move_to( x, y );
 
  801                             m_path.line_to( x, y );
 
  807                     theta = theta + dphi;
 
  822                 if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  825                         m_path.move_to( x, y );
 
  827                         m_path.line_to( x, y );
 
  839 int a2dAggDrawerBase::ToAggPath( 
const a2dVertexList* list, 
bool transform )
 
  841     unsigned int segments = 0;
 
  848     a2dVertexList::const_iterator iterprev = list->end();
 
  850     unsigned int count = 0;
 
  851     double x, y, lastx, lasty;
 
  852     iterprev = list->end();
 
  853     if ( iterprev != list->begin() )
 
  855     a2dVertexList::const_iterator iter = list->begin();
 
  856     iter = list->begin();
 
  857     while ( iter != list->end() )
 
  861         if ( !seg->GetArc() )
 
  872             if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  875                     m_path.move_to( x, y );
 
  877                     m_path.line_to( x, y );
 
  887             double radius, center_x, center_y, beginrad, midrad, endrad, phit;
 
  889             if ( cseg->
CalcR( *( *iterprev ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
 
  892                 unsigned int segments;
 
  896                 double theta = beginrad;
 
  900                 for ( step = 0; step < segments + 1; step++ )
 
  906                         x = center_x + radius * cos ( theta );
 
  907                         y = center_y + radius * sin ( theta );
 
  911                     if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  914                             m_path.move_to( x, y );
 
  916                             m_path.line_to( x, y );
 
  921                     theta = theta + dphi;
 
  936                 if( !count || fabs( x - lastx ) > 0.001  ||  fabs( y - lasty ) > 0.001 )
 
  939                         m_path.move_to( x, y );
 
  941                         m_path.line_to( x, y );
 
  954 void a2dAggDrawerBase::ShiftBufferInternal( 
int dxy, 
bool yshift, 
int bytesPerPixel )
 
  958         int pixelwidth = 
m_width * bytesPerPixel;
 
  962             unsigned char* highline = m_pdata + ( 
m_height - dxy ) * pixelwidth ;
 
  963             unsigned char* lowline = m_pdata + 
m_height * pixelwidth ;
 
  965             for ( 
int yp = 0; yp < 
m_height - dxy; yp++ )
 
  967                 highline -= pixelwidth;
 
  968                 lowline -= pixelwidth;
 
  969                 memcpy( lowline, highline, pixelwidth );
 
  972         else  if ( dxy < 0 && dxy > -
m_height )
 
  975             unsigned char* highline = m_pdata;
 
  976             unsigned char* lowline = m_pdata + dxy * pixelwidth ;
 
  978             for ( 
int yp = 0; yp < 
m_height - dxy ; yp++ )
 
  980                 memcpy( highline, lowline, pixelwidth );
 
  981                 highline += pixelwidth;
 
  982                 lowline += pixelwidth;
 
  986             wxFAIL_MSG( wxT( 
"you can only shift within height of buffer" ) );
 
  990         int pixelwidth = 
m_width * bytesPerPixel;
 
  991         if ( dxy > 0 && dxy < 
m_width )
 
  993             int subwidth = ( 
m_width - dxy ) * bytesPerPixel;
 
  994             unsigned char* low = m_pdata;
 
  995             unsigned char* high = m_pdata + dxy * bytesPerPixel;
 
  997             for ( 
int yp = 0; yp < 
m_height  ; yp++ )
 
  999                 memmove( high, low, subwidth );
 
 1004         else if ( dxy < 0 && dxy > -
m_width )
 
 1007             int subwidth = ( 
m_width - dxy ) * bytesPerPixel;
 
 1008             unsigned char* low = m_pdata;
 
 1009             unsigned char* high = m_pdata + dxy * bytesPerPixel ;
 
 1011             for ( 
int yp = 0; yp < 
m_height  ; yp++ )
 
 1013                 memmove( low, high, subwidth );
 
 1019             wxFAIL_MSG( wxT( 
"you can only shift within width of buffer" ) );
 
 1023 template< 
class PathT >
 
 1024 void a2dAggDrawerBase::_ras_add_stroked_path_xform( PathT& path, 
const 
 1025         agg::trans_affine& mtx )
 
 1036             typedef agg::conv_stroke< PathT > path_stroke_t;
 
 1037             typedef agg::conv_transform< path_stroke_t > path_stroke_trans_t;
 
 1039             path_stroke_t stroke( path );
 
 1040             path_stroke_trans_t trans_path( stroke, mtx );
 
 1041             stroke.line_join( m_join );
 
 1042             stroke.line_cap( m_cap );
 
 1044                 stroke.width( m_strokewidthDev );
 
 1046                 stroke.width( m_strokewidth );
 
 1047             m_rasterizer.reset();
 
 1048             m_rasterizer.add_path( trans_path );
 
 1052             typedef agg::conv_transform<PathT> trans_t;
 
 1053             typedef agg::conv_stroke< trans_t > path_stroke_t;
 
 1055             trans_t trans_path( path, mtx );
 
 1056             path_stroke_t stroke( trans_path );
 
 1058             stroke.line_join( m_join );
 
 1059             stroke.line_cap( m_cap );
 
 1060             stroke.width( m_strokewidthDev );
 
 1061             m_rasterizer.reset();
 
 1062             m_rasterizer.add_path( stroke );
 
 1069             typedef agg::conv_dash< PathT > path_dash_t;
 
 1070             typedef agg::conv_stroke< path_dash_t > path_dashstroked_t;
 
 1071             typedef agg::conv_transform< path_dashstroked_t > path_transdash_t;
 
 1073             path_dash_t dash_path( path );
 
 1074             path_dashstroked_t stroke( dash_path );
 
 1075             path_transdash_t trans_path( stroke, mtx );
 
 1077             double scale = m_strokewidth;
 
 1078             if ( scale < 1.0 ) scale = 1.0;
 
 1083                     dash_path.add_dash( 0.25 * scale, 1.5 * scale );
 
 1086                     dash_path.add_dash( 0.25 * scale, 1.5 * scale );
 
 1087                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1090                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1093                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1099             stroke.line_join( m_join );
 
 1100             stroke.line_cap( m_cap );
 
 1103                 stroke.width( m_strokewidth );
 
 1105                 stroke.width( m_strokewidthDev );
 
 1106             m_rasterizer.reset();
 
 1107             m_rasterizer.add_path( trans_path );
 
 1111             typedef agg::conv_transform<PathT> trans_t;
 
 1112             typedef agg::conv_dash< trans_t > path_transdash_t;
 
 1113             typedef agg::conv_stroke< path_transdash_t > path_dashstroked_t;
 
 1115             trans_t trans_path( path, mtx );
 
 1116             path_transdash_t dash_path( trans_path );
 
 1117             path_dashstroked_t stroke( dash_path );
 
 1119             double scale = m_strokewidthDev;
 
 1120             if ( scale < 1.0 ) scale = 1.0;
 
 1125                     dash_path.add_dash( 0.25 * scale, 1.5 * scale );
 
 1128                     dash_path.add_dash( 0.25 * scale, 1.5 * scale );
 
 1129                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1132                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1135                     dash_path.add_dash( 2.0 * scale, 2.0 * scale );
 
 1141             stroke.line_join( m_join );
 
 1142             stroke.line_cap( m_cap );
 
 1144             stroke.width( m_strokewidthDev );
 
 1145             m_rasterizer.reset();
 
 1146             m_rasterizer.add_path( stroke );
 
 1171 #if wxART2D_USE_FREETYPE && defined(__USE_WINAPI__) 
 1181 #else // wxART2D_USE_FREETYPE && defined(__USE_WINAPI__) 
 1183 #endif // wxART2D_USE_FREETYPE && defined(__USE_WINAPI__) 
 1191     if ( width == 0  || height == 0 )
 
 1205         agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1207         if ( fabs( radius ) <= 0.00000001 )
 
 1210             agg::conv_transform<plain_rect> tr( r, mtx );
 
 1211             m_rasterizer.reset();
 
 1212             m_rasterizer.add_path( tr );
 
 1216             agg::rounded_rect r( x, y, x + width, y + height, radius );
 
 1217             r.normalize_radius();
 
 1218             agg::conv_transform<agg::rounded_rect> tr( r, mtx );
 
 1219             m_rasterizer.reset();
 
 1220             m_rasterizer.add_path( tr );
 
 1225             RenderGradient( 
false );
 
 1229             RenderGradient( 
true );
 
 1245         if ( fabs( radius ) <= 0.00000001 )
 
 1248             agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1249             m_rasterizer.reset();
 
 1250             _ras_add_stroked_path_xform( r, mtx );
 
 1254             m_rasterizer.reset();
 
 1255             agg::rounded_rect r( x, y, x + width, y + height, radius );
 
 1256             r.normalize_radius();
 
 1257             agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1258             _ras_add_stroked_path_xform( r, mtx );
 
 1270     unsigned int segments;
 
 1276     agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1278     agg::ellipse ellipse( xc, yc, width / 2.0, height / 2.0, segments );
 
 1280     agg::conv_transform<agg::ellipse> tr( ellipse, mtx );
 
 1284         m_path.remove_all();
 
 1285         m_path.concat_path( tr, 0 );
 
 1287         m_rasterizer.reset();
 
 1288         m_rasterizer.add_path( m_path );
 
 1292             RenderGradient( 
false );
 
 1296             RenderGradient( 
true );
 
 1309         m_rasterizer.reset();
 
 1310         _ras_add_stroked_path_xform( ellipse, mtx );
 
 1324         segments = ToAggPath( splinedlist, 
false );
 
 1328         segments = ToAggPath( array, 
false );
 
 1330     if ( segments == 0 )
 
 1333     agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1339         m_path.close_polygon();
 
 1340         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1341         m_rasterizer.reset();
 
 1342         m_rasterizer.add_path( tr );
 
 1344         RenderGradient( 
false );
 
 1348         m_path.close_polygon();
 
 1349         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1350         m_rasterizer.reset();
 
 1351         m_rasterizer.add_path( tr );
 
 1353         RenderGradient( 
true );
 
 1359         m_path.close_polygon();
 
 1360         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1361         m_rasterizer.reset();
 
 1362         m_rasterizer.add_path( tr );
 
 1368         m_path.close_polygon();
 
 1369         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1370         m_rasterizer.reset();
 
 1371         m_rasterizer.add_path( tr );
 
 1378         m_rasterizer.reset();
 
 1379         m_path.close_polygon();
 
 1380         _ras_add_stroked_path_xform( m_path, mtx );
 
 1395         segments = ToAggPath( splinedlist, 
false );
 
 1399         segments = ToAggPath( list, 
false );
 
 1401     if ( segments == 0 )
 
 1404     agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1410         m_path.close_polygon();
 
 1411         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1412         m_rasterizer.reset();
 
 1413         m_rasterizer.add_path( tr );
 
 1415         RenderGradient( 
false );
 
 1419         m_path.close_polygon();
 
 1420         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1421         m_rasterizer.reset();
 
 1422         m_rasterizer.add_path( tr );
 
 1424         RenderGradient( 
true );
 
 1430         m_path.close_polygon();
 
 1432         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1433         m_rasterizer.reset();
 
 1434         m_rasterizer.add_path( tr );
 
 1440         m_path.close_polygon();
 
 1442         agg::conv_transform<agg::path_storage> tr( m_path, mtx );
 
 1443         m_rasterizer.reset();
 
 1444         m_rasterizer.add_path( tr );
 
 1451         m_rasterizer.reset();
 
 1452         m_path.close_polygon();
 
 1453         _ras_add_stroked_path_xform( m_path, mtx );
 
 1463     for( a2dListOfa2dVertexList::iterator iterp = polylist.begin(); iterp != polylist.end(); iterp++ )
 
 1478         segments = ToAggPath( splinedlist, 
false );
 
 1482         segments = ToAggPath( list, 
false );
 
 1484     if ( segments == 0 )
 
 1487     agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1488     m_rasterizer.reset();
 
 1489     _ras_add_stroked_path_xform( m_path, mtx );
 
 1502         segments = ToAggPath( splinedlist, 
false );
 
 1506         segments = ToAggPath( array, 
false );
 
 1508     if ( segments == 0 )
 
 1511     agg::trans_affine mtx = _get_agg_user_to_device_transform();
 
 1512     m_rasterizer.reset();
 
 1513     _ras_add_stroked_path_xform( m_path, mtx );
 
 1525 #if wxART2D_USE_FREETYPE 
 1528     agg::path_storage path;
 
 1531     FT_Glyph glyph = 
m_currentfont.GetGlyphFreetype( c )->m_glyph;
 
 1532     if ( glyph->format != FT_GLYPH_FORMAT_OUTLINE )
 
 1534     FT_Outline& outline = ( ( FT_OutlineGlyph ) glyph )->outline;
 
 1537     FT_Vector   v_control;
 
 1550     for( n = 0; n < outline.n_contours; n++ )
 
 1554         last  = outline.contours[n];
 
 1555         limit = outline.points + last;
 
 1557         v_start = outline.points[first];
 
 1558         v_last  = outline.points[last];
 
 1560         v_control = v_start;
 
 1562         point = outline.points + first;
 
 1563         tags  = outline.tags  + first;
 
 1564         tag   = FT_CURVE_TAG( tags[0] );
 
 1567         if( tag == FT_CURVE_TAG_CUBIC ) 
return;
 
 1570         if( tag == FT_CURVE_TAG_CONIC )
 
 1573             if( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
 
 1584                 v_start.x = ( v_start.x + v_last.x ) / 2;
 
 1585                 v_start.y = ( v_start.y + v_last.y ) / 2;
 
 1593         path.move_to( v_start.x, v_start.y );
 
 1595         while( point < limit )
 
 1600             tag = FT_CURVE_TAG( tags[0] );
 
 1603                 case FT_CURVE_TAG_ON:  
 
 1605                     path.line_to( point->x, point->y );
 
 1609                 case FT_CURVE_TAG_CONIC:  
 
 1611                     v_control.x = point->x;
 
 1612                     v_control.y = point->y;
 
 1622                         tag = FT_CURVE_TAG( tags[0] );
 
 1627                         if( tag == FT_CURVE_TAG_ON )
 
 1629                             path.curve3( v_control.x, v_control.y, vec.x, vec.y );
 
 1633                         if( tag != FT_CURVE_TAG_CONIC ) 
return;
 
 1635                         v_middle.x = ( v_control.x + vec.x ) / 2;
 
 1636                         v_middle.y = ( v_control.y + vec.y ) / 2;
 
 1638                         path.curve3( v_control.x, v_control.y, v_middle.x, v_middle.y );
 
 1643                     path.curve3( v_control.x, v_control.y, v_start.x, v_start.y );
 
 1649                     FT_Vector vec1, vec2;
 
 1651                     if( point + 1 > limit || FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
 
 1656                     vec1.x = point[0].x;
 
 1657                     vec1.y = point[0].y;
 
 1658                     vec2.x = point[1].x;
 
 1659                     vec2.y = point[1].y;
 
 1664                     if( point <= limit )
 
 1671                         path.curve4( vec1.x, vec1.y, vec2.x, vec2.y, vec.x, vec.y );
 
 1675                     path.curve4( vec1.x, vec1.y, vec2.x, vec2.y, v_start.x, v_start.y );
 
 1681         path.close_polygon();
 
 1689     affine.
Scale( scale );
 
 1696     agg::conv_transform< agg::path_storage > tr( path, mtx );
 
 1697     agg::conv_curve< agg::conv_transform< agg::path_storage > > stroke( tr );
 
 1699     m_rasterizer.reset();
 
 1700     m_rasterizer.add_path( stroke );
 
 1703 #else // wxART2D_USE_FREETYPE 
 1705 #endif // wxART2D_USE_FREETYPE 
 1710     agg::path_storage path;
 
 1717             a2dVertexList::iterator iter = ( *ptr )->begin();
 
 1718             if ( ( *ptr )->size() )
 
 1721                 path.move_to( point.m_x * size, point.m_y * size );
 
 1724             while ( iter != ( *ptr )->end() )
 
 1727                 path.line_to( point.m_x * size, point.m_y * size );
 
 1738     agg::conv_transform< agg::path_storage > tr( path, mtx );
 
 1739     agg::conv_stroke< agg::conv_transform< agg::path_storage > > stroke( tr );
 
 1741     stroke.line_join( m_join );
 
 1742     stroke.line_cap( m_cap );
 
 1744     m_rasterizer.reset();
 
 1745     m_rasterizer.add_path( stroke );
 
 1758 void 
a2dAggDrawerRgba::DeviceDrawPixel( 
int x1, 
int y1, 
unsigned char r, 
unsigned char g, 
unsigned char b , 
unsigned char a )
 
 1760     agg::rgba8 colorfill( m_colour1redStroke, m_colour1greenStroke, m_colour1blueStroke, m_StrokeOpacityCol1 );
 
 1761     m_renBase.blend_pixel( x1, y1, colorfill, 255 );
 
 1764 void a2dAggDrawerRgba::Render( 
bool fillColor )
 
 1769         m_renderer.color( colorfill );
 
 1770         m_renSolidComp.color( colorfill );
 
 1775         m_renderer.color( colorstroke );
 
 1776         m_renSolidComp.color( colorstroke );
 
 1779     if( m_blendMode == agg::end_of_comp_op_e )
 
 1780         agg::render_scanlines( m_rasterizer, m_sl, m_renderer );
 
 1782         agg::render_scanlines( m_rasterizer, m_sl, m_renSolidComp );
 
 1785 void a2dAggDrawerRgba::RenderGradient( 
bool radial )
 
 1789         span_allocator_type aggallocator;
 
 1790         LinearGradientSpan span( 
 
 1791             m_fillGradientInterpolator,
 
 1792             m_linearGradientFunction,
 
 1796         RendererLinearGradientA ren( m_renBase, aggallocator, span );
 
 1797         RendererLinearGradientComp renComp( m_renBaseComp, aggallocator, span );
 
 1799         if( m_blendMode == agg::end_of_comp_op_e )
 
 1800             agg::render_scanlines( m_rasterizer, m_sl, ren );
 
 1802             agg::render_scanlines( m_rasterizer, m_sl, renComp );
 
 1806         span_allocator_type aggallocator;
 
 1807         RadialGradientSpan span( 
 
 1808             m_fillGradientInterpolator,
 
 1809             m_radialGradientFunction,
 
 1813         RendererRadialGradientA ren( m_renBase, aggallocator, span );
 
 1814         RendererRadialGradientComp renComp( m_renBaseComp, aggallocator, span );
 
 1816         if( m_blendMode == agg::end_of_comp_op_e )
 
 1817             agg::render_scanlines( m_rasterizer, m_sl, ren );
 
 1819             agg::render_scanlines( m_rasterizer, m_sl, renComp );
 
 1824 void a2dAggDrawerRgba::RenderBitmapFill()
 
 1826     unsigned offset_x = 0;
 
 1827     unsigned offset_y = 0;
 
 1831     typedef agg::wrap_mode_repeat wrap_x_type;
 
 1832     typedef agg::wrap_mode_repeat wrap_y_type;
 
 1834     typedef agg::image_accessor_wrap<PixFormat, wrap_x_type, wrap_y_type> img_source_type;
 
 1836     typedef agg::span_allocator<color_type> span_alloc_type;
 
 1838     typedef agg::renderer_scanline_aa<RendererBaseA, span_alloc_type, span_gen_type> renderer_type;
 
 1840     PixFormat  img_pixf( m_pattern_rbuf );
 
 1841     img_source_type img_src( img_pixf );
 
 1842     span_gen_type sg( img_src, offset_x, offset_y );
 
 1847     renderer_type rp( m_renBase, sa, sg );
 
 1849     agg::render_scanlines( m_rasterizer, m_sl, rp );
 
 1852 void a2dAggDrawerRgba::RenderSetClip()
 
 1860     m_rendering_buffer(),
 
 1861     m_pixFormat( m_rendering_buffer ),
 
 1862     m_pixFormatComp( m_rendering_buffer ),
 
 1863     m_renBase( m_pixFormat ),
 
 1864     m_renBaseComp( m_pixFormatComp ),
 
 1865     m_renderer( m_renBase ),
 
 1866     m_renSolidComp( m_renBaseComp ),
 
 1871     m_ownsBuffer = 
true;
 
 1872     m_preStroke = 
false;
 
 1874     m_pdata = m_buffer.GetData();
 
 1880     m_rendering_buffer(),
 
 1881     m_pixFormat( m_rendering_buffer ),
 
 1882     m_pixFormatComp( m_rendering_buffer ),
 
 1883     m_renBase( m_pixFormat ),
 
 1884     m_renBaseComp( m_pixFormatComp ),
 
 1885     m_renderer( m_renBase ),
 
 1886     m_renSolidComp( m_renBaseComp ),
 
 1890     if ( width == 0 || height == 0 )
 
 1894     m_ownsBuffer = 
true;
 
 1895     m_pdata = m_buffer.GetData();
 
 1897     m_pixFormatComp.premultiply();
 
 1899     m_preStroke = 
false;
 
 1904     m_rendering_buffer(),
 
 1905     m_pixFormat( m_rendering_buffer ),
 
 1906     m_pixFormatComp( m_rendering_buffer ),
 
 1907     m_renBase( m_pixFormat ),
 
 1908     m_renBaseComp( m_pixFormatComp ),
 
 1909     m_renderer( m_renBase ),
 
 1910     m_renSolidComp( m_renBaseComp ),
 
 1914     m_ownsBuffer = 
false;
 
 1917     m_buffer = other.m_buffer;
 
 1918     m_preStroke = other.m_preStroke;
 
 1923     m_rendering_buffer(),
 
 1924     m_pixFormat( m_rendering_buffer ),
 
 1925     m_pixFormatComp( m_rendering_buffer ),
 
 1926     m_renBase( m_pixFormat ),
 
 1927     m_renBaseComp( m_pixFormatComp ),
 
 1928     m_renderer( m_renBase ),
 
 1929     m_renSolidComp( m_renBaseComp ),
 
 1933     wxImage image = bitmap.ConvertToImage();
 
 1935     m_ownsBuffer = 
true;
 
 1936     m_pdata = m_buffer.GetData();
 
 1939     m_preStroke = 
false;
 
 1943 a2dAggDrawerRgba::~a2dAggDrawerRgba()
 
 1949     wxImage image = m_buffer.GetImage();
 
 1957     int old_pixelwidth = 
m_width * 4;
 
 1958     int new_pixelwidth = w * 4;
 
 1959     int pixelwidth = wxMin( w, 
m_width ) * 4;
 
 1960     int minheight =  wxMin( h, 
m_height );
 
 1963     unsigned char* oldpdata = m_pdata;
 
 1964     unsigned char* newpdata = newbuf.GetData();
 
 1966     for ( 
int yp = 0; yp < minheight; yp++ )
 
 1968         memcpy( newpdata, oldpdata, pixelwidth );
 
 1969         oldpdata += old_pixelwidth;
 
 1970         newpdata += new_pixelwidth;
 
 1977     m_pdata = m_buffer.GetData();
 
 1979     m_pixFormatComp.premultiply();
 
 1985     return wxBitmap( m_buffer.GetImage() );
 
 1990     return wxBitmap( m_buffer.GetImage().GetSubImage( rect ) );
 
 1993 void a2dAggDrawerRgba::CopyIntoBuffer( 
const wxBitmap& bitm )
 
 1998 void a2dAggDrawerRgba::DoSetDrawStyle( 
a2dDrawStyle drawstyle )
 
 2000     a2dAggDrawerBase::DoSetDrawStyle( drawstyle );
 
 2001     m_pixFormatComp.comp_op( m_blendMode );
 
 2008     int imagew = image.GetWidth();
 
 2009     int imageh = image.GetHeight();
 
 2011     agg::trans_affine mtxi;
 
 2012     mtxi *= agg::trans_affine_scaling( width / imagew, height / imageh );
 
 2013     mtxi *= agg::trans_affine_translation( x - width / 2, y - height / 2 );
 
 2019     agg::trans_affine mtx(
 
 2027     typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 
 2030     typedef agg::image_accessor_clip<PixFormat> img_source_type;
 
 2031     typedef agg::span_interpolator_linear<> interpolator_type;
 
 2032     interpolator_type interpolator( mtxi );
 
 2034     typedef agg::span_image_filter_rgb_bilinear<img_source_type, interpolator_type> span_gen_type;
 
 2037     typedef agg::span_converter<span_gen_type, span_conv_const_alpha_rgba8> span_conv;
 
 2039     agg::rendering_buffer image_buffer;
 
 2040     image_buffer.attach( image.GetData(), imagew, imageh, ( 
m_yaxis ) ? -imagew * 3 : imagew * 3 );
 
 2041     PixFormat img_pixf( image_buffer );
 
 2042     img_source_type img_src( img_pixf, agg::rgba( 1, 1, 1, 0 ) );
 
 2044     span_gen_type sg( img_src, interpolator );
 
 2062     agg::rounded_rect er( x - width / 2, y - height / 2 , x + width / 2, y + height / 2, 0 );
 
 2063     er.normalize_radius();
 
 2064     agg::conv_transform<agg::rounded_rect> tr( er, mtx );
 
 2065     m_rasterizer.reset();
 
 2066     m_rasterizer.add_path( tr );
 
 2073         span_conv_const_alpha_rgba8 color_alpha( OpacityFactor );
 
 2074         span_conv sc( sg, color_alpha );
 
 2075         typedef agg::renderer_scanline_aa<RendererBaseA, span_alloc_type, span_conv> renderer_type_alpha;
 
 2076         renderer_type_alpha ri( m_renBase, sa, sc );
 
 2078         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2082         typedef agg::renderer_scanline_bin<RendererBaseA, span_alloc_type, span_gen_type> renderer_type_normal;
 
 2083         renderer_type_normal ri( m_renBase, sa, sg );
 
 2084         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2093     int imagew = image.GetWidth();
 
 2094     int imageh = image.GetHeight();
 
 2096     agg::trans_affine mtxi;
 
 2097     mtxi *= agg::trans_affine_scaling( width / imagew, height / imageh );
 
 2098     mtxi *= agg::trans_affine_translation( x, y );
 
 2101     agg::trans_affine mtx(
 
 2109     typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 
 2111     typedef agg::image_accessor_clip<agg::pixfmt_rgba32> img_source_type;
 
 2112     typedef agg::span_interpolator_linear<> interpolator_type;
 
 2113     interpolator_type interpolator( mtxi );
 
 2115     typedef agg::span_image_filter_rgba_nn<img_source_type, interpolator_type> span_gen_type;
 
 2117     typedef agg::span_converter<span_gen_type, span_conv_const_alpha_rgba8> span_conv;
 
 2119     agg::rendering_buffer image_buffer;
 
 2120     image_buffer.attach( image.GetData(), imagew, imageh, imagew * 4 );
 
 2121     agg::pixfmt_rgba32 img_pixf( image_buffer );
 
 2122     img_source_type img_src( img_pixf, agg::rgba( 0, 0, 0, 0 ) );
 
 2124     span_gen_type sg( img_src, interpolator );
 
 2127     agg::rounded_rect er( x, y , x + width, y + height, 1 );
 
 2128     er.normalize_radius();
 
 2129     agg::conv_transform<agg::rounded_rect> tr( er, mtx );
 
 2130     m_rasterizer.reset();
 
 2131     m_rasterizer.add_path( tr );
 
 2136     if ( OpacityFactor != 255 )
 
 2138         span_conv_const_alpha_rgba8 color_alpha( OpacityFactor );
 
 2139         span_conv sc( sg, color_alpha );
 
 2140         typedef agg::renderer_scanline_aa<RendererBaseA, span_alloc_type, span_conv> renderer_type_alpha;
 
 2141         renderer_type_alpha ri( m_renBase, sa, sc );
 
 2143         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2147         typedef agg::renderer_scanline_bin<RendererBaseA, span_alloc_type, span_gen_type> renderer_type_normal;
 
 2148         renderer_type_normal ri( m_renBase, sa, sg );
 
 2149         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2158         rect.width += rect.x;
 
 2161     if ( rect.width <= 0 ) 
return;
 
 2165         rect.height += rect.y;
 
 2168     if ( rect.height <= 0 ) 
return;
 
 2170     if ( rect.x + rect.width >= 
m_width )
 
 2171         rect.width = 
m_width - rect.x;
 
 2173     if ( rect.width <= 0 ) 
return;
 
 2175     if ( rect.y + rect.height >= 
m_height )
 
 2178     if ( rect.height <= 0 ) 
return;
 
 2180     int xmax = rect.x + rect.width;
 
 2181     int ymax = rect.y + rect.height;
 
 2184     wxBitmap subbitmap = subImage->CreateBitmap();
 
 2188     mdc.SelectObject( subbitmap );
 
 2190     dc->Blit( rect.x - bufferpos.x, rect.y - bufferpos.y, xmax - rect.x, ymax - rect.y, &mdc, 0, 0, wxCOPY, 
false );
 
 2192     mdc.SelectObject( wxNullBitmap );
 
 2197     ShiftBufferInternal( dxy, yshift, 4 );
 
 2207     m_renBase.blend_pixel( x1, y1, colorfill, 255 );
 
 2210 void a2dAggDrawer::Render( 
bool fillColor )
 
 2215         m_renderer.color( colorfill );
 
 2220         m_renderer.color( colorstroke );
 
 2222     agg::render_scanlines( m_rasterizer, m_sl, m_renderer );
 
 2225 void a2dAggDrawer::RenderGradient( 
bool radial )
 
 2229         span_allocator_type aggallocator;
 
 2230         LinearGradientSpan span( 
 
 2231             m_fillGradientInterpolator,
 
 2232             m_linearGradientFunction,
 
 2236         RendererLinearGradient ren( m_renBase, aggallocator, span );
 
 2237         agg::render_scanlines( m_rasterizer, m_sl, ren );
 
 2241         span_allocator_type aggallocator;
 
 2242         RadialGradientSpan span( 
 
 2243             m_fillGradientInterpolator,
 
 2244             m_radialGradientFunction,
 
 2248         RendererRadialGradient ren( m_renBase, aggallocator, span );
 
 2249         agg::render_scanlines( m_rasterizer, m_sl, ren );
 
 2253 void a2dAggDrawer::RenderBitmapFill()
 
 2255     unsigned offset_x = 0;
 
 2256     unsigned offset_y = 0;
 
 2260     typedef agg::wrap_mode_repeat wrap_x_type;
 
 2261     typedef agg::wrap_mode_repeat wrap_y_type;
 
 2263     typedef agg::image_accessor_wrap<PixFormat, wrap_x_type, wrap_y_type> img_source_type;
 
 2265     typedef agg::span_allocator<color_type> span_alloc_type;
 
 2267     typedef agg::renderer_scanline_aa<RendererBase, span_alloc_type, span_gen_type> renderer_type;
 
 2269     PixFormat  img_pixf( m_pattern_rbuf );
 
 2270     img_source_type img_src( img_pixf );
 
 2271     span_gen_type sg( img_src, offset_x, offset_y );
 
 2276     renderer_type rp( m_renBase, sa, sg );
 
 2278     agg::render_scanlines( m_rasterizer, m_sl, rp );
 
 2281 void a2dAggDrawer::RenderSetClip()
 
 2290     m_rendering_buffer(),
 
 2291     m_pixFormat( m_rendering_buffer ),
 
 2292     m_renBase( m_pixFormat ),
 
 2293     m_renderer( m_renBase ),
 
 2297     m_buffer = wxImage( m_width, m_height );
 
 2299     m_pdata = m_buffer.GetData();
 
 2300     m_rendering_buffer.attach( m_pdata, m_width, m_height, m_width * 3 );
 
 2301     DestroyClippingRegion();
 
 2302     m_preStroke = 
false;
 
 2306     m_rendering_buffer(),
 
 2307     m_pixFormat( m_rendering_buffer ),
 
 2308     m_renBase( m_pixFormat ),
 
 2309     m_renderer( m_renBase ),
 
 2313     if ( width == 0 || height == 0 )
 
 2314         m_buffer = wxImage( 100, 100 );
 
 2316         m_buffer = wxImage( width, height );
 
 2318     m_pdata = m_buffer.GetData();
 
 2321     m_preStroke = 
false;
 
 2325     m_rendering_buffer(),
 
 2326     m_pixFormat( m_rendering_buffer ),
 
 2327     m_renBase( m_pixFormat ),
 
 2328     m_renderer( m_renBase ),
 
 2334     m_buffer = other.m_buffer;
 
 2335     m_preStroke = other.m_preStroke;
 
 2339     m_rendering_buffer(),
 
 2340     m_pixFormat( m_rendering_buffer ),
 
 2341     m_renBase( m_pixFormat ),
 
 2342     m_renderer( m_renBase ),
 
 2346     m_buffer = bitmap.ConvertToImage();
 
 2347     m_pdata = m_buffer.GetData();
 
 2350     m_preStroke = 
false;
 
 2353 a2dAggDrawer::~a2dAggDrawer()
 
 2359     wxImage newbuf = wxImage( w, h );
 
 2361     int old_pixelwidth = 
m_width * 3;
 
 2362     int new_pixelwidth = w * 3;
 
 2363     int pixelwidth = wxMin( w, 
m_width ) * 3;
 
 2364     int minheight =  wxMin( h, 
m_height );
 
 2367     unsigned char* oldpdata = m_pdata;
 
 2368     unsigned char* newpdata = newbuf.GetData();
 
 2370     for ( 
int yp = 0; yp < minheight; yp++ )
 
 2372         memcpy( newpdata, oldpdata, pixelwidth );
 
 2373         oldpdata += old_pixelwidth;
 
 2374         newpdata += new_pixelwidth;
 
 2381     m_pdata = m_buffer.GetData();
 
 2397     return wxBitmap( m_buffer );
 
 2402     return wxBitmap( m_buffer.GetSubImage( rect ) );
 
 2405 void a2dAggDrawer::CopyIntoBuffer( 
const wxBitmap& bitm )
 
 2407     m_buffer = bitm.ConvertToImage();
 
 2408     m_pdata = m_buffer.GetData();
 
 2417     int imagew = image.GetWidth();
 
 2418     int imageh = image.GetHeight();
 
 2420     agg::trans_affine mtxi;
 
 2421     mtxi *= agg::trans_affine_scaling( width / imagew, height / imageh );
 
 2422     mtxi *= agg::trans_affine_translation( x - width / 2, y - height / 2 );
 
 2428     agg::trans_affine mtx(
 
 2436     typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 
 2439     typedef agg::image_accessor_clip<PixFormat> img_source_type;
 
 2440     typedef agg::span_interpolator_linear<> interpolator_type;
 
 2441     interpolator_type interpolator( mtxi );
 
 2443     typedef agg::span_image_filter_rgb_bilinear<img_source_type, interpolator_type> span_gen_type;
 
 2446     typedef agg::span_converter<span_gen_type, span_conv_const_alpha_rgba8> span_conv;
 
 2448     typedef agg::renderer_scanline_aa<RendererBase, span_alloc_type, span_conv> renderer_type_alpha;
 
 2450     typedef agg::renderer_scanline_bin<RendererBase, span_alloc_type, span_gen_type> renderer_type_normal;
 
 2452     agg::rendering_buffer image_buffer;
 
 2453     image_buffer.attach( image.GetData(), imagew, imageh, ( 
m_yaxis ) ? -imagew * 3 : imagew * 3 );
 
 2454     PixFormat img_pixf( image_buffer );
 
 2455     img_source_type img_src( img_pixf, agg::rgba( 1, 1, 1, 0 ) );
 
 2457     span_gen_type sg( img_src, interpolator );
 
 2475     agg::rounded_rect er( x - width / 2, y - height / 2 , x + width / 2, y + height / 2, 0 );
 
 2476     er.normalize_radius();
 
 2477     agg::conv_transform<agg::rounded_rect> tr( er, mtx );
 
 2478     m_rasterizer.reset();
 
 2479     m_rasterizer.add_path( tr );
 
 2484     if ( image.HasAlpha() || OpacityFactor != 255 )
 
 2486         span_conv_const_alpha_rgba8 color_alpha( OpacityFactor );
 
 2488         span_conv sc( sg, color_alpha );
 
 2489         renderer_type_alpha ri( m_renBase, sa, sc );
 
 2491         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2495         renderer_type_normal ri( m_renBase, sa, sg );
 
 2496         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2505     int imagew = image.GetWidth();
 
 2506     int imageh = image.GetHeight();
 
 2508     agg::trans_affine mtxi;
 
 2509     mtxi *= agg::trans_affine_scaling( width / imagew, height / imageh );
 
 2510     mtxi *= agg::trans_affine_translation( x, y );
 
 2513     agg::trans_affine mtx(
 
 2521     typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 
 2523     typedef agg::image_accessor_clip<agg::pixfmt_rgba32> img_source_type;
 
 2524     typedef agg::span_interpolator_linear<> interpolator_type;
 
 2525     interpolator_type interpolator( mtxi );
 
 2527     typedef agg::span_image_filter_rgba_nn<img_source_type, interpolator_type> span_gen_type;
 
 2529     typedef agg::span_converter<span_gen_type, span_conv_const_alpha_rgba8> span_conv;
 
 2531     typedef agg::renderer_scanline_aa<RendererBase, span_alloc_type, span_conv> renderer_type_alpha;
 
 2533     typedef agg::renderer_scanline_bin<RendererBase, span_alloc_type, span_gen_type> renderer_type_normal;
 
 2535     agg::rendering_buffer image_buffer;
 
 2536     image_buffer.attach( image.GetData(), imagew, imageh, imagew * 4 );
 
 2537     agg::pixfmt_rgba32 img_pixf( image_buffer );
 
 2538     img_source_type img_src( img_pixf, agg::rgba( 0, 0, 0, 0 ) );
 
 2540     span_gen_type sg( img_src, interpolator );
 
 2543     agg::rounded_rect er( x, y , x + width, y + height, 1 );
 
 2544     er.normalize_radius();
 
 2545     agg::conv_transform<agg::rounded_rect> tr( er, mtx );
 
 2546     m_rasterizer.reset();
 
 2547     m_rasterizer.add_path( tr );
 
 2552     if ( OpacityFactor != 255 )
 
 2554         span_conv_const_alpha_rgba8 color_alpha( OpacityFactor );
 
 2555         span_conv sc( sg, color_alpha );
 
 2556         renderer_type_alpha ri( m_renBase, sa, sc );
 
 2558         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2562         renderer_type_normal ri( m_renBase, sa, sg );
 
 2563         agg::render_scanlines( m_rasterizer, m_sl, ri );
 
 2572         rect.width += rect.x;
 
 2575     if ( rect.width <= 0 ) 
return;
 
 2579         rect.height += rect.y;
 
 2582     if ( rect.height <= 0 ) 
return;
 
 2584     if ( rect.x + rect.width >= 
m_width )
 
 2585         rect.width = 
m_width - rect.x;
 
 2587     if ( rect.width <= 0 ) 
return;
 
 2589     if ( rect.y + rect.height >= 
m_height )
 
 2592     if ( rect.height <= 0 ) 
return;
 
 2594     int xmax = rect.x + rect.width;
 
 2595     int ymax = rect.y + rect.height;
 
 2597     wxBitmap subbitmap = m_buffer.GetSubImage( rect );
 
 2599     mdc.SelectObject( subbitmap );
 
 2601     dc->Blit( rect.x - bufferpos.x, rect.y - bufferpos.y, xmax - rect.x, ymax - rect.y, &mdc, 0, 0, wxCOPY, 
false );
 
 2603     mdc.SelectObject( wxNullBitmap );
 
 2608     ShiftBufferInternal( dxy, yshift, 3 );
 
a2dAffineMatrix m_usertodevice
pointer to current user-to-device transform matrix ( so includes mapping matrix ) ...
a2dStroke m_activestroke
used while rendering 
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles 
a2dDrawStyle m_drawstyle
drawstyle (like invert mode) 
double GetSize() const 
Get the font size. 
double GetStrokeWidth() const 
Get stroke width. 
wxUint8 m_StrokeOpacityCol1
active stroke alpha 
virtual void DeviceDrawPixel(int x1, int y1, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
draw a single, unstroked pixel in device coordinates with the given color 
a2dStroke m_fixStrokeRestore
used to restore an overruled fix style 
wxImage GetImageBuffer() const 
return wxImage which is used as buffer here 
void ShiftBuffer(int dxy, bool yshift)
quick scroll over small distance 
a2dFill m_activefill
used while rendering 
void SetDrawStyle(a2dDrawStyle drawstyle)
set drawstyle to use for drawing, 
int WorldToDeviceY(double y) const 
convert y from world to device coordinates 
virtual void DrawPolygon(a2dVertexArray *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
Draw polygon in world coordinates using pointarray. 
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking 
Stroke and fill base classes. 
a2dPoint2D GetStop() const 
Get stop for gradient fill colour change. 
unsigned char m_colour2blueFill
active fill colours 
a2dStroke m_currentstroke
used while rendering 
a2dDrawStyle m_fixDrawstyle
used to restore an overruled fix style 
const a2dFill * a2dBLACK_FILL
global a2dFill stock object for BLACK filling 
bool IsStrokeOnly()
wxART2D_USE_GRAPHICS_CONTEXT 
std::vector< wxRealPoint > m_cpointsDouble
cached array for containing transformed device coordinates (double) 
double DeviceToWorldYRel(double y) const 
convert y relative from device to world coordinates 
double GetDescent() const 
Get descent. 
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke. 
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc. 
double GetRadius() const 
Get stop for gradient fill colour change. 
bool GetPixelStroke() const 
if the width is pixels or not. 
virtual void DrawCharDc(wxChar c)
Draw a dc character. 
double GetValue(int col, int row) const 
get the value in the matrix at col,row 
unsigned char m_colour1redFill
active fill colours 
void ShiftBuffer(int dxy, bool yshift)
quick scroll over small distance 
a2dFont m_currentfont
current font set 
a2dBoundingBox m_clipboxworld
current clipping area in world coordinates 
virtual void DrawCharFreetype(wxChar c)
Draw a freetype character. 
void DeviceDrawPixel(int x1, int y1, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
draw a single, unstroked pixel in device coordinates with the given color 
a2dVertexList * ConvertSplinedPolyline(double Aber) const 
Spline conversion for polyline. 
Arc Segment in a2dVertexList. 
vertex array of line and arc segments. 
unsigned char m_colour1blueStroke
active stroke colours 
virtual void BeginDraw()
start to draw on this context (used to initialize a specific drawer) 
unsigned char m_colour2redFill
active fill colours 
vertex list of line and arc segments. 
unsigned char m_colour1blueFill
active fill colours 
void TransformPoint(double x, double y, double &tx, double &ty) const 
Transform a point. 
a2dStrokeGlyph GetGlyphStroke(wxChar c) const 
Get the glyph of a single character. 
virtual void EndDraw()
end drawing on this context (used to reset a specific drawer) 
double TransformDistance(double distance) const 
Transform a distance. 
virtual void SetActiveFill(const a2dFill &fill)
sync with actual API graphical context 
wxBitmap GetBuffer() const 
get buffer as bitmap pointer 
a2dVertexList * ConvertSplinedPolygon(double Aber) const 
Spline conversion for polygon. 
a2dDrawStyle
Define the manner in which a2dCanvasView draws to the device. 
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill. 
bool Ok() const 
Check font validity. 
void SetBufferSize(int w, int h)
set buffer size to w pixel wide and h pixels heigh 
a2dVertexArray * ConvertSplinedPolyline(double Aber) const 
Spline conversion for polyline. 
a2dClipRegionList m_clipregionlist
pushed clipping regions 
bool CalcR(const a2dLineSegment &prev, double &radius, double ¢er_x, double ¢er_y, double &beginrad, double &midrad, double &endrad, double &phit) const 
Calculation of center for the Arc. 
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates. 
a2dAffineMatrix m_worldtodevice
world to device coordinate mapping 
double m_displayaberration
accuracy of arc segment calculation etc. in device coordinates 
#define forEachIn(listtype, list)
easy iteration for a2dlist 
virtual void DrawCharDc(wxChar c)
Draw a dc character. 
the antigrain based drawing context derived from a2dDrawer2D 
unsigned char m_colour1greenStroke
active stroke colours 
void DrawImage(const wxImage &image, double x, double y, double width, double height, wxUint8 Opacity=255)
Draw wxImage in world coordinates. 
void SetBufferSize(int w, int h)
set buffer size to w pixel wide and h pixels heigh 
wxBitmap GetBuffer() const 
get buffer as bitmap pointer 
a2dPoint2D GetStart() const 
Get start for gradient fill colour change. 
a2dPoint2D GetCenter() const 
Get start for gradient fill colour change. 
the antigrain based drawing context derived from a2dDrawer2D 
Drawing context abstraction. 
Normal straight line segment in a2dVertexList and a2dVertexArray. 
unsigned char m_colour2greenFill
active fill colours 
int WorldToDeviceX(double x) const 
convert x from world to device coordinates 
virtual void DrawLines(a2dVertexArray *points, bool spline=false)
Draw polyline in world coordinates using pointarray. 
virtual void ExtendClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE, a2dBooleanClip clipoperation=a2dCLIP_AND)
extend clipping region with a polygon to which everything drawn will be clipped. 
void DoSetActiveStroke()
per drawer implementation 
virtual void DrawPolyPolygon(a2dListOfa2dVertexList polylist, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
draw a list of polygons ( contour clockwise becomes hole ) 
a2dPoint2D GetFocal() const 
Get start for gradient fill colour change. 
void SetClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
set clipping region from polygon to which everything drawn will be clipped. 
the antigrain based drawing context derived from a2dDrawer2D 
void SetClippingRegionDev(wxCoord minx, wxCoord miny, wxCoord width, wxCoord height)
set clipping region using x y values in device coordinates 
A 2x3 affine matrix class for 2D transformations. 
agg::rgba8 color_type
color format in a2dAggDrawer 
virtual void SetActiveStroke(const a2dStroke &stroke)
sync with actual API graphical context 
a2dBoundingBox ToWorld(const wxRect &rect)
convert the rect in device coordinates to a bounding box in world coordinates and return that boundin...
int m_height
device size height 
bool m_disableDrawing
all drawing is disabled when this is true 
a2dAggDrawerRgba(int width=0, int height=0)
Drawer having a buffer of w pixel wide and h pixels heigh. 
void DrawImage(const wxImage &image, double x, double y, double width, double height, wxUint8 Opacity=255)
Draw wxImage in world coordinates. 
double m_x
x endpoint of line 
void DestroyClippingRegion()
set clipping region off 
a2dAggDrawer(int width=0, int height=0)
Drawer having a buffer of w pixel wide and h pixels heigh. 
a2dBooleanClip
Used for defining how a ClippingRegion defined as a polygon is combined with. 
wxRect m_clipboxdev
current clipping area in device coordinates 
virtual void DrawCharFreetype(wxChar c)
Draw a freetype character. 
double m_y
y endpoint of line 
void Aberration(double aber, double angle, double radius, double &dphi, unsigned int &segments)
calculate number of segments in an arc such that a certain accuracy is maintained ...
int m_beginDraw_endDraw
counter for BeginDraw EndDraw calls 
wxBitmap GetSubBitmap(wxRect sub_rect) const 
get part of the buffer given a rect 
int m_width
device size width 
void DrawPoint(double xc, double yc)
draw a single point 
unsigned char m_colour1greenFill
active fill colours 
virtual void ExtendAndPushClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE, a2dBooleanClip clipoperation=a2dCLIP_AND)
push on stack the current clipping region and extend clipping region 
void DoSetActiveFill()
per drawer implementation 
unsigned char m_colour1redStroke
active stroke colours 
void BlitBuffer()
blit whole buffer to device 
bool Scale(double scale)
Scale by scale (isotropic scaling i.e. the same in x and y): 
bool Translate(double x, double y)
Translate by dx, dy: 
wxWindow * m_display
view its window. 
wxUint8 m_FillOpacityCol1
active fill alpha 
bool Invert(void)
Invert matrix. 
void PopClippingRegion()
pop a previously pushed clipping region 
#define Round(x)
round to integer such that e.g 2.5 < x < 3.5 becomes 3 
virtual void DrawCircle(double x, double y, double radius)
Draw Circle in world coordinates. 
virtual void DrawEllipse(double x, double y, double width, double height)
Draw Ellipse in world coordinates. 
virtual void DrawCharStroke(wxChar c)
Draw a stroke character. 
void ResetStyle()
set a pre-defined style reseting cashed values. 
a2dFill m_currentfill
used while rendering 
const a2dAffineMatrix & GetMappingMatrix()
get the world-to-device (aka mapping) matrix 
wxUint8 m_OpacityFactor
opacity will be the one set, derived by this 
wxBitmap GetSubBitmap(wxRect sub_rect) const 
get part of the buffer given a rect 
double DeviceToWorldXRel(double x) const 
convert x relative from device to world coordinates 
const a2dAffineMatrix & GetUserToDeviceTransform() const 
get matrix which transforms directly from user coordinates to device 
wxUint8 m_FillOpacityCol2
active fill alpha 
double m_splineaberration
accuracy of spline 
const double wxPI
defines PI 
unsigned int ConvertSplinedPolygon2(unsigned int n)
converts internal device points array to spline. Returns new number of points. 
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling 
a2dFill m_fixFillRestore
used to restore an overruled fix style