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_INVERT on B_RGBA32. 7 * 8 */ 9 10 #ifndef DRAWING_MODE_INVERT_SUBPIX_H 11 #define DRAWING_MODE_INVERT_SUBPIX_H 12 13 #include "DrawingMode.h" 14 15 // BLEND_INVERT_SUBPIX 16 #define BLEND_INVERT_SUBPIX(d, a1, a2, a3) \ 17 { \ 18 pixel32 _p; \ 19 _p.data32 = *(uint32*)d; \ 20 BLEND_SUBPIX(d, 255 - _p.data8[2], 255 - _p.data8[1], 255 - _p.data8[0], \ 21 a1, a2, a3); \ 22 } 23 24 25 // BLEND_INVERT 26 #define BLEND_INVERT(d, a) \ 27 { \ 28 pixel32 _p; \ 29 _p.data32 = *(uint32*)d; \ 30 BLEND(d, 255 - _p.data8[2], 255 - _p.data8[1], 255 - _p.data8[0], a); \ 31 } 32 33 34 // ASSIGN_INVERT 35 #define ASSIGN_INVERT(d) \ 36 { \ 37 pixel32 _p; \ 38 _p.data32 = *(uint32*)d; \ 39 d[0] = 255 - _p.data8[0]; \ 40 d[1] = 255 - _p.data8[1]; \ 41 d[2] = 255 - _p.data8[2]; \ 42 d[3] = 255; \ 43 } 44 45 46 // blend_hline_invert_subpix 47 void 48 blend_hline_invert_subpix(int x, int y, unsigned len, const color_type& c, 49 uint8 cover, agg_buffer* buffer, const PatternHandler* pattern) 50 { 51 uint8* p = buffer->row_ptr(y) + (x << 2); 52 if(cover == 255) { 53 do { 54 if (pattern->IsHighColor(x, y)) { 55 ASSIGN_INVERT(p); 56 } 57 x++; 58 p += 4; 59 len -= 3; 60 } while (len); 61 } else { 62 do { 63 if (pattern->IsHighColor(x, y)) { 64 BLEND_INVERT(p, cover); 65 } 66 x++; 67 p += 4; 68 len -= 3; 69 } while (len); 70 } 71 } 72 73 74 // blend_solid_hspan_invert_subpix 75 void 76 blend_solid_hspan_invert_subpix(int x, int y, unsigned len, const color_type& c, 77 const uint8* covers, agg_buffer* buffer, const PatternHandler* pattern) 78 { 79 uint8* p = buffer->row_ptr(y) + (x << 2); 80 do { 81 if (pattern->IsHighColor(x, y)) 82 BLEND_INVERT_SUBPIX(p, covers[2], covers[1], covers[0]); 83 covers += 3; 84 p += 4; 85 x++; 86 len -= 3; 87 } while (len); 88 } 89 90 91 #endif // DRAWING_MODE_INVERT_SUBPIX_H 92 93