1c8164642SStephan Aßmus /*
2c8164642SStephan Aßmus * Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
3c8164642SStephan Aßmus * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
4c8164642SStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License.
5c8164642SStephan Aßmus *
6c8164642SStephan Aßmus * DrawingMode implementing B_OP_ALPHA in "Constant Composite" mode on B_RGBA32.
7c8164642SStephan Aßmus *
8c8164642SStephan Aßmus */
9c8164642SStephan Aßmus
10c8164642SStephan Aßmus #ifndef DRAWING_MODE_ALPHA_CC_SUBPIX_H
11c8164642SStephan Aßmus #define DRAWING_MODE_ALPHA_CC_SUBPIX_H
12c8164642SStephan Aßmus
13c8164642SStephan Aßmus #include "DrawingMode.h"
14*59e13a3fSStephan Aßmus #include "GlobalSubpixelSettings.h"
15c8164642SStephan Aßmus
16c8164642SStephan Aßmus // BLEND_ALPHA_CC_SUBPIX
17c8164642SStephan Aßmus #define BLEND_ALPHA_CC_SUBPIX(d, r, g, b, a1, a2, a3) \
18c8164642SStephan Aßmus { \
19c8164642SStephan Aßmus BLEND_COMPOSITE16_SUBPIX(d, r, g, b, a1, a2, a3); \
20c8164642SStephan Aßmus }
21c8164642SStephan Aßmus
22c8164642SStephan Aßmus
23c8164642SStephan Aßmus // blend_solid_hspan_alpha_cc_subpix
24c8164642SStephan Aßmus void
blend_solid_hspan_alpha_cc_subpix(int x,int y,unsigned len,const color_type & c,const uint8 * covers,agg_buffer * buffer,const PatternHandler * pattern)25c8164642SStephan Aßmus blend_solid_hspan_alpha_cc_subpix(int x, int y, unsigned len,
26c8164642SStephan Aßmus const color_type& c, const uint8* covers, agg_buffer* buffer,
27c8164642SStephan Aßmus const PatternHandler* pattern)
28c8164642SStephan Aßmus {
29c8164642SStephan Aßmus uint8* p = buffer->row_ptr(y) + (x << 2);
30c8164642SStephan Aßmus uint8 hAlpha = pattern->HighColor().alpha;
31c8164642SStephan Aßmus uint16 alphaRed;
32c8164642SStephan Aßmus uint16 alphaGreen;
33c8164642SStephan Aßmus uint16 alphaBlue;
34*59e13a3fSStephan Aßmus const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
35*59e13a3fSStephan Aßmus const int subpixelM = 1;
36*59e13a3fSStephan Aßmus const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
37c8164642SStephan Aßmus do {
38*59e13a3fSStephan Aßmus alphaRed = hAlpha * covers[subpixelL];
39*59e13a3fSStephan Aßmus alphaGreen = hAlpha * covers[subpixelM];
40*59e13a3fSStephan Aßmus alphaBlue = hAlpha * covers[subpixelR];
41c8164642SStephan Aßmus rgb_color color = pattern->ColorAt(x, y);
42c8164642SStephan Aßmus BLEND_ALPHA_CC_SUBPIX(p, color.red, color.green, color.blue,
43c8164642SStephan Aßmus alphaBlue, alphaGreen, alphaRed);
44c8164642SStephan Aßmus covers += 3;
45c8164642SStephan Aßmus p += 4;
46c8164642SStephan Aßmus x++;
47c8164642SStephan Aßmus len -= 3;
48c8164642SStephan Aßmus } while (len);
49c8164642SStephan Aßmus }
50c8164642SStephan Aßmus
51c8164642SStephan Aßmus #endif // DRAWING_MODE_ALPHA_CC_SUBPIX_H
52c8164642SStephan Aßmus
53