17 #ifndef __WXAGGGRAPHICS_H__
18 #define __WXAGGGRAPHICS_H__
25 #include "a2dprivate.h"
27 #if wxART2D_USE_GRAPHICS_CONTEXT
28 #if wxART2D_USE_AGGDRAWER
46 class a2dAggContext :
public a2dContext
48 DECLARE_NO_COPY_CLASS( a2dAggContext )
51 a2dAggContext( wxGraphicsRenderer* renderer, const wxImage& drawable );
52 a2dAggContext( wxGraphicsRenderer* renderer,
a2dImageRGBA* drawable );
53 virtual ~a2dAggContext();
55 virtual
void Clip( const wxRegion& region );
58 virtual
void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
61 virtual
void ResetClip();
63 virtual
void Translate( wxDouble dx , wxDouble dy );
64 virtual
void Scale( wxDouble xScale , wxDouble yScale );
65 virtual
void Rotate( wxDouble angle );
68 virtual
void ConcatTransform( const wxGraphicsMatrix& matrix );
71 virtual
void SetTransform( const wxGraphicsMatrix& matrix );
74 virtual wxGraphicsMatrix GetTransform() const;
78 #if wxCHECK_VERSION(2,9,0)
79 virtual void DrawBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
81 virtual void DrawGraphicsBitmap(
const wxGraphicsBitmap& bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h );
84 virtual void GetTextExtent(
const wxString& str, wxDouble* width, wxDouble* height,
85 wxDouble* descent, wxDouble* externalLeading )
const;
86 virtual void GetPartialTextExtents(
const wxString& text, wxArrayDouble& widths )
const;
88 #if wxCHECK_VERSION(2,9,0)
89 bool SetCompositionMode( wxCompositionMode op );
93 virtual bool SetLogicalFunction(
int function ) ;
95 virtual void DrawCharDc( wxChar c );
96 virtual void DrawTextDc(
const wxString& text,
double x,
double y );
97 virtual void DrawCharStroke( wxChar c );
98 virtual void DrawCharFreetype( wxChar c );
100 void DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius );
101 void DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
103 void SetPreStroke(
bool preStroke ) { m_preStroke = preStroke; }
105 bool GetPreStroke() {
return m_preStroke; }
109 void Render(
bool fillColor );
110 virtual void RenderGradient(
bool radial );
111 virtual void RenderBitmapFill();
116 void DrawPolygon(
const a2dVertexList* list, wxPolygonFillMode fillStyle );
119 agg::trans_affine _get_agg_user_to_device_transform()
const
121 return agg::trans_affine(
122 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
123 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
124 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
128 virtual void DoSetActiveStroke();
131 virtual void DoSetActiveFill();
133 void DeviceDrawBitmap(
const wxBitmap& bmp,
double x,
double y,
bool useMask );
137 bool m_needbufferupdate;
139 wxClientDC* m_deviceDC;
142 PixFormatComp m_pixFormatComp;
144 RendererBaseComp m_renBaseComp;
145 RendererSolidComp m_renSolidComp;
147 agg::rasterizer_scanline_aa<> m_rasterizer;
148 agg::comp_op_e m_blendMode;
150 template <
class PathT>
151 void _ras_add_stroked_path_xform( PathT& path,
const agg::trans_affine& mtx );
153 unsigned char* m_pdata;
155 agg::rendering_buffer m_rendering_buffer;
157 double m_strokewidth;
158 double m_strokewidthDev;
164 agg::line_join_e m_join;
166 agg::line_cap_e m_cap;
169 agg::rendering_buffer m_pattern_rbuf;
171 agg::scanline_u8 m_sl;
173 void _stipple_render_scanlines( agg::rasterizer_scanline_aa<>& ras,
174 agg::scanline_u8& sl,
176 agg::rendering_buffer pat,
179 agg::path_storage m_path;
180 double m_fillGradientD1;
181 double m_lineGradientD1;
182 double m_fillGradientD2;
183 double m_lineGradientD2;
184 GradientArray m_fillGradient;
185 GradientArray m_lineGradient;
186 agg::trans_affine m_fillGradientMatrix;
187 agg::trans_affine m_lineGradientMatrix;
188 agg::span_interpolator_linear<> m_fillGradientInterpolator;
189 agg::span_interpolator_linear<> m_lineGradientInterpolator;
191 agg::gradient_x m_linearGradientFunction;
192 agg::gradient_circle m_radialGradientFunction;
203 class a2dGcAggDrawer :
public a2dGcBaseDrawer
205 DECLARE_DYNAMIC_CLASS( a2dGcAggDrawer )
210 a2dGcAggDrawer(
int width = 0,
int height = 0 );
213 a2dGcAggDrawer( const wxSize& size );
217 a2dGcAggDrawer( const wxBitmap& bitmap );
219 bool HasAlpha() {
return true; }
222 wxBitmap GetBuffer()
const;
225 a2dGcAggDrawer(
const a2dGcAggDrawer& other );
230 void SetBufferSize(
int w,
int h );
233 wxBitmap GetSubBitmap( wxRect sub_rect )
const;
235 void CopyIntoBuffer(
const wxBitmap& bitm );
237 virtual ~a2dGcAggDrawer();
239 virtual void SetYaxis(
bool up );
243 void BlitBuffer( wxDC* dc, wxRect rect,
const wxPoint& bufferpos = wxPoint( 0, 0 ) );
245 void ShiftBuffer(
int dxy,
bool yshift );
247 void DrawPoint(
double xc,
double yc );
249 void DrawImage(
const wxImage& image,
double x,
double y,
double width,
double height, wxUint8 Opacity = 255 );
251 void DrawImage(
const a2dImageRGBA& image,
double x,
double y,
double width,
double height, wxUint8 Opacity = 255 );
255 void DoSetActiveStroke();
257 void DoSetActiveFill();
259 void DoSetActiveFont(
const a2dFont& font );
264 unsigned char* m_pdata;
269 #endif //wxART2D_USE_GRAPHICS_CONTEXT
Stroke and fill base classes.
agg::renderer_scanline_aa_solid< RendererBaseA > RendererSolidAaA
solid rendering on top of base rendering Agg
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
vertex array of line and arc segments.
vertex list of line and arc segments.
a2dDrawStyle
Define the manner in which a2dCanvasView draws to the device.
classes for initializing the artbase modules, and set paths to be used for fonts etc.
the antigrain based drawing context derived from a2dDrawer2D
Drawing context abstraction.
agg::renderer_base< PixFormatA > RendererBaseA
base rendering Agg
the wxGraphicContext based drawing context
agg::pixfmt_rgba32 PixFormatA
color format in a2dAggDrawer
Contains image with RGBA per pixel.
a2dStrokeStyle
stroke styles for a2dStroke