patch by Andrej Spielmann (GSOC):

Added complementary functions to the set of functions that implement a
drawing_mode, these new functions interpret the coverage values passed
from the AGG rasterizer or another scanline storage as subpixel triplets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26355 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-07-10 08:08:59 +00:00
parent 60d98a49ed
commit c816464287
19 changed files with 1747 additions and 0 deletions
@@ -0,0 +1,101 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ADD on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ADD_SUBPIX_H
#define DRAWING_MODE_ADD_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ADD_SUBPIX
#define BLEND_ADD_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 rt = min_c(255, _p.data8[2] + (r)); \
uint8 gt = min_c(255, _p.data8[1] + (g)); \
uint8 bt = min_c(255, _p.data8[0] + (b)); \
BLEND_SUBPIX(d, rt, gt, bt, a1, a2, a3); \
}
// BLEND_ADD
#define BLEND_ADD(d, r, g, b, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 rt = min_c(255, _p.data8[2] + (r)); \
uint8 gt = min_c(255, _p.data8[1] + (g)); \
uint8 bt = min_c(255, _p.data8[0] + (b)); \
BLEND(d, rt, gt, bt, a); \
}
//ASSIGN_ADD
#define ASSIGN_ADD(d, r, g, b) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
d[0] = min_c(255, _p.data8[0] + (b)); \
d[1] = min_c(255, _p.data8[1] + (g)); \
d[2] = min_c(255, _p.data8[2] + (r)); \
d[3] = 255; \
}
// blend_hline_add_subpix
void
blend_hline_add_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) {
do {
rgb_color color = pattern->ColorAt(x, y);
ASSIGN_ADD(p, color.red, color.green, color.blue);
p += 4;
x++;
len -= 3;
} while (len);
} else {
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_ADD(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_add_subpix
void
blend_solid_hspan_add_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_ADD_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ADD_SUBPIX_H
@@ -0,0 +1,113 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Constant Composite" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_CC_SUBPIX_H
#define DRAWING_MODE_ALPHA_CC_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ALPHA_CC_SUBPIX
#define BLEND_ALPHA_CC_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND_COMPOSITE16_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_ALPHA_CC
#define BLEND_ALPHA_CC(d, r, g, b, a) \
{ \
BLEND_COMPOSITE16(d, r, g, b, a); \
}
// ASSIGN_ALPHA_CC
#define ASSIGN_ALPHA_CC(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_alpha_cc_subpix
void
blend_hline_alpha_cc_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
rgb_color color = pattern->HighColor();
uint16 alpha = color.alpha * cover;
if (alpha == 255 * 255) {
// cache the low and high color as 32bit values
// high color
uint32 vh;
uint8* p8 = (uint8*)&vh;
p8[0] = color.blue;
p8[1] = color.green;
p8[2] = color.red;
p8[3] = 255;
// low color
color = pattern->LowColor();
uint32 vl;
p8 = (uint8*)&vl;
p8[0] = color.blue;
p8[1] = color.green;
p8[2] = color.red;
p8[3] = 255;
// row offset as 32 bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
if (pattern->IsHighColor(x, y))
*p32 = vh;
else
*p32 = vl;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CC(p, color.red, color.green, color.blue, alpha);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_alpha_cc_subpix
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)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().alpha;
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
alphaRed = hAlpha * covers[0];
alphaGreen = hAlpha * covers[1];
alphaBlue = hAlpha * covers[2];
rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CC_SUBPIX(p, color.red, color.green, color.blue,
alphaBlue,alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_CC_SUBPIX_H
@@ -0,0 +1,113 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Constant Overlay" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_CO_SUBPIX_H
#define DRAWING_MODE_ALPHA_CO_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ALPHA_CO_SUBPIX
#define BLEND_ALPHA_CO_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND16_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_ALPHA_CO
#define BLEND_ALPHA_CO(d, r, g, b, a) \
{ \
BLEND16(d, r, g, b, a); \
}
// ASSIGN_ALPHA_CO
#define ASSIGN_ALPHA_CO(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_alpha_co_subpix
void
blend_hline_alpha_co_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
rgb_color color = pattern->HighColor();
uint16 alpha = color.alpha * cover;
if (alpha == 255 * 255) {
// cache the low and high color as 32bit values
// high color
uint32 vh;
uint8* p8 = (uint8*)&vh;
p8[0] = color.blue;
p8[1] = color.green;
p8[2] = color.red;
p8[3] = 255;
// low color
color = pattern->LowColor();
uint32 vl;
p8 = (uint8*)&vl;
p8[0] = color.blue;
p8[1] = color.green;
p8[2] = color.red;
p8[3] = 255;
// row offset as 32bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
if (pattern->IsHighColor(x, y))
*p32 = vh;
else
*p32 = vl;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CO(p, color.red, color.green, color.blue, alpha);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_alpha_co_subpix
void
blend_solid_hspan_alpha_co_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().alpha;
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
alphaRed = hAlpha * covers[0];
alphaGreen = hAlpha * covers[1];
alphaBlue = hAlpha * covers[2];
rgb_color color = pattern->ColorAt(x, y);
BLEND_ALPHA_CO_SUBPIX(p, color.red, color.green, color.blue,
alphaBlue, alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_CO_SUBPIX_H
@@ -0,0 +1,81 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Constant Overlay" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H
#define DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H
#include "DrawingModeAlphaCOSUBPIX.h"
// blend_hline_alpha_co_solid_subpix
void
blend_hline_alpha_co_solid_subpix(int x, int y, unsigned len,
const color_type& c, uint8 cover, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint16 alpha = pattern->HighColor().alpha * cover;
if (alpha == 255 * 255) {
// cache the color as 32bit values
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = c.b;
p8[1] = c.g;
p8[2] = c.r;
p8[3] = 255;
// row offset as 32bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
*p32 = v;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
if (len < 12) {
do {
BLEND_ALPHA_CO(p, c.r, c.g, c.b, alpha);
x++;
p += 4;
len -= 3;
} while (len);
} else {
alpha = alpha >> 8;
blend_line32(p, len / 3, c.r, c.g, c.b, alpha);
}
}
}
// blend_solid_hspan_alpha_co_solid_subpix
void
blend_solid_hspan_alpha_co_solid_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint8 hAlpha = pattern->HighColor().alpha;
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
alphaRed = hAlpha * covers[0];
alphaGreen = hAlpha * covers[1];
alphaBlue = hAlpha * covers[2];
BLEND_ALPHA_CO_SUBPIX(p, c.r, c.g, c.b,
alphaBlue, alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H
@@ -0,0 +1,87 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Pixel Composite" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_PC_SUBPIX_H
#define DRAWING_MODE_ALPHA_PC_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ALPHA_PC_SUBPIX
#define BLEND_ALPHA_PC_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND_COMPOSITE16_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_ALPHA_PC
#define BLEND_ALPHA_PC(d, r, g, b, a) \
{ \
BLEND_COMPOSITE16(d, r, g, b, a); \
}
// ASSIGN_ALPHA_PC
#define ASSIGN_ALPHA_PC(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_alpha_pc_subpix
void
blend_hline_alpha_pc_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover;
if (alpha) {
if (alpha == 255) {
ASSIGN_ALPHA_PC(p, color.red, color.green, color.blue);
} else {
BLEND_ALPHA_PC(p, color.red, color.green, color.blue, alpha);
}
}
x++;
p += 4;
len -= 3;
} while (len);
}
// blend_solid_hspan_alpha_pc_subpix
void
blend_solid_hspan_alpha_pc_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
rgb_color color = pattern->ColorAt(x, y);
alphaRed = color.alpha * covers[0];
alphaGreen = color.alpha * covers[1];
alphaBlue = color.alpha * covers[2];
BLEND_ALPHA_PC_SUBPIX(p, color.red, color.green, color.blue,
alphaBlue, alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_PC_SUBPIX_H
@@ -0,0 +1,85 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Constant Overlay" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_PO_SUBPIX_H
#define DRAWING_MODE_ALPHA_PO_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ALPHA_PO_SUBPIX
#define BLEND_ALPHA_PO_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND16_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_ALPHA_PO
#define BLEND_ALPHA_PO(d, r, g, b, a) \
{ \
BLEND16(d, r, g, b, a); \
}
// ASSIGN_ALPHA_PO
#define ASSIGN_ALPHA_PO(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_alpha_po_subpix
void
blend_hline_alpha_po_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
uint16 alpha = color.alpha * cover;
if (alpha) {
if (alpha == 255) {
ASSIGN_ALPHA_PO(p, color.red, color.green, color.blue);
} else {
BLEND_ALPHA_PO(p, color.red, color.green, color.blue, alpha);
}
}
x++;
p += 4;
len -= 3;
} while(len);
}
// blend_solid_hspan_alpha_po_subpix
void
blend_solid_hspan_alpha_po_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
rgb_color color = pattern->ColorAt(x, y);
alphaRed = color.alpha * covers[0];
alphaGreen = color.alpha * covers[1];
alphaBlue = color.alpha * covers[2];
BLEND_ALPHA_PO_SUBPIX(p, color.red, color.green, color.blue,
alphaBlue, alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_PO_SUBPIX_H
@@ -0,0 +1,79 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ALPHA in "Constant Overlay" mode on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ALPHA_PO_SOLID_SUBPIX_H
#define DRAWING_MODE_ALPHA_PO_SOLID_SUBPIX_H
#include "DrawingModeAlphaPOSUBPIX.h"
// blend_hline_alpha_po_solid_subpix
void
blend_hline_alpha_po_solid_subpix(int x, int y, unsigned len,
const color_type& c, uint8 cover, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint16 alpha = c.a * cover;
if (alpha == 255 * 255) {
// cache the color as 32bit values
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = c.b;
p8[1] = c.g;
p8[2] = c.r;
p8[3] = 255;
// row offset as 32bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
*p32 = v;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
if (len < 12) {
do {
BLEND_ALPHA_CO(p, c.r, c.g, c.b, alpha);
x++;
p += 4;
len -= 3;
} while (len);
} else {
alpha = alpha >> 8;
blend_line32(p, len / 3, c.r, c.g, c.b, alpha);
}
}
}
// blend_solid_hspan_alpha_po_solid_subpix
void
blend_solid_hspan_alpha_po_solid_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
uint16 alphaRed;
uint16 alphaGreen;
uint16 alphaBlue;
do {
alphaRed = c.a * covers[0];
alphaGreen = c.a * covers[1];
alphaBlue = c.a * covers[2];
BLEND_ALPHA_PO_SUBPIX(p, c.r, c.g, c.b,
alphaBlue, alphaGreen, alphaRed);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ALPHA_PO_SOLID_SUBPIX_H
@@ -0,0 +1,101 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ADD on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_BLEND_SUBPIX_H
#define DRAWING_MODE_BLEND_SUBPIX_H
#include "DrawingMode.h"
// BLEND_BLEND_SUBPIX
#define BLEND_BLEND_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 bt = (_p.data8[0] + (b)) >> 1; \
uint8 gt = (_p.data8[1] + (g)) >> 1; \
uint8 rt = (_p.data8[2] + (r)) >> 1; \
BLEND_SUBPIX(d, rt, gt, bt, a1, a2, a3); \
}
// BLEND_BLEND
#define BLEND_BLEND(d, r, g, b, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 bt = (_p.data8[0] + (b)) >> 1; \
uint8 gt = (_p.data8[1] + (g)) >> 1; \
uint8 rt = (_p.data8[2] + (r)) >> 1; \
BLEND(d, rt, gt, bt, a); \
}
// ASSIGN_BLEND
#define ASSIGN_BLEND(d, r, g, b) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
d[0] = (_p.data8[0] + (b)) >> 1; \
d[1] = (_p.data8[1] + (g)) >> 1; \
d[2] = (_p.data8[2] + (r)) >> 1; \
d[3] = 255; \
}
// blend_hline_blend_subpix
void
blend_hline_blend_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) {
do {
rgb_color color = pattern->ColorAt(x, y);
ASSIGN_BLEND(p, color.red, color.green, color.blue);
p += 4;
x++;
len -= 3;
} while (len);
} else {
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_BLEND(p, color.red, color.green, color.blue, cover);
p += 4;
x++;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_blend_subpix
void
blend_solid_hspan_blend_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_BLEND_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_BLEND_SUBPIX_H
@@ -0,0 +1,107 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_COPY on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_COPY_SUBPIX_H
#define DRAWING_MODE_COPY_SUBPIX_H
#include "DrawingMode.h"
// BLEND_COPY_SUBPIX
#define BLEND_COPY_SUBPIX(d, r2, g2, b2, a1, a2, a3, r1, g1, b1) \
{ \
BLEND_FROM_SUBPIX(d, r1, g1, b1, r2, g2, b2, a1, a2, a3); \
}
// BLEND_COPY
#define BLEND_COPY(d, r2, g2, b2, a, r1, g1, b1) \
{ \
BLEND_FROM(d, r1, g1, b1, r2, g2, b2, a); \
}
// ASSIGN_COPY
#define ASSIGN_COPY(d, r, g, b, a) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = (a); \
}
// blend_hline_copy_subpix
void
blend_hline_copy_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (cover == 255) {
// cache the low and high color as 32bit values
// high color
rgb_color color = pattern->HighColor();
uint32 vh;
uint8* p8 = (uint8*)&vh;
p8[0] = (uint8)color.blue;
p8[1] = (uint8)color.green;
p8[2] = (uint8)color.red;
p8[3] = 255;
// low color
color = pattern->LowColor();
uint32 vl;
p8 = (uint8*)&vl;
p8[0] = (uint8)color.blue;
p8[1] = (uint8)color.green;
p8[2] = (uint8)color.red;
p8[3] = 255;
// row offset as 32bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
if (pattern->IsHighColor(x, y))
*p32 = vh;
else
*p32 = vl;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor();
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_COPY(p, color.red, color.green, color.blue, cover,
l.red, l.green, l.blue);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_copy_subpix
void
blend_solid_hspan_copy_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor();
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_COPY_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0], l.red, l.green, l.blue);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_COPY_SUBPIX_H
@@ -0,0 +1,63 @@
/*
* Copyright 2005, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_COPY ignoring the pattern (solid) on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_COPY_SOLID_SUBPIX_H
#define DRAWING_MODE_COPY_SOLID_SUBPIX_H
#include "DrawingModeOverSUBPIX.h"
// blend_hline_copy_solid_subpix
void
blend_hline_copy_solid_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (cover == 255) {
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = (uint8)c.b;
p8[1] = (uint8)c.g;
p8[2] = (uint8)c.r;
p8[3] = 255;
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
*p32 = v;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
BLEND_OVER(p, c.r, c.g, c.b, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_copy_solid_subpix
void
blend_solid_hspan_copy_solid_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
BLEND_OVER_SUBPIX(p, c.r, c.g, c.b, covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_COPY_SOLID_SUBPIX_H
@@ -0,0 +1,66 @@
/*
* Copyright 2006, Stephan Aßmus <[email protected]>.
* Copyright 2008, Andrej Spielmann <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_COPY for text on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_COPY_TEXT_SUBPIX_H
#define DRAWING_MODE_COPY_TEXT_SUBPIX_H
#include "DrawingModeCopySUBPIX.h"
// blend_hline_copy_text_subpix
void
blend_hline_copy_text_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (cover == 255) {
// cache the color as 32bit value
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = (uint8)c.b;
p8[1] = (uint8)c.g;
p8[2] = (uint8)c.r;
p8[3] = 255;
// row offset as 32bit pointer
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
*p32 = v;
p32++;
len -= 3;
} while(len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color l = pattern->LowColor();
do {
BLEND_COPY(p, c.r, c.g, c.b, cover, l.red, l.green, l.blue);
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_copy_text_subpix
void
blend_solid_hspan_copy_text_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
//printf("blend_solid_hspan_copy_text(%d, %d)\n", x, len);
uint8* p = buffer->row_ptr(y) + (x << 2);
//rgb_color l = pattern->LowColor();
do {
BLEND_OVER_SUBPIX(p, c.r, c.g, c.b, covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_COPY_TEXT_SUBPIX_H
@@ -0,0 +1,94 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_ERASE on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_ERASE_SUBPIX_H
#define DRAWING_MODE_ERASE_SUBPIX_H
#include "DrawingMode.h"
// BLEND_ERASE_SUBPIX
#define BLEND_ERASE_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_ERASE
#define BLEND_ERASE(d, r, g, b, a) \
{ \
BLEND(d, r, g, b, a); \
}
// ASSIGN_ERASE
#define ASSIGN_ERASE(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_erase_subpix
void
blend_hline_erase_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (cover == 255) {
rgb_color color = pattern->LowColor();
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = (uint8)color.blue;
p8[1] = (uint8)color.green;
p8[2] = (uint8)color.red;
p8[3] = 255;
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
if (pattern->IsHighColor(x, y))
*p32 = v;
p32++;
x +=3;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor();
do {
if (pattern->IsHighColor(x, y))
BLEND_ERASE(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_erase_subpix
void
blend_solid_hspan_erase_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->LowColor();
do {
if (pattern->IsHighColor(x, y)) {
BLEND_ERASE_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
}
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_ERASE_SUBPIX_H
@@ -0,0 +1,92 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_INVERT on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_INVERT_SUBPIX_H
#define DRAWING_MODE_INVERT_SUBPIX_H
#include "DrawingMode.h"
// BLEND_INVERT_SUBPIX
#define BLEND_INVERT_SUBPIX(d, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
BLEND_SUBPIX(d, 255 - _p.data8[2], 255 - _p.data8[1], 255 - _p.data8[0], \
a1, a2, a3); \
}
// BLEND_INVERT
#define BLEND_INVERT(d, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
BLEND(d, 255 - _p.data8[2], 255 - _p.data8[1], 255 - _p.data8[0], a); \
}
// ASSIGN_INVERT
#define ASSIGN_INVERT(d) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
d[0] = 255 - _p.data8[0]; \
d[1] = 255 - _p.data8[1]; \
d[2] = 255 - _p.data8[2]; \
d[3] = 255; \
}
// blend_hline_invert_subpix
void
blend_hline_invert_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if(cover == 255) {
do {
if (pattern->IsHighColor(x, y)) {
ASSIGN_INVERT(p);
}
x++;
p += 4;
len -= 3;
} while (len);
} else {
do {
if (pattern->IsHighColor(x, y)) {
BLEND_INVERT(p, cover);
}
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_invert_subpix
void
blend_solid_hspan_invert_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
if (pattern->IsHighColor(x, y))
BLEND_INVERT_SUBPIX(p, covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_INVERT_SUBPIX_H
@@ -0,0 +1,102 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_MAX on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_MAX_SUBPIX_H
#define DRAWING_MODE_MAX_SUBPIX_H
#include "DrawingMode.h"
// BLEND_MAX_SUBPIX
#define BLEND_MAX_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
> brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
BLEND_SUBPIX(d, (r), (g), (b), a1, a2, a3); \
} \
}
// BLEND_MAX
#define BLEND_MAX(d, r, g, b, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
> brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
BLEND(d, (r), (g), (b), a); \
} \
}
// ASSIGN_MAX
#define ASSIGN_MAX(d, r, g, b) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
> brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
} \
}
// blend_hline_max_subpix
void
blend_hline_max_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) {
do {
rgb_color color = pattern->ColorAt(x, y);
ASSIGN_MAX(p, color.red, color.green, color.blue);
p += 4;
x++;
len -= 3;
} while (len);
} else {
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_MAX(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_max_subpix
void
blend_solid_hspan_max_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_MAX_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_MAX_SUBPIX_H
@@ -0,0 +1,102 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_MIN on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_MIN_SUBPIX_H
#define DRAWING_MODE_MIN_SUBPIX_H
#include "DrawingMode.h"
// BLEND_MIN_SUBPIX
#define BLEND_MIN_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
< brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
BLEND_SUBPIX(d, (r), (g), (b), a1, a2, a3); \
} \
}
// BLEND_MIN
#define BLEND_MIN(d, r, g, b, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
< brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
BLEND(d, (r), (g), (b), a); \
} \
}
// ASSIGN_MIN
#define ASSIGN_MIN(d, r, g, b) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
if (brightness_for((r), (g), (b)) \
< brightness_for(_p.data8[2], _p.data8[1], _p.data8[0])) { \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
} \
}
// blend_hline_min_subpix
void
blend_hline_min_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) {
do {
rgb_color color = pattern->ColorAt(x, y);
ASSIGN_MIN(p, color.red, color.green, color.blue);
p += 4;
x++;
len -= 3;
} while (len);
} else {
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_MIN(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_min_subpix
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)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_MIN_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_MIN_SUBPIX_H
@@ -0,0 +1,94 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_OVER on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_OVER_SUBPIX_H
#define DRAWING_MODE_OVER_SUBPIX_H
#include "DrawingMode.h"
// BLEND_OVER_SUBPIX
#define BLEND_OVER_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND_SUBPIX(d, r, g, b, a1, a2, a3) \
}
// BLEND_OVER
#define BLEND_OVER(d, r, g, b, a) \
{ \
BLEND(d, r, g, b, a) \
}
// ASSIGN_OVER
#define ASSIGN_OVER(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_over_subpix
void
blend_hline_over_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (cover == 255) {
rgb_color color = pattern->HighColor();
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = (uint8)color.blue;
p8[1] = (uint8)color.green;
p8[2] = (uint8)color.red;
p8[3] = 255;
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
if (pattern->IsHighColor(x, y))
*p32 = v;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor();
do {
if (pattern->IsHighColor(x, y))
BLEND_OVER(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_over_subpix
void
blend_solid_hspan_over_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color color = pattern->HighColor();
do {
if (pattern->IsHighColor(x, y)) {
BLEND_OVER_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
}
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_OVER_SUBPIX_H
@@ -0,0 +1,69 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_OVER on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_OVER_SOLID_SUBPIX_H
#define DRAWING_MODE_OVER_SOLID_SUBPIX_H
#include "DrawingModeOverSUBPIX.h"
// blend_hline_over_solid_subpix
void
blend_hline_over_solid_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
if (pattern->IsSolidLow())
return;
if (cover == 255) {
uint32 v;
uint8* p8 = (uint8*)&v;
p8[0] = (uint8)c.b;
p8[1] = (uint8)c.g;
p8[2] = (uint8)c.r;
p8[3] = 255;
uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x;
do {
*p32 = v;
p32++;
x++;
len -= 3;
} while (len);
} else {
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
BLEND_OVER(p, c.r, c.g, c.b, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_over_solid_subpix
void
blend_solid_hspan_over_solid_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
if (pattern->IsSolidLow())
return;
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
BLEND_OVER_SUBPIX(p, c.r, c.g, c.b, covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_OVER_SUBPIX_H
@@ -0,0 +1,95 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_SELECT on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_SELECT_SUBPIX_H
#define DRAWING_MODE_SELECT_SUBPIX_H
#include "DrawingMode.h"
// BLEND_SELECT_SUBPIX
#define BLEND_SELECT_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
BLEND_SUBPIX(d, r, g, b, a1, a2, a3); \
}
// BLEND_SELECT
#define BLEND_SELECT(d, r, g, b, a) \
{ \
BLEND(d, r, g, b, a); \
}
// ASSIGN_SELECT
#define ASSIGN_SELECT(d, r, g, b) \
{ \
d[0] = (b); \
d[1] = (g); \
d[2] = (r); \
d[3] = 255; \
}
// blend_hline_select_subpix
void
blend_hline_select_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor();
rgb_color color;
if (cover == 255) {
do {
if (pattern->IsHighColor(x, y)
&& compare(p, high, low, &color))
ASSIGN_SELECT(p, color.red, color.green, color.blue);
x++;
p += 4;
len -= 3;
} while (len);
} else {
do {
if (pattern->IsHighColor(x, y)
&& compare(p, high, low, &color)) {
BLEND_SELECT(p, color.red, color.green, color.blue, cover);
}
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_select_subpix
void
blend_solid_hspan_select_subpix(int x, int y, unsigned len, const color_type& c,
const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
rgb_color high = pattern->HighColor();
rgb_color low = pattern->LowColor();
rgb_color color;
do {
if (pattern->IsHighColor(x, y)) {
if (compare(p, high, low, &color)){
BLEND_SELECT_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
}
}
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_SELECT_SUBPIX_H
@@ -0,0 +1,103 @@
/*
* Copyright 2005, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License.
*
* DrawingMode implementing B_OP_SUBTRACT on B_RGBA32.
*
*/
#ifndef DRAWING_MODE_SUBTRACT_SUBPIX_H
#define DRAWING_MODE_SUBTRACT_SUBPIX_H
#include <SupportDefs.h>
#include "DrawingMode.h"
#include "PatternHandler.h"
// BLEND_SUBTRACT_SUBPIX
#define BLEND_SUBTRACT_SUBPIX(d, r, g, b, a1, a2, a3) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 rt = max_c(0, _p.data8[2] - (r)); \
uint8 gt = max_c(0, _p.data8[1] - (g)); \
uint8 bt = max_c(0, _p.data8[0] - (b)); \
BLEND_SUBPIX(d, rt, gt, bt, a1, a2, a3); \
}
// BLEND_SUBTRACT
#define BLEND_SUBTRACT(d, r, g, b, a) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
uint8 rt = max_c(0, _p.data8[2] - (r)); \
uint8 gt = max_c(0, _p.data8[1] - (g)); \
uint8 bt = max_c(0, _p.data8[0] - (b)); \
BLEND(d, rt, gt, bt, a); \
}
// ASSIGN_SUBTRACT
#define ASSIGN_SUBTRACT(d, r, g, b) \
{ \
pixel32 _p; \
_p.data32 = *(uint32*)d; \
d[0] = max_c(0, _p.data8[0] - (b)); \
d[1] = max_c(0, _p.data8[1] - (g)); \
d[2] = max_c(0, _p.data8[2] - (r)); \
d[3] = 255; \
}
// blend_hline_subtract_subpix
void
blend_hline_subtract_subpix(int x, int y, unsigned len, const color_type& c,
uint8 cover, agg_buffer* buffer, const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
if (cover == 255) {
do {
rgb_color color = pattern->ColorAt(x, y);
ASSIGN_SUBTRACT(p, color.red, color.green, color.blue);
p += 4;
x++;
len -= 3;
} while (len);
} else {
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_SUBTRACT(p, color.red, color.green, color.blue, cover);
x++;
p += 4;
len -= 3;
} while (len);
}
}
// blend_solid_hspan_subtract_subpix
void
blend_solid_hspan_subtract_subpix(int x, int y, unsigned len,
const color_type& c, const uint8* covers, agg_buffer* buffer,
const PatternHandler* pattern)
{
uint8* p = buffer->row_ptr(y) + (x << 2);
do {
rgb_color color = pattern->ColorAt(x, y);
BLEND_SUBTRACT_SUBPIX(p, color.red, color.green, color.blue,
covers[2], covers[1], covers[0]);
covers += 3;
p += 4;
x++;
len -= 3;
} while (len);
}
#endif // DRAWING_MODE_SUBTRACT_SUBPIX_H