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_MIN on B_RGBA32.
7 *
8 */
9
10 #ifndef DRAWING_MODE_MIN_SUBPIX_H
11 #define DRAWING_MODE_MIN_SUBPIX_H
12
13 #include "DrawingMode.h"
14 #include "GlobalSubpixelSettings.h"
15
16 // BLEND_MIN_SUBPIX
17 #define BLEND_MIN_SUBPIX(d, r, g, b, a1, a2, a3) \
18 { \
19 pixel32 _p; \
20 _p.data32 = *(uint32*)d; \
21 if (brightness_for((r), (g), (b)) \
22 < brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
23 BLEND_SUBPIX(d, (r), (g), (b), a1, a2, a3); \
24 } \
25 }
26
27
28 // blend_solid_hspan_min_subpix
29 void
blend_solid_hspan_min_subpix(int x,int y,unsigned len,const color_type & c,const uint8 * covers,agg_buffer * buffer,const PatternHandler * pattern)30 blend_solid_hspan_min_subpix(int x, int y, unsigned len, const color_type& c,
31 const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
32 {
33 uint8* p = buffer->row_ptr(y) + (x << 2);
34 const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
35 const int subpixelM = 1;
36 const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
37 do {
38 rgb_color color = pattern->ColorAt(x, y);
39 BLEND_MIN_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 #endif // DRAWING_MODE_MIN_SUBPIX_H
49
50