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 Overlay" mode on B_RGBA32. 7 * 8 */ 9 10 #ifndef DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H 11 #define DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H 12 13 #include "DrawingModeAlphaCOSUBPIX.h" 14 15 // blend_hline_alpha_co_solid_subpix 16 void 17 blend_hline_alpha_co_solid_subpix(int x, int y, unsigned len, 18 const color_type& c, uint8 cover, agg_buffer* buffer, 19 const PatternHandler* pattern) 20 { 21 uint16 alpha = pattern->HighColor().alpha * cover; 22 if (alpha == 255 * 255) { 23 // cache the color as 32bit values 24 uint32 v; 25 uint8* p8 = (uint8*)&v; 26 p8[0] = c.b; 27 p8[1] = c.g; 28 p8[2] = c.r; 29 p8[3] = 255; 30 // row offset as 32bit pointer 31 uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x; 32 do { 33 *p32 = v; 34 p32++; 35 x++; 36 len -= 3; 37 } while (len); 38 } else { 39 uint8* p = buffer->row_ptr(y) + (x << 2); 40 if (len < 12) { 41 do { 42 BLEND_ALPHA_CO(p, c.r, c.g, c.b, alpha); 43 x++; 44 p += 4; 45 len -= 3; 46 } while (len); 47 } else { 48 alpha = alpha >> 8; 49 blend_line32(p, len / 3, c.r, c.g, c.b, alpha); 50 } 51 } 52 } 53 54 55 // blend_solid_hspan_alpha_co_solid_subpix 56 void 57 blend_solid_hspan_alpha_co_solid_subpix(int x, int y, unsigned len, 58 const color_type& c, const uint8* covers, agg_buffer* buffer, 59 const PatternHandler* pattern) 60 { 61 uint8* p = buffer->row_ptr(y) + (x << 2); 62 uint8 hAlpha = pattern->HighColor().alpha; 63 uint16 alphaRed; 64 uint16 alphaGreen; 65 uint16 alphaBlue; 66 do { 67 alphaRed = hAlpha * covers[0]; 68 alphaGreen = hAlpha * covers[1]; 69 alphaBlue = hAlpha * covers[2]; 70 BLEND_ALPHA_CO_SUBPIX(p, c.r, c.g, c.b, 71 alphaBlue, alphaGreen, alphaRed); 72 covers += 3; 73 p += 4; 74 x++; 75 len -= 3; 76 } while (len); 77 } 78 79 80 #endif // DRAWING_MODE_ALPHA_CO_SOLID_SUBPIX_H 81 82