00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __WXAGGDRAWER_H__
00018 #define __WXAGGDRAWER_H__
00019
00020 #ifndef WX_PRECOMP
00021 #include "wx/wx.h"
00022 #endif
00023
00024
00025 #include "a2dprivate.h"
00026
00027 #if wxART2D_USE_AGGDRAWER
00028
00029 #include "wx/artbase/drawer2d.h"
00030 #include "agg_basics.h"
00031 #include "agg_rendering_buffer.h"
00032 #include "agg_rasterizer_scanline_aa.h"
00033 #include "agg_scanline_u.h"
00034 #include "agg_path_storage.h"
00035 #include "agg_conv_stroke.h"
00036 #include "wx/image.h"
00037 #include "wx/geometry.h"
00038
00039 #include "agg_pixfmt_rgb.h"
00040 #include "agg_pixfmt_rgba.h"
00041 #include "agg_image_accessors.h"
00042 #include "agg_span_allocator.h"
00043 #include "agg_conv_dash.h"
00044 #include "agg_pixfmt_rgba.h"
00045 #include "agg_span_image_filter_rgba.h"
00046
00047 #include "agg_rendering_buffer.h"
00048 #include "agg_rasterizer_scanline_aa.h"
00049 #include "agg_renderer_outline_aa.h"
00050 #include "agg_rasterizer_outline_aa.h"
00051 #include "agg_conv_transform.h"
00052 #include "agg_bspline.h"
00053 #include "agg_gsv_text.h"
00054 #include "agg_scanline_p.h"
00055 #include "agg_renderer_scanline.h"
00056 #include "agg_renderer_mclip.h"
00057
00058 #include "agg_conv_stroke.h"
00059 #include "agg_conv_dash.h"
00060 #include "agg_conv_curve.h"
00061 #include "agg_conv_contour.h"
00062 #include "agg_conv_smooth_poly1.h"
00063 #include "agg_conv_marker.h"
00064 #include "agg_arrowhead.h"
00065 #include "agg_vcgen_markers_term.h"
00066 #include "agg_rendering_buffer.h"
00067 #include "agg_arc.h"
00068 #include "agg_ellipse.h"
00069 #include "agg_rounded_rect.h"
00070 #include "agg_path_storage.h"
00071 #include "agg_span_pattern_rgb.h"
00072 #include "agg_trans_affine.h"
00073 #include "agg_span_image_filter_rgb.h"
00074 #include "agg_span_gradient.h"
00075 #include "agg_span_interpolator_linear.h"
00076 #include "agg_span_converter.h"
00077
00078 #ifdef A2DAGGDRAWERMAKINGDLL
00079 #define A2DAGGDRAWERDLLEXP WXEXPORT
00080 #define A2DAGGDRAWERDLLEXP_DATA(type) WXEXPORT type
00081 #define A2DAGGDRAWERDLLEXP_CTORFN
00082 #elif defined(WXART2D_USINGDLL)
00083 #define A2DAGGDRAWERDLLEXP WXIMPORT
00084 #define A2DAGGDRAWERDLLEXP_DATA(type) WXIMPORT type
00085 #define A2DAGGDRAWERDLLEXP_CTORFN
00086 #else // not making nor using DLL
00087 #define A2DAGGDRAWERDLLEXP
00088 #define A2DAGGDRAWERDLLEXP_DATA(type) type
00089 #define A2DAGGDRAWERDLLEXP_CTORFN
00090 #endif
00091
00092 #if defined(WXART2D_USINGDLL)
00093 template struct A2DAGGDRAWERDLLEXP agg::rect_base<int>;
00094
00095 template class A2DAGGDRAWERDLLEXP agg::pod_array<agg::int8u*>;
00096 template class A2DAGGDRAWERDLLEXP agg::row_ptr_cache<agg::int8u>;
00097
00098 template class A2DAGGDRAWERDLLEXP agg::rasterizer_sl_clip<agg::ras_conv_int>;
00099 template class A2DAGGDRAWERDLLEXP agg::pod_vector<agg::rasterizer_cells_aa<agg::cell_aa>::cell_type *>;
00100 template class A2DAGGDRAWERDLLEXP agg::pod_vector<agg::rasterizer_cells_aa<agg::cell_aa>::sorted_y>;
00101 template class A2DAGGDRAWERDLLEXP agg::rasterizer_cells_aa<agg::cell_aa>;
00102 template class A2DAGGDRAWERDLLEXP agg::rasterizer_scanline_aa<>;
00103
00104 template class A2DAGGDRAWERDLLEXP agg::row_accessor<agg::int8u>;
00105
00106 class A2DAGGDRAWERDLLEXP agg::scanline_u8;
00107 #endif
00108
00109 typedef agg::order_rgba wxImageComponentOrder;
00110
00111
00112 typedef agg::rgba8 color_type;
00113 typedef agg::pixfmt_rgb24 PixFormat;
00114 typedef agg::blender_rgba<color_type, wxImageComponentOrder> Blender;
00115
00116 typedef agg::renderer_base<PixFormat> RendererBase;
00117
00118 typedef agg::renderer_scanline_aa_solid<RendererBase> RendererSolidAa;
00119
00120 typedef agg::renderer_scanline_bin_solid<RendererBase> RendererSolidBin;
00121
00122 typedef agg::renderer_outline_aa<RendererBase> RendererOutlineAa;
00123 typedef agg::rasterizer_outline_aa<RendererOutlineAa> RasterOutLineAa;
00124
00125 #include "agg_pixfmt_rgba.h"
00126
00127
00128 #if defined(__WXMSW__)
00129 typedef agg::pixfmt_bgra32 PixFormatA;
00130 typedef agg::order_bgra ComponentOrder;
00131 #else
00132 typedef agg::pixfmt_rgba32 PixFormatA;
00133 typedef agg::order_rgba ComponentOrder;
00134 #endif
00135 typedef agg::comp_op_adaptor_rgba<color_type, ComponentOrder> BlenderCompA;
00136 typedef agg::pixfmt_custom_blend_rgba<BlenderCompA,agg::rendering_buffer> PixFormatComp;
00137
00138 typedef agg::renderer_base<PixFormatA> RendererBaseA;
00139 typedef agg::renderer_base<PixFormatComp> RendererBaseComp;
00140
00141 typedef agg::renderer_scanline_aa_solid<RendererBaseA> RendererSolidAaA;
00142 typedef agg::renderer_scanline_aa_solid<RendererBaseComp> RendererSolidComp;
00143
00144 typedef agg::renderer_scanline_bin_solid<RendererBase> RendererSolidBin;
00145
00146 typedef agg::renderer_outline_aa<RendererBaseA> RendererOutlineAaA;
00147 typedef agg::rasterizer_outline_aa<RendererOutlineAaA> RasterOutLineAaA;
00148
00149 typedef agg::pod_auto_array<color_type, 256> GradientArray;
00150
00151 typedef agg::span_gradient<color_type, agg::span_interpolator_linear<>, agg::gradient_x, GradientArray> LinearGradientSpan;
00152 typedef agg::span_gradient<color_type, agg::span_interpolator_linear<>, agg::gradient_circle, GradientArray> RadialGradientSpan;
00153
00154 typedef agg::span_allocator<agg::rgba8> span_allocator_type;
00155
00156 typedef agg::renderer_scanline_aa<RendererBase,
00157 span_allocator_type,
00158 LinearGradientSpan> RendererLinearGradient;
00159 typedef agg::renderer_scanline_aa<RendererBase,
00160 span_allocator_type,
00161 RadialGradientSpan> RendererRadialGradient;
00162
00163 typedef agg::renderer_scanline_aa<RendererBaseA,
00164 span_allocator_type,
00165 LinearGradientSpan> RendererLinearGradientA;
00166 typedef agg::renderer_scanline_aa<RendererBaseA,
00167 span_allocator_type,
00168 RadialGradientSpan> RendererRadialGradientA;
00169
00170 typedef agg::renderer_scanline_aa<RendererBaseComp,
00171 span_allocator_type,
00172 LinearGradientSpan> RendererLinearGradientComp;
00173 typedef agg::renderer_scanline_aa<RendererBaseComp,
00174 span_allocator_type,
00175 RadialGradientSpan> RendererRadialGradientComp;
00176
00177 static const char *HORIZONTAL_HATCH_XPM[] = {
00178 "32 32 2 1 0 0",
00179 " c #000000",
00180 "! c #FFFFFF",
00181 " ",
00182 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00183 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00184 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00185 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00186 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00187 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00188 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00189 " ",
00190 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00191 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00192 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00193 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00194 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00195 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00196 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00197 " ",
00198 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00199 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00200 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00201 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00202 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00203 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00204 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00205 " ",
00206 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00207 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00208 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00209 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00210 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00211 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
00212 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
00213 };
00214
00215 static const char *VERTICAL_HATCH_XPM[] = {
00216 "32 32 2 1 0 0",
00217 " c #000000",
00218 "! c #FFFFFF",
00219 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00220 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00221 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00222 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00223 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00224 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00225 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00226 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00227 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00228 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00229 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00230 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00231 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00232 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00233 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00234 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00235 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00236 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00237 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00238 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00239 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00240 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00241 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00242 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00243 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00244 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00245 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00246 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00247 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00248 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00249 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00250 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!"
00251 };
00252
00253 static const char *FDIAGONAL_HATCH_XPM[] = {
00254 "32 32 2 1 0 0",
00255 " c #000000",
00256 "! c #FFFFFF",
00257 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00258 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00259 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00260 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00261 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00262 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00263 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00264 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00265 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00266 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00267 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00268 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00269 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00270 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00271 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00272 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00273 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00274 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00275 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00276 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00277 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00278 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00279 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00280 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00281 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00282 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00283 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00284 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00285 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00286 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00287 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00288 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! "
00289 };
00290
00291 static const char *BDIAGONAL_HATCH_XPM[] = {
00292 "32 32 2 1 0 0",
00293 " c #000000",
00294 "! c #FFFFFF",
00295 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00296 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00297 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00298 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00299 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00300 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00301 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00302 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00303 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00304 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00305 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00306 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00307 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00308 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00309 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00310 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00311 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00312 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00313 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00314 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00315 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00316 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00317 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00318 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00319 "!!!!!!! !!!!!!! !!!!!!! !!!!!!! ",
00320 "!!!!!! !!!!!!! !!!!!!! !!!!!!! !",
00321 "!!!!! !!!!!!! !!!!!!! !!!!!!! !!",
00322 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00323 "!!! !!!!!!! !!!!!!! !!!!!!! !!!!",
00324 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00325 "! !!!!!!! !!!!!!! !!!!!!! !!!!!!",
00326 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!"
00327 };
00328
00329 static const char *CROSSDIAG_HATCH_XPM[] = {
00330 "32 32 2 1 0 0",
00331 " c #000000",
00332 "! c #FFFFFF",
00333 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00334 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00335 "!! !!! !!! !!! !!! !!! !!! !!! !",
00336 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00337 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00338 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00339 "!! !!! !!! !!! !!! !!! !!! !!! !",
00340 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00341 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00342 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00343 "!! !!! !!! !!! !!! !!! !!! !!! !",
00344 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00345 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00346 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00347 "!! !!! !!! !!! !!! !!! !!! !!! !",
00348 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00349 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00350 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00351 "!! !!! !!! !!! !!! !!! !!! !!! !",
00352 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00353 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00354 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00355 "!! !!! !!! !!! !!! !!! !!! !!! !",
00356 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00357 " !!!!!!! !!!!!!! !!!!!!! !!!!!!!",
00358 "! !!!!! ! !!!!! ! !!!!! ! !!!!! ",
00359 "!! !!! !!! !!! !!! !!! !!! !!! !",
00360 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00361 "!!!! !!!!!!! !!!!!!! !!!!!!! !!!",
00362 "!!! ! !!!!! ! !!!!! ! !!!!! ! !!",
00363 "!! !!! !!! !!! !!! !!! !!! !!! !",
00364 "! !!!!! ! !!!!! ! !!!!! ! !!!!! "
00365 };
00366
00367 static const char *CROSS_HATCH_XPM[] = {
00368 "32 32 2 1 0 0",
00369 " c #000000",
00370 "! c #FFFFFF",
00371 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00372 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00373 " ",
00374 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00375 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00376 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00377 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00378 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00379 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00380 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00381 " ",
00382 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00383 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00384 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00385 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00386 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00387 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00388 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00389 " ",
00390 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00391 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00392 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00393 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00394 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00395 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00396 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00397 " ",
00398 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00399 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00400 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00401 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!",
00402 "!! !!!!!!! !!!!!!! !!!!!!! !!!!!"
00403 };
00404
00405 typedef agg::rasterizer_scanline_aa<> RasterizerType;
00406 typedef RendererSolidAa RendererType;
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 template<class VertexSource> class noop_conv_transform
00418 {
00419 public:
00420 noop_conv_transform(VertexSource& source, int) : m_source(source) {}
00421
00422 void rewind(unsigned path_id)
00423 {
00424 m_source.rewind(path_id);
00425 }
00426
00427 unsigned vertex(double* x, double* y)
00428 {
00429 return m_source.vertex(x, y);
00430 }
00431
00432 void transformer(void *) {}
00433
00434 private:
00435 noop_conv_transform(const noop_conv_transform<VertexSource>&);
00436 const noop_conv_transform<VertexSource>&
00437 operator = (const noop_conv_transform<VertexSource>&);
00438 VertexSource& m_source;
00439 };
00440
00441 class A2DAGGDRAWERDLLEXP a2dAggDrawerBase : public a2dDrawer2D
00442 {
00443
00444 public:
00445
00446 a2dAggDrawerBase( int width = 0, int height = 0 );
00447
00448
00449 a2dAggDrawerBase( const wxSize& size );
00450
00451
00452
00453 a2dAggDrawerBase( const wxBitmap& bitmap );
00454
00455
00456 a2dAggDrawerBase( const a2dAggDrawerBase& other );
00457
00458 bool HasAlpha() { return true; }
00459
00460 void SetPreStroke( bool preStroke ) { m_preStroke = preStroke; }
00461
00462 bool GetPreStroke() { return m_preStroke; }
00463
00464 void ResetStyle();
00465
00466 void SetClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00467
00468 virtual void ExtendClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE, a2dBooleanClip clipoperation = a2dCLIP_AND );
00469
00470 virtual void ExtendAndPushClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE, a2dBooleanClip clipoperation = a2dCLIP_AND );
00471
00472 void PopClippingRegion();
00473
00474 void SetClippingRegionDev( wxCoord minx, wxCoord miny, wxCoord width, wxCoord height );
00475
00476 void SetClippingRegion( double minx, double miny, double maxx, double maxy );
00477
00478 void DestroyClippingRegion();
00479
00480 void BlitBuffer( wxRect rect, const wxPoint& bufferpos = wxPoint(0,0) );
00481
00482 void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint(0,0) ) = 0;
00483
00484 virtual void DrawCircle( double x, double y, double radius );
00485
00486 void DrawPoint( double xc, double yc );
00487
00488
00489 virtual void BeginDraw();
00490
00491
00492 virtual void EndDraw();
00493
00494 wxDC* GetDeviceDC() const { return m_deviceDC; }
00495
00496 virtual void DrawRoundedRectangle( double x, double y, double width, double height, double radius, bool pixelsize = false );
00497
00498 virtual void DrawEllipse( double x, double y, double width, double height);
00499
00500
00501 virtual void DrawPolygon( a2dVertexArray* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00502
00503
00504 virtual void DrawPolygon( const a2dVertexList* list, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00505
00506
00507 virtual void DrawPolyPolygon( a2dListOfa2dVertexList polylist, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00508
00509
00510 virtual void DrawLines( a2dVertexArray* points, bool spline = false );
00511
00512
00513 virtual void DrawLines( const a2dVertexList* list, bool spline = false );
00514
00515 protected:
00516
00517
00518 virtual void DrawCharDc( wxChar c );
00519
00520 virtual void DrawCharStroke( wxChar c );
00521
00522 virtual void DrawCharFreetype( wxChar c );
00523
00524 void ShiftBufferInternal( int dxy, bool yshift, int bytesPerPixel );
00525
00526 template <class PathT>
00527 void _ras_add_stroked_path_xform(PathT &path, const agg::trans_affine &mtx);
00528
00529 virtual void Render( bool fillColor ) = 0;
00530 virtual void RenderGradient( bool radial ) = 0;
00531 virtual void RenderBitmapFill() = 0;
00532 virtual void RenderSetClip() = 0;
00533
00534 agg::trans_affine _get_agg_user_to_device_transform() const;
00535
00536 void DoSetDrawStyle( a2dDrawStyle drawstyle );
00537
00538 void DoSetActiveStroke();
00539
00540 void DoSetActiveFill();
00541
00542 int ToAggPath( a2dVertexArray* points, bool transform );
00543 int ToAggPath( const a2dVertexList *list, bool transform );
00544
00545 bool m_preStroke;
00546
00547 wxRegion m_clip;
00548
00549 wxClientDC* m_deviceDC;
00550
00551 bool m_ownsBuffer;
00552
00553 RasterizerType m_rasterizer;
00554 agg::comp_op_e m_blendMode;
00555
00556 double m_strokewidth;
00557 double m_strokewidthDev;
00558 a2dStrokeStyle m_style;
00559
00560 agg::line_join_e m_join;
00561
00562 agg::line_cap_e m_cap;
00563
00564 wxImage m_pattern;
00565 agg::rendering_buffer m_pattern_rbuf;
00566
00567 agg::scanline_u8 m_sl;
00568
00569 agg::path_storage m_path;
00570
00571 double m_fillGradientD1;
00572 double m_lineGradientD1;
00573 double m_fillGradientD2;
00574 double m_lineGradientD2;
00575 GradientArray m_fillGradient;
00576 GradientArray m_lineGradient;
00577 agg::trans_affine m_fillGradientMatrix;
00578 agg::trans_affine m_lineGradientMatrix;
00579 agg::span_interpolator_linear<> m_fillGradientInterpolator;
00580 agg::span_interpolator_linear<> m_lineGradientInterpolator;
00581
00582 agg::gradient_x m_linearGradientFunction;
00583 agg::gradient_circle m_radialGradientFunction;
00584
00585 unsigned char* m_pdata;
00586 };
00587
00588
00589
00590
00591
00592
00593
00594
00595 class A2DAGGDRAWERDLLEXP a2dAggDrawer : public a2dAggDrawerBase
00596 {
00597 DECLARE_DYNAMIC_CLASS(a2dAggDrawer)
00598
00599 public:
00600
00601
00602 a2dAggDrawer( int width = 0, int height = 0 );
00603
00604
00605 a2dAggDrawer( const wxSize& size );
00606
00607
00608
00609 a2dAggDrawer( const wxBitmap& bitmap );
00610
00611
00612 a2dAggDrawer( const a2dAggDrawer& other );
00613
00614
00615 wxBitmap GetBuffer() const;
00616
00617
00618 wxImage& GetImageBuffer() { return m_buffer; }
00619
00620
00621 void SetBufferSize( int w, int h );
00622
00623
00624 wxBitmap GetSubBitmap( wxRect sub_rect ) const;
00625
00626 void CopyIntoBuffer( const wxBitmap& bitm );
00627
00628 virtual ~a2dAggDrawer();
00629
00630 void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint(0,0) );
00631
00632 void ShiftBuffer( int dxy, bool yshift );
00633
00634 void DrawImage( const wxImage& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00635
00636 void DrawImage( const a2dImageRGBA& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00637
00638 protected:
00639
00640 void Render( bool fillColor );
00641 virtual void RenderGradient( bool radial );
00642 virtual void RenderBitmapFill();
00643 virtual void RenderSetClip();
00644
00645 wxImage m_buffer;
00646
00647 bool m_needbufferupdate;
00648
00649 private:
00650
00651 PixFormat m_pixFormat;
00652 RendererBase m_renBase;
00653 RendererType m_renderer;
00654
00655 agg::rendering_buffer m_rendering_buffer;
00656
00657 };
00658
00659
00660
00661
00662
00663
00664
00665
00666 class A2DAGGDRAWERDLLEXP a2dAggDrawerRgba : public a2dAggDrawerBase
00667 {
00668 DECLARE_DYNAMIC_CLASS(a2dAggDrawerRgba)
00669
00670 public:
00671
00672
00673 a2dAggDrawerRgba( int width = 0, int height = 0 );
00674
00675
00676 a2dAggDrawerRgba( const wxSize& size );
00677
00678
00679
00680 a2dAggDrawerRgba( const wxBitmap& bitmap );
00681
00682
00683 a2dAggDrawerRgba( const a2dAggDrawerRgba& other );
00684
00685
00686 wxBitmap GetBuffer() const;
00687
00688
00689 wxImage GetImageBuffer() const;
00690
00691
00692 void SetBufferSize( int w, int h );
00693
00694
00695 wxBitmap GetSubBitmap( wxRect sub_rect ) const;
00696
00697 void CopyIntoBuffer( const wxBitmap& bitm );
00698
00699 virtual ~a2dAggDrawerRgba();
00700
00701 void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint(0,0) );
00702
00703 void ShiftBuffer( int dxy, bool yshift );
00704
00705 void DrawImage( const wxImage& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00706
00707 void DrawImage( const a2dImageRGBA& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00708
00709 protected:
00710
00711 void DoSetDrawStyle( a2dDrawStyle drawstyle );
00712
00713
00714 void Render( bool fillColor );
00715 virtual void RenderGradient( bool radial );
00716 virtual void RenderBitmapFill();
00717 virtual void RenderSetClip();
00718
00719 a2dImageRGBA m_buffer;
00720
00721 bool m_needbufferupdate;
00722
00723 private:
00724
00725 PixFormatA m_pixFormat;
00726 PixFormatComp m_pixFormatComp;
00727 RendererBaseA m_renBase;
00728 RendererBaseComp m_renBaseComp;
00729 RendererSolidComp m_renSolidComp;
00730 RendererSolidAaA m_renderer;
00731
00732 agg::rendering_buffer m_rendering_buffer;
00733
00734 };
00735
00736 namespace
00737 {
00738
00739
00740 class span_conv_const_alpha_rgba8
00741 {
00742 public:
00743 typedef agg::rgba8 color_type;
00744 typedef agg::int8u alpha_type;
00745
00746 span_conv_const_alpha_rgba8(alpha_type a) :
00747 m_alpha(a){}
00748
00749 void alpha(alpha_type a) { m_alpha = a; }
00750 alpha_type alpha() const { return m_alpha; }
00751
00752 void prepare() {}
00753 void generate(color_type* colors, int x, int y, unsigned len) const
00754 {
00755 do
00756 {
00757 colors->a = colors->a * m_alpha/255 ;
00758 ++colors;
00759 }
00760 while(--len);
00761 }
00762
00763 private:
00764 alpha_type m_alpha;
00765 };
00766
00767
00768 class span_conv_array_alpha_rgba8
00769 {
00770 public:
00771 typedef agg::rgba8 color_type;
00772 typedef agg::int8u alpha_type;
00773
00774 span_conv_array_alpha_rgba8( const wxImage& image, alpha_type a) :
00775 m_image(image), m_alpha(a) {}
00776
00777 void prepare() {}
00778 void generate(color_type* colors, int x, int y, unsigned len) const
00779 {
00780 do
00781 {
00782 colors->a = m_image.GetAlpha(x++,y) * m_alpha/255;
00783 ++colors;
00784 }
00785 while(--len);
00786 }
00787
00788 private:
00789 alpha_type m_alpha;
00790 wxImage m_image;
00791 };
00792
00793
00794 }
00795
00796
00797 namespace agg
00798 {
00799
00800
00801 template<> struct gradient_linear_color<rgba8>
00802 {
00803 typedef rgba8 color_type;
00804
00805 gradient_linear_color() {}
00806 gradient_linear_color(const color_type& c1, const color_type& c2) :
00807 m_c1(c1), m_c2(c2) {}
00808
00809 color_type operator [] (unsigned v) const
00810 {
00811 color_type c;
00812 c.r = (int8u)((((m_c2.r - m_c1.r) * int(v)) + (m_c1.r << 8)) >> 8);
00813 c.g = (int8u)((((m_c2.g - m_c1.g) * int(v)) + (m_c1.g << 8)) >> 8);
00814 c.b = (int8u)((((m_c2.b - m_c1.b) * int(v)) + (m_c1.b << 8)) >> 8);
00815 c.a = (int8u)((((m_c2.a - m_c1.a) * int(v)) + (m_c1.a << 8)) >> 8);
00816 return c;
00817 }
00818
00819 void colors(const color_type& c1, const color_type& c2)
00820 {
00821 m_c1 = c1;
00822 m_c2 = c2;
00823 }
00824
00825 color_type m_c1;
00826 color_type m_c2;
00827 };
00828
00829
00830 template<class Source> class span_pattern_a2d
00831 {
00832 public:
00833 typedef Source source_type;
00834 typedef typename source_type::color_type color_type;
00835 typedef typename source_type::order_type order_type;
00836 typedef typename color_type::value_type value_type;
00837 typedef typename color_type::calc_type calc_type;
00838
00839
00840 span_pattern_a2d() {}
00841 span_pattern_a2d(source_type& src,
00842 unsigned offset_x, unsigned offset_y) :
00843 m_src(&src),
00844 m_offset_x(offset_x),
00845 m_offset_y(offset_y),
00846 m_alpha(color_type::base_mask)
00847 {}
00848
00849
00850 void attach(source_type& v) { m_src = &v; }
00851 source_type& source() { return *m_src; }
00852 const source_type& source() const { return *m_src; }
00853
00854
00855 void offset_x(unsigned v) { m_offset_x = v; }
00856 void offset_y(unsigned v) { m_offset_y = v; }
00857 unsigned offset_x() const { return m_offset_x; }
00858 unsigned offset_y() const { return m_offset_y; }
00859 void alpha(value_type v) { m_alpha = v; }
00860 value_type alpha() const { return m_alpha; }
00861
00862
00863 void prepare() {}
00864 void generate(color_type* span, int x, int y, unsigned len)
00865 {
00866 x += m_offset_x;
00867 y += m_offset_y;
00868 const value_type* p = (const value_type*)m_src->span(x, y, len);
00869 do
00870 {
00871 span->r = p[order_type::R];
00872 span->g = p[order_type::G];
00873 span->b = p[order_type::B];
00874 if ( span->r == 255 && span->g == 255 && span->b == 255 )
00875 span->a = 0;
00876 else
00877 span->a = m_alpha;
00878 p = m_src->next_x();
00879 ++span;
00880 }
00881 while(--len);
00882 }
00883
00884 private:
00885 source_type* m_src;
00886 unsigned m_offset_x;
00887 unsigned m_offset_y;
00888 value_type m_alpha;
00889
00890 };
00891 }
00892
00893 class plain_rect
00894 {
00895 public:
00896 plain_rect() {}
00897 plain_rect(double x1, double y1, double x2, double y2) :
00898 m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2)
00899 {
00900 if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
00901 if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
00902 }
00903
00904 void rect(double x1, double y1, double x2, double y2)
00905 {
00906 m_x1 = x1; m_y1 = y1;m_x2 = x2; m_y2 = y2;
00907 if(x1 > x2) { m_x1 = x2; m_x2 = x1; }
00908 if(y1 > y2) { m_y1 = y2; m_y2 = y1; }
00909 }
00910 void rewind(unsigned) { m_status = 0;}
00911 unsigned vertex(double* x, double* y)
00912 {
00913 switch(m_status)
00914 {
00915 case 0:
00916 *x = m_x1; *y = m_y1;
00917 m_status++;
00918 return agg::path_cmd_move_to;
00919
00920 case 1:
00921 *x = m_x2; *y = m_y1;
00922 m_status++;
00923 return agg::path_cmd_line_to;
00924
00925 case 2:
00926 *x = m_x2; *y = m_y2;
00927 m_status++;
00928 return agg::path_cmd_line_to;
00929
00930 case 3:
00931 *x = m_x1; *y = m_y2;
00932 m_status++;
00933 return agg::path_cmd_line_to;
00934
00935 case 4:
00936 *x = m_x1; *y = m_y1;
00937 m_status++;
00938 return agg::path_cmd_line_to;
00939
00940 case 5:
00941 m_status++;
00942 return agg::path_cmd_end_poly | agg::path_flags_close | agg::path_flags_ccw;
00943 }
00944 return agg::path_cmd_stop;
00945 }
00946 private:
00947 double m_x1;
00948 double m_y1;
00949 double m_x2;
00950 double m_y2;
00951 unsigned m_status;
00952 };
00953
00954
00955 #endif
00956
00957 #endif