xref: /haiku/src/servers/app/drawing/Painter/AGGTextRenderer.h (revision 71452e98334eaac603bf542d159e24788a46bebb)
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&
31 										subpixScanline,
32 									rasterizer_subpix_type& subpixRasterizer,
33 									scanline_unpacked_masked_type*&
34 										maskedScanline,
35 									agg::trans_affine& viewTransformation);
36 	virtual						~AGGTextRenderer();
37 
38 			void				SetFont(const ServerFont &font);
39 	inline	const ServerFont&	Font() const
40 									{ return fFont; }
41 
42 			void				SetHinting(bool hinting);
43 			bool				Hinting() const
44 									{ return fHinted; }
45 
46 			void				SetAntialiasing(bool antialiasing);
47 			bool				Antialiasing() const
48 									{ return fAntialias; }
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 			BRect				RenderString(const char* utf8String,
58 									uint32 length, const BPoint* offsets,
59 									const BRect& clippingFrame, bool dryRun,
60 									BPoint* nextCharPos,
61 									FontCacheReference* cacheReference);
62 
63 private:
64 
65 	class StringRenderer;
66 	friend class StringRenderer;
67 
68 	// Pipeline to process the vectors glyph paths (curves + contour)
69 	FontCacheEntry::GlyphPathAdapter	fPathAdaptor;
70 	FontCacheEntry::GlyphGray8Adapter	fGray8Adaptor;
71 	FontCacheEntry::GlyphGray8Scanline	fGray8Scanline;
72 	FontCacheEntry::GlyphMonoAdapter	fMonoAdaptor;
73 	FontCacheEntry::GlyphMonoScanline	fMonoScanline;
74 	FontCacheEntry::SubpixAdapter		fSubpixAdaptor;
75 
76 	FontCacheEntry::CurveConverter		fCurves;
77 	FontCacheEntry::ContourConverter	fContour;
78 
79 	renderer_type&				fSolidRenderer;
80 	renderer_bin_type&			fBinRenderer;
81 	renderer_subpix_type&		fSubpixRenderer;
82 	scanline_unpacked_type&		fScanline;
83 	scanline_unpacked_subpix_type& fSubpixScanline;
84 	rasterizer_subpix_type&		fSubpixRasterizer;
85 	scanline_unpacked_masked_type*& fMaskedScanline;
86 
87 	rasterizer_type				fRasterizer;
88 		// NOTE: the object has it's own rasterizer object
89 		// since it might be using a different gamma setting
90 		// to support non-anti-aliased text rendering
91 
92 	ServerFont					fFont;
93 	bool						fHinted;
94 									// is glyph hinting active?
95 	bool						fAntialias;
96 	Transformable				fEmbeddedTransformation;
97 									// rotated or sheared font?
98 	agg::trans_affine&			fViewTransformation;
99 };
100 
101 #endif // AGG_TEXT_RENDERER_H
102