xref: /haiku/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAddSUBPIX.h (revision b06a48ab8f30b45916a9c157b992827779182163)
1 /*
2  * Copyright 2005, 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  * DrawingMode implementing B_OP_ADD on B_RGBA32.
7  *
8  */
9 
10 #ifndef DRAWING_MODE_ADD_SUBPIX_H
11 #define DRAWING_MODE_ADD_SUBPIX_H
12 
13 #include "DrawingMode.h"
14 #include "GlobalSubpixelSettings.h"
15 
16 // BLEND_ADD_SUBPIX
17 #define BLEND_ADD_SUBPIX(d, r, g, b, a1, a2, a3) \
18 { \
19 	pixel32 _p; \
20 	_p.data32 = *(uint32*)d; \
21 	uint8 rt = min_c(255, _p.data8[2] + (r)); \
22 	uint8 gt = min_c(255, _p.data8[1] + (g)); \
23 	uint8 bt = min_c(255, _p.data8[0] + (b)); \
24 	BLEND_SUBPIX(d, rt, gt, bt, a1, a2, a3); \
25 }
26 
27 
28 // blend_solid_hspan_add_subpix
29 void
30 blend_solid_hspan_add_subpix(int x, int y, unsigned len, const color_type& c,
31 	const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
32 {
33 	const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
34 	const int subpixelM = 1;
35 	const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
36 	uint8* p = buffer->row_ptr(y) + (x << 2);
37 	do {
38 		rgb_color color = pattern->ColorAt(x, y);
39 		BLEND_ADD_SUBPIX(p, color.red, color.green, color.blue,
40 			covers[subpixelL], covers[subpixelM], covers[subpixelR]);
41 		covers += 3;
42 		p += 4;
43 		x++;
44 		len -= 3;
45 	} while (len);
46 }
47 
48 
49 #endif // DRAWING_MODE_ADD_SUBPIX_H
50 
51