xref: /haiku/src/servers/app/drawing/Painter/AGGTextRenderer.h (revision b6b0567fbd186f8ce8a0c90bdc7a7b5b4c649678)
1 /*
2  * Copyright 2005-2009, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
4  * All rights reserved. Distributed under the terms of the MIT License.
5  */
6 #ifndef AGG_TEXT_RENDERER_H
7 #define AGG_TEXT_RENDERER_H
8 
9 
10 #include "defines.h"
11 
12 #include "FontCacheEntry.h"
13 #include "ServerFont.h"
14 #include "Transformable.h"
15 
16 #include <agg_conv_curve.h>
17 #include <agg_conv_contour.h>
18 #include <agg_scanline_u.h>
19 
20 
21 class FontCacheReference;
22 
23 class AGGTextRenderer {
24 public:
25 								AGGTextRenderer(
26 									renderer_subpix_type& subpixRenderer,
27 									renderer_type& solidRenderer,
28 									renderer_bin_type& binRenderer,
29 									scanline_unpacked_type& scanline,
30 									scanline_unpacked_subpix_type& subpixScanline,
31 									rasterizer_subpix_type& subpixRasterizer);
32 	virtual						~AGGTextRenderer();
33 
34 			void				SetFont(const ServerFont &font);
35 	inline	const ServerFont&	Font() const
36 									{ return fFont; }
37 
38 			void				SetHinting(bool hinting);
39 			bool				Hinting() const
40 									{ return fHinted; }
41 
42 			void				SetAntialiasing(bool antialiasing);
43 			bool				Antialiasing() const
44 									{ return fAntialias; }
45 
46 			void				SetKerning(bool kerning);
47 			bool				Kerning() const
48 									{ return fKerning; }
49 
50 			BRect				RenderString(const char* utf8String,
51 									uint32 length, const BPoint& baseLine,
52 									const BRect& clippingFrame, bool dryRun,
53 									BPoint* nextCharPos,
54 									const escapement_delta* delta,
55 									FontCacheReference* cacheReference);
56 
57 private:
58 
59 	class StringRenderer;
60 	friend class StringRenderer;
61 
62 	// Pipeline to process the vectors glyph paths (curves + contour)
63 	FontCacheEntry::GlyphPathAdapter	fPathAdaptor;
64 	FontCacheEntry::GlyphGray8Adapter	fGray8Adaptor;
65 	FontCacheEntry::GlyphGray8Scanline	fGray8Scanline;
66 	FontCacheEntry::GlyphMonoAdapter	fMonoAdaptor;
67 	FontCacheEntry::GlyphMonoScanline	fMonoScanline;
68 	FontCacheEntry::SubpixAdapter		fSubpixAdaptor;
69 
70 	FontCacheEntry::CurveConverter		fCurves;
71 	FontCacheEntry::ContourConverter	fContour;
72 
73 	renderer_type&				fSolidRenderer;
74 	renderer_bin_type&			fBinRenderer;
75 	renderer_subpix_type&		fSubpixRenderer;
76 	scanline_unpacked_type&		fScanline;
77 	scanline_unpacked_subpix_type& fSubpixScanline;
78 	rasterizer_subpix_type&		fSubpixRasterizer;
79 	rasterizer_type				fRasterizer;
80 		// NOTE: the object has it's own rasterizer object
81 		// since it might be using a different gamma setting
82 		// to support non-anti-aliased text rendering
83 
84 	ServerFont					fFont;
85 	bool						fHinted;
86 									// is glyph hinting active?
87 	bool						fAntialias;
88 	bool						fKerning;
89 	Transformable				fEmbeddedTransformation;
90 									// rotated or sheared font?
91 };
92 
93 #endif // AGG_TEXT_RENDERER_H
94