1/* 2 * Copyright 2005, Stephan Aßmus <superstippi@gmx.de>. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * DrawingMode implementing B_OP_OVER on B_RGBA32. 6 * 7 */ 8 9#ifndef DRAWING_MODE_OVER_SOLID_H 10#define DRAWING_MODE_OVER_SOLID_H 11 12#include "DrawingModeOver.h" 13 14// blend_pixel_over_solid 15void 16blend_pixel_over_solid(int x, int y, const color_type& c, uint8 cover, 17 agg_buffer* buffer, const PatternHandler* pattern) 18{ 19 if (pattern->IsSolidLow()) 20 return; 21 22 uint8* p = buffer->row_ptr(y) + (x << 2); 23 if (cover == 255) { 24 ASSIGN_OVER(p, c.r, c.g, c.b); 25 } else { 26 BLEND_OVER(p, c.r, c.g, c.b, cover); 27 } 28} 29 30// blend_hline_over_solid 31void 32blend_hline_over_solid(int x, int y, unsigned len, 33 const color_type& c, uint8 cover, 34 agg_buffer* buffer, const PatternHandler* pattern) 35{ 36 if (pattern->IsSolidLow()) 37 return; 38 39 if (cover == 255) { 40 uint32 v; 41 uint8* p8 = (uint8*)&v; 42 p8[0] = (uint8)c.b; 43 p8[1] = (uint8)c.g; 44 p8[2] = (uint8)c.r; 45 p8[3] = 255; 46 uint32* p32 = (uint32*)(buffer->row_ptr(y)) + x; 47 do { 48 *p32 = v; 49 p32++; 50 x++; 51 } while(--len); 52 } else { 53 uint8* p = buffer->row_ptr(y) + (x << 2); 54 do { 55 BLEND_OVER(p, c.r, c.g, c.b, cover); 56 x++; 57 p += 4; 58 } while(--len); 59 } 60} 61 62// blend_solid_hspan_over_solid 63void 64blend_solid_hspan_over_solid(int x, int y, unsigned len, 65 const color_type& c, const uint8* covers, 66 agg_buffer* buffer, const PatternHandler* pattern) 67{ 68 if (pattern->IsSolidLow()) 69 return; 70 71 uint8* p = buffer->row_ptr(y) + (x << 2); 72 do { 73 if (*covers) { 74 if (*covers == 255) { 75 ASSIGN_OVER(p, c.r, c.g, c.b); 76 } else { 77 BLEND_OVER(p, c.r, c.g, c.b, *covers); 78 } 79 } 80 covers++; 81 p += 4; 82 x++; 83 } while(--len); 84} 85 86// blend_solid_vspan_over_solid 87void 88blend_solid_vspan_over_solid(int x, int y, unsigned len, 89 const color_type& c, const uint8* covers, 90 agg_buffer* buffer, const PatternHandler* pattern) 91{ 92 if (pattern->IsSolidLow()) 93 return; 94 95 uint8* p = buffer->row_ptr(y) + (x << 2); 96 do { 97 if (*covers) { 98 if (*covers == 255) { 99 ASSIGN_OVER(p, c.r, c.g, c.b); 100 } else { 101 BLEND_OVER(p, c.r, c.g, c.b, *covers); 102 } 103 } 104 covers++; 105 p += buffer->stride(); 106 y++; 107 } while(--len); 108} 109 110#endif // DRAWING_MODE_OVER_H 111 112