8 #include <FontServer.h>
9 #include <ServerFont.h>
12 #include "forwarding_pixfmt.h"
16 class AGGTextRenderer
;
21 class RenderingBuffer
;
31 void AttachToBuffer(RenderingBuffer
* buffer
);
32 void DetachFromBuffer();
34 void ConstrainClipping(const BRegion
& region
);
35 void SetDrawData(const DrawData
* data
);
38 void SetHighColor(const rgb_color
& color
);
39 inline void SetHighColor(uint8 r
, uint8 g
, uint8 b
, uint8 a
= 255);
40 inline void SetHighColor(const RGBColor
& color
)
41 { SetHighColor(color
.GetColor32()); }
42 void SetLowColor(const rgb_color
& color
);
43 inline void SetLowColor(uint8 r
, uint8 g
, uint8 b
, uint8 a
= 255);
44 inline void SetLowColor(const RGBColor
& color
)
45 { SetLowColor(color
.GetColor32()); }
47 void SetScale(float scale
);
48 void SetPenSize(float size
);
49 void SetOrigin(const BPoint
& origin
);
50 void SetDrawingMode(drawing_mode mode
);
51 void SetBlendingMode(source_alpha alphaSrcMode
,
52 alpha_function alphaFncMode
);
53 void SetPenLocation(const BPoint
& location
);
54 void SetFont(const BFont
& font
);
55 void SetFont(const ServerFont
& font
);
57 // BView API compatibility (for easier testing)
59 inline void MovePenTo(const BPoint
& location
)
60 { SetPenLocation(location
); }
61 inline void SetFont(const BFont
* font
)
62 { if (font
) SetFont(*font
); }
67 BRect
StrokeLine( BPoint a
,
69 const pattern
& p
= B_SOLID_HIGH
);
71 BRect
StrokeLine( BPoint b
,
72 const pattern
& p
= B_SOLID_HIGH
);
74 // return true if the line was either vertical or horizontal
75 // draws a solid one pixel wide line of color c, no blending
76 bool StraightLine( BPoint a
,
78 const rgb_color
& c
) const;
81 void StrokeTriangle( BPoint pt1
,
84 const pattern
& p
= B_SOLID_HIGH
) const;
86 void FillTriangle( BPoint pt1
,
89 const pattern
& p
= B_SOLID_HIGH
) const;
92 void StrokePolygon( const BPoint
* ptArray
,
95 const pattern
& p
= B_SOLID_HIGH
) const;
97 void FillPolygon( const BPoint
* ptArray
,
100 const pattern
& p
= B_SOLID_HIGH
) const;
103 void StrokeBezier( const BPoint
* controlPoints
,
104 const pattern
& p
= B_SOLID_HIGH
) const;
106 void FillBezier( const BPoint
* controlPoints
,
107 const pattern
& p
= B_SOLID_HIGH
) const;
110 void StrokeShape( /*const */BShape
* shape
,
111 const pattern
& p
= B_SOLID_HIGH
) const;
113 void FillShape( /*const */BShape
* shape
,
114 const pattern
& p
= B_SOLID_HIGH
) const;
118 BRect
StrokeRect( const BRect
& r
,
119 const pattern
& p
= B_SOLID_HIGH
) const;
121 // strokes a one pixel wide solid rect, no blending
122 void StrokeRect( const BRect
& r
,
123 const rgb_color
& c
) const;
125 BRect
FillRect( const BRect
& r
,
126 const pattern
& p
= B_SOLID_HIGH
) const;
128 // fills a solid rect with color c, no blending
129 void FillRect( const BRect
& r
,
130 const rgb_color
& c
) const;
133 void StrokeRoundRect(const BRect
& r
,
136 const pattern
& p
= B_SOLID_HIGH
) const;
138 void FillRoundRect( const BRect
& r
,
141 const pattern
& p
= B_SOLID_HIGH
) const;
144 void StrokeEllipse( BPoint center
,
147 const pattern
& p
= B_SOLID_HIGH
) const;
149 void FillEllipse( BPoint center
,
152 const pattern
& p
= B_SOLID_HIGH
) const;
155 void StrokeArc( BPoint center
,
160 const pattern
& p
= B_SOLID_HIGH
) const;
162 void FillArc( BPoint center
,
167 const pattern
& p
= B_SOLID_HIGH
) const;
170 BRect
DrawChar( char aChar
);
172 BRect
DrawChar( char aChar
,
175 BRect
DrawString( const char* utf8String
,
177 const escapement_delta
* delta
= NULL
);
179 BRect
DrawString( const char* utf8String
,
182 const escapement_delta
* delta
= NULL
);
184 BRect
DrawString( const char* utf8String
,
185 const escapement_delta
* delta
= NULL
);
187 BRect
DrawString( const char* utf8String
,
189 const escapement_delta
* delta
= NULL
);
192 void DrawBitmap( const BBitmap
* bitmap
,
194 BRect viewRect
) const;
196 void DrawBitmap( const ServerBitmap
* bitmap
,
198 BRect viewRect
) const;
200 // some convenience stuff
201 void FillRegion( const BRegion
* region
,
202 const pattern
& p
= B_SOLID_HIGH
) const;
204 void InvertRect( const BRect
& r
) const;
206 BRect
BoundingBox( const char* utf8String
,
208 const BPoint
& baseLine
) const;
210 inline BRect
ClipRect(const BRect
& rect
) const
211 { return _Clipped(rect
); }
216 void _Transform(BPoint
* point
,
217 bool centerOffset
= true) const;
218 BPoint
_Transform(const BPoint
& point
,
219 bool centerOffset
= true) const;
220 void _Transform(float* width
) const;
221 float _Transform(const float& width
) const;
222 void _Transform(BRect
* rect
) const;
223 BRect
_Transform(const BRect
& rect
) const;
224 BRect
_Clipped(const BRect
& rect
) const;
226 void _RebuildClipping();
229 void _UpdateLineWidth();
231 // drawing functions stroke/fill
232 void _DrawTriangle( BPoint pt1
,
237 void _DrawEllipse( BPoint center
,
242 void _DrawShape( /*const */BShape
* shape
,
245 void _DrawPolygon( const BPoint
* ptArray
,
251 void _DrawBitmap( const agg::rendering_buffer
& srcBuffer
,
253 BRect actualBitmapRect
,
255 BRect viewRect
) const;
256 void _DrawBitmap32( const agg::rendering_buffer
& srcBuffer
,
257 BRect actualBitmapRect
,
259 BRect viewRect
) const;
261 void _InvertRect32(BRect r
) const;
264 template<class VertexSource
>
265 BRect
_BoundingBox(VertexSource
& path
) const;
267 template<class VertexSource
>
268 BRect
_StrokePath(VertexSource
& path
,
269 const pattern
& p
) const;
270 template<class VertexSource
>
271 BRect
_FillPath(VertexSource
& path
,
273 const pattern
& p
) const;
275 void _SetPattern(const pattern
& p
) const;
276 void _SetRendererColor(const rgb_color
& color
) const;
278 agg::rendering_buffer
* fBuffer
;
280 // AGG rendering and rasterization classes
281 pixfmt
* fPixelFormat
;
282 renderer_base
* fBaseRenderer
;
284 outline_renderer_type
* fOutlineRenderer
;
285 outline_rasterizer_type
* fOutlineRasterizer
;
287 scanline_type
* fScanline
;
288 rasterizer_type
* fRasterizer
;
289 renderer_type
* fRenderer
;
291 font_renderer_solid_type
* fFontRendererSolid
;
292 font_renderer_bin_type
* fFontRendererBin
;
294 agg::line_profile_aa fLineProfile
;
296 // for internal coordinate rounding/transformation,
297 // does not concern rendering
298 bool fSubpixelPrecise
;
303 BRegion
* fClippingRegion
; // NULL indicates no clipping at all
304 drawing_mode fDrawingMode
;
305 source_alpha fAlphaSrcMode
;
306 alpha_function fAlphaFncMode
;
308 PatternHandler
* fPatternHandler
;
311 // a class handling rendering and caching of glyphs
312 // it is setup to load from a specific Freetype supported
313 // font file, it uses the FontManager to locate a file
314 // by Family and Style
315 AGGTextRenderer
* fTextRenderer
;
316 uint32 fLastFamilyAndStyle
;
321 Painter::SetHighColor(uint8 r
, uint8 g
, uint8 b
, uint8 a
)
333 Painter::SetLowColor(uint8 r
, uint8 g
, uint8 b
, uint8 a
)