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_COPY on B_RGBA32.
7 *
8 */
9
10#ifndef DRAWING_MODE_COPY_SUBPIX_H
11#define DRAWING_MODE_COPY_SUBPIX_H
12
13#include "DrawingMode.h"
14#include "GlobalSubpixelSettings.h"
15
16// BLEND_COPY_SUBPIX
17#define BLEND_COPY_SUBPIX(d, r2, g2, b2, a1, a2, a3, r1, g1, b1) \
18{ \
19	BLEND_FROM_SUBPIX(d, r1, g1, b1, r2, g2, b2, a1, a2, a3); \
20}
21
22
23// blend_solid_hspan_copy_subpix
24void
25blend_solid_hspan_copy_subpix(int x, int y, unsigned len, const color_type& c,
26	const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
27{
28	uint8* p = buffer->row_ptr(y) + (x << 2);
29	rgb_color l = pattern->LowColor();
30	const int subpixelL = gSubpixelOrderingRGB ? 2 : 0;
31	const int subpixelM = 1;
32	const int subpixelR = gSubpixelOrderingRGB ? 0 : 2;
33	do {
34		rgb_color color = pattern->ColorAt(x, y);
35		BLEND_COPY_SUBPIX(p, color.red, color.green, color.blue,
36			covers[subpixelL], covers[subpixelM], covers[subpixelR], l.red,
37			l.green, l.blue);
38		covers += 3;
39		p += 4;
40		x++;
41		len -= 3;
42	} while (len);
43}
44
45#endif // DRAWING_MODE_COPY_SUBPIX_H
46
47