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 "Constant Composite" mode on B_RGBA32.
7 *
8 */
9
10 #ifndef DRAWING_MODE_ALPHA_CC_SUBPIX_H
11 #define DRAWING_MODE_ALPHA_CC_SUBPIX_H
12
13 #include "DrawingMode.h"
14 #include "GlobalSubpixelSettings.h"
15
16 // BLEND_ALPHA_CC_SUBPIX
17 #define BLEND_ALPHA_CC_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_cc_subpix
24 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)25 blend_solid_hspan_alpha_cc_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 uint8 hAlpha = pattern->HighColor().alpha;
31 uint16 alphaRed;
32 uint16 alphaGreen;
33 uint16 alphaBlue;
34 const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
35 const int subpixelM = 1;
36 const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
37 do {
38 alphaRed = hAlpha * covers[subpixelL];
39 alphaGreen = hAlpha * covers[subpixelM];
40 alphaBlue = hAlpha * covers[subpixelR];
41 rgb_color color = pattern->ColorAt(x, y);
42 BLEND_ALPHA_CC_SUBPIX(p, color.red, color.green, color.blue,
43 alphaBlue, alphaGreen, alphaRed);
44 covers += 3;
45 p += 4;
46 x++;
47 len -= 3;
48 } while (len);
49 }
50
51 #endif // DRAWING_MODE_ALPHA_CC_SUBPIX_H
52
53