xref: /haiku/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaPCSUBPIX.h (revision 16d5c24e533eb14b7b8a99ee9f3ec9ba66335b1e)
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_ALPHA in "Pixel Composite" mode on B_RGBA32.
7  *
8  */
9 
10 #ifndef DRAWING_MODE_ALPHA_PC_SUBPIX_H
11 #define DRAWING_MODE_ALPHA_PC_SUBPIX_H
12 
13 #include "DrawingMode.h"
14 #include "GlobalSubpixelSettings.h"
15 
16 // BLEND_ALPHA_PC_SUBPIX
17 #define BLEND_ALPHA_PC_SUBPIX(d, r, g, b, a1, a2, a3) \
18 { \
19 	BLEND_COMPOSITE16_SUBPIX(d, r, g, b, a1, a2, a3); \
20 }
21 
22 
23 // blend_solid_hspan_alpha_pc_subpix
24 void
25 blend_solid_hspan_alpha_pc_subpix(int x, int y, unsigned len,
26 	const color_type& c, const uint8* covers, agg_buffer* buffer,
27 	const PatternHandler* pattern)
28 {
29 	uint8* p = buffer->row_ptr(y) + (x << 2);
30 	uint16 alphaRed;
31 	uint16 alphaGreen;
32 	uint16 alphaBlue;
33 	const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
34 	const int subpixelM = 1;
35 	const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
36 	do {
37 		rgb_color color = pattern->ColorAt(x, y);
38 		alphaRed = color.alpha * covers[subpixelL];
39 		alphaGreen = color.alpha * covers[subpixelM];
40 		alphaBlue = color.alpha * covers[subpixelR];
41 		BLEND_ALPHA_PC_SUBPIX(p, color.red, color.green, color.blue,
42 			alphaBlue, alphaGreen, alphaRed);
43 		covers += 3;
44 		p += 4;
45 		x++;
46 		len -= 3;
47 	} while (len);
48 }
49 
50 #endif // DRAWING_MODE_ALPHA_PC_SUBPIX_H
51 
52