1 // DrawingModeMin.h 2 3 #ifndef DRAWING_MODE_MIN_H 4 #define DRAWING_MODE_MIN_H 5 6 #include "DrawingMode.h" 7 8 9 // BLEND_MIN 10 #define BLEND_MIN(d, r, g, b, a) \ 11 { \ 12 pixel32 _p; \ 13 _p.data32 = *(uint32*)d; \ 14 uint8 rt = min_c(_p.data8[2], (r)); \ 15 uint8 gt = min_c(_p.data8[1], (g)); \ 16 uint8 bt = min_c(_p.data8[0], (b)); \ 17 BLEND(d, rt, gt, bt, a); \ 18 } 19 20 // ASSIGN_MIN 21 #define ASSIGN_MIN(d, r, g, b) \ 22 { \ 23 pixel32 _p; \ 24 _p.data32 = *(uint32*)d; \ 25 d[0] = min_c(_p.data8[0], (b)); \ 26 d[1] = min_c(_p.data8[1], (g)); \ 27 d[2] = min_c(_p.data8[2], (r)); \ 28 d[3] = 255; \ 29 } 30 31 32 // blend_pixel_min 33 void 34 blend_pixel_min(int x, int y, const color_type& c, uint8 cover, 35 agg_buffer* buffer, const PatternHandler* pattern) 36 { 37 uint8* p = buffer->row_ptr(y) + (x << 2); 38 rgb_color color = pattern->R5ColorAt(x, y); 39 if (cover == 255) { 40 ASSIGN_MIN(p, color.red, color.green, color.blue); 41 } else { 42 BLEND_MIN(p, color.red, color.green, color.blue, cover); 43 } 44 } 45 46 // blend_hline_min 47 void 48 blend_hline_min(int x, int y, unsigned len, 49 const color_type& c, uint8 cover, 50 agg_buffer* buffer, const PatternHandler* pattern) 51 { 52 uint8* p = buffer->row_ptr(y) + (x << 2); 53 if (cover == 255) { 54 do { 55 rgb_color color = pattern->R5ColorAt(x, y); 56 57 ASSIGN_MIN(p, color.red, color.green, color.blue); 58 59 p += 4; 60 x++; 61 } while(--len); 62 } else { 63 do { 64 rgb_color color = pattern->R5ColorAt(x, y); 65 66 BLEND_MIN(p, color.red, color.green, color.blue, cover); 67 68 x++; 69 p += 4; 70 } while(--len); 71 } 72 } 73 74 // blend_solid_hspan_min 75 void 76 blend_solid_hspan_min(int x, int y, unsigned len, 77 const color_type& c, const uint8* covers, 78 agg_buffer* buffer, const PatternHandler* pattern) 79 { 80 uint8* p = buffer->row_ptr(y) + (x << 2); 81 do { 82 rgb_color color = pattern->R5ColorAt(x, y); 83 if (*covers) { 84 if (*covers == 255) { 85 ASSIGN_MIN(p, color.red, color.green, color.blue); 86 } else { 87 BLEND_MIN(p, color.red, color.green, color.blue, *covers); 88 } 89 } 90 covers++; 91 p += 4; 92 x++; 93 } while(--len); 94 } 95 96 97 98 // blend_solid_vspan_min 99 void 100 blend_solid_vspan_min(int x, int y, unsigned len, 101 const color_type& c, const uint8* covers, 102 agg_buffer* buffer, const PatternHandler* pattern) 103 { 104 uint8* p = buffer->row_ptr(y) + (x << 2); 105 do { 106 rgb_color color = pattern->R5ColorAt(x, y); 107 if (*covers) { 108 if (*covers == 255) { 109 ASSIGN_MIN(p, color.red, color.green, color.blue); 110 } else { 111 BLEND_MIN(p, color.red, color.green, color.blue, *covers); 112 } 113 } 114 covers++; 115 p += buffer->stride(); 116 y++; 117 } while(--len); 118 } 119 120 121 // blend_color_hspan_min 122 void 123 blend_color_hspan_min(int x, int y, unsigned len, 124 const color_type* colors, 125 const uint8* covers, uint8 cover, 126 agg_buffer* buffer, const PatternHandler* pattern) 127 { 128 uint8* p = buffer->row_ptr(y) + (x << 2); 129 if (covers) { 130 // non-solid opacity 131 do { 132 if (*covers) { 133 if (*covers == 255) { 134 ASSIGN_MIN(p, colors->r, colors->g, colors->b); 135 } else { 136 BLEND_MIN(p, colors->r, colors->g, colors->b, *covers); 137 } 138 } 139 covers++; 140 p += 4; 141 ++colors; 142 } while(--len); 143 } else { 144 // solid full opcacity 145 if (cover == 255) { 146 do { 147 ASSIGN_MIN(p, colors->r, colors->g, colors->b); 148 p += 4; 149 ++colors; 150 } while(--len); 151 // solid partial opacity 152 } else if (cover) { 153 do { 154 BLEND_MIN(p, colors->r, colors->g, colors->b, cover); 155 p += 4; 156 ++colors; 157 } while(--len); 158 } 159 } 160 } 161 162 #endif // DRAWING_MODE_MIN_H 163 164