OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCoreBlitters.h" | 10 #include "SkCoreBlitters.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkShader.h" | 12 #include "SkShader.h" |
13 #include "SkXfermode.h" | 13 #include "SkXfermode.h" |
14 | 14 |
15 SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint) | 15 SkA8_Blitter::SkA8_Blitter(const SkPixmap& device, const SkPaint& paint) : INHER
ITED(device) { |
16 : INHERITED(device) { | |
17 fSrcA = paint.getAlpha(); | 16 fSrcA = paint.getAlpha(); |
18 } | 17 } |
19 | 18 |
20 const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) { | 19 const SkPixmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) { |
21 if (255 == fSrcA) { | 20 if (255 == fSrcA) { |
22 *value = 255; | 21 *value = 255; |
23 return &fDevice; | 22 return &fDevice; |
24 } | 23 } |
25 return NULL; | 24 return NULL; |
26 } | 25 } |
27 | 26 |
28 void SkA8_Blitter::blitH(int x, int y, int width) { | 27 void SkA8_Blitter::blitH(int x, int y, int width) { |
29 SkASSERT(x >= 0 && y >= 0 && | 28 SkASSERT(x >= 0 && y >= 0 && |
30 (unsigned)(x + width) <= (unsigned)fDevice.width()); | 29 (unsigned)(x + width) <= (unsigned)fDevice.width()); |
31 | 30 |
32 if (fSrcA == 0) { | 31 if (fSrcA == 0) { |
33 return; | 32 return; |
34 } | 33 } |
35 | 34 |
36 uint8_t* device = fDevice.getAddr8(x, y); | 35 uint8_t* device = fDevice.writable_addr8(x, y); |
37 | 36 |
38 if (fSrcA == 255) { | 37 if (fSrcA == 255) { |
39 memset(device, 0xFF, width); | 38 memset(device, 0xFF, width); |
40 } else { | 39 } else { |
41 unsigned scale = 256 - SkAlpha255To256(fSrcA); | 40 unsigned scale = 256 - SkAlpha255To256(fSrcA); |
42 unsigned srcA = fSrcA; | 41 unsigned srcA = fSrcA; |
43 | 42 |
44 for (int i = 0; i < width; i++) { | 43 for (int i = 0; i < width; i++) { |
45 device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale)); | 44 device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale)); |
46 } | 45 } |
47 } | 46 } |
48 } | 47 } |
49 | 48 |
50 void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 49 void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
51 const int16_t runs[]) { | 50 const int16_t runs[]) { |
52 if (fSrcA == 0) { | 51 if (fSrcA == 0) { |
53 return; | 52 return; |
54 } | 53 } |
55 | 54 |
56 uint8_t* device = fDevice.getAddr8(x, y); | 55 uint8_t* device = fDevice.writable_addr8(x, y); |
57 unsigned srcA = fSrcA; | 56 unsigned srcA = fSrcA; |
58 | 57 |
59 for (;;) { | 58 for (;;) { |
60 int count = runs[0]; | 59 int count = runs[0]; |
61 SkASSERT(count >= 0); | 60 SkASSERT(count >= 0); |
62 if (count == 0) { | 61 if (count == 0) { |
63 return; | 62 return; |
64 } | 63 } |
65 unsigned aa = antialias[0]; | 64 unsigned aa = antialias[0]; |
66 | 65 |
(...skipping 23 matching lines...) Expand all Loading... |
90 if (mask & 0x10) dst[3] = 0xFF; \ | 89 if (mask & 0x10) dst[3] = 0xFF; \ |
91 if (mask & 0x08) dst[4] = 0xFF; \ | 90 if (mask & 0x08) dst[4] = 0xFF; \ |
92 if (mask & 0x04) dst[5] = 0xFF; \ | 91 if (mask & 0x04) dst[5] = 0xFF; \ |
93 if (mask & 0x02) dst[6] = 0xFF; \ | 92 if (mask & 0x02) dst[6] = 0xFF; \ |
94 if (mask & 0x01) dst[7] = 0xFF; \ | 93 if (mask & 0x01) dst[7] = 0xFF; \ |
95 } while (0) | 94 } while (0) |
96 | 95 |
97 #define SK_BLITBWMASK_NAME SkA8_BlitBW | 96 #define SK_BLITBWMASK_NAME SkA8_BlitBW |
98 #define SK_BLITBWMASK_ARGS | 97 #define SK_BLITBWMASK_ARGS |
99 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst) | 98 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst) |
100 #define SK_BLITBWMASK_GETADDR getAddr8 | 99 #define SK_BLITBWMASK_GETADDR writable_addr8 |
101 #define SK_BLITBWMASK_DEVTYPE uint8_t | 100 #define SK_BLITBWMASK_DEVTYPE uint8_t |
102 #include "SkBlitBWMaskTemplate.h" | 101 #include "SkBlitBWMaskTemplate.h" |
103 | 102 |
104 static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa, | 103 static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa, |
105 unsigned dst_scale) { | 104 unsigned dst_scale) { |
106 if (bw & 0x80) dst[0] = SkToU8(sa + SkAlphaMul(dst[0], dst_scale)); | 105 if (bw & 0x80) dst[0] = SkToU8(sa + SkAlphaMul(dst[0], dst_scale)); |
107 if (bw & 0x40) dst[1] = SkToU8(sa + SkAlphaMul(dst[1], dst_scale)); | 106 if (bw & 0x40) dst[1] = SkToU8(sa + SkAlphaMul(dst[1], dst_scale)); |
108 if (bw & 0x20) dst[2] = SkToU8(sa + SkAlphaMul(dst[2], dst_scale)); | 107 if (bw & 0x20) dst[2] = SkToU8(sa + SkAlphaMul(dst[2], dst_scale)); |
109 if (bw & 0x10) dst[3] = SkToU8(sa + SkAlphaMul(dst[3], dst_scale)); | 108 if (bw & 0x10) dst[3] = SkToU8(sa + SkAlphaMul(dst[3], dst_scale)); |
110 if (bw & 0x08) dst[4] = SkToU8(sa + SkAlphaMul(dst[4], dst_scale)); | 109 if (bw & 0x08) dst[4] = SkToU8(sa + SkAlphaMul(dst[4], dst_scale)); |
111 if (bw & 0x04) dst[5] = SkToU8(sa + SkAlphaMul(dst[5], dst_scale)); | 110 if (bw & 0x04) dst[5] = SkToU8(sa + SkAlphaMul(dst[5], dst_scale)); |
112 if (bw & 0x02) dst[6] = SkToU8(sa + SkAlphaMul(dst[6], dst_scale)); | 111 if (bw & 0x02) dst[6] = SkToU8(sa + SkAlphaMul(dst[6], dst_scale)); |
113 if (bw & 0x01) dst[7] = SkToU8(sa + SkAlphaMul(dst[7], dst_scale)); | 112 if (bw & 0x01) dst[7] = SkToU8(sa + SkAlphaMul(dst[7], dst_scale)); |
114 } | 113 } |
115 | 114 |
116 #define SK_BLITBWMASK_NAME SkA8_BlendBW | 115 #define SK_BLITBWMASK_NAME SkA8_BlendBW |
117 #define SK_BLITBWMASK_ARGS , U8CPU sa, unsigned dst_scale | 116 #define SK_BLITBWMASK_ARGS , U8CPU sa, unsigned dst_scale |
118 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sa, dst_sc
ale) | 117 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sa, dst_sc
ale) |
119 #define SK_BLITBWMASK_GETADDR getAddr8 | 118 #define SK_BLITBWMASK_GETADDR writable_addr8 |
120 #define SK_BLITBWMASK_DEVTYPE uint8_t | 119 #define SK_BLITBWMASK_DEVTYPE uint8_t |
121 #include "SkBlitBWMaskTemplate.h" | 120 #include "SkBlitBWMaskTemplate.h" |
122 | 121 |
123 void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 122 void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
124 if (fSrcA == 0) { | 123 if (fSrcA == 0) { |
125 return; | 124 return; |
126 } | 125 } |
127 | 126 |
128 if (mask.fFormat == SkMask::kBW_Format) { | 127 if (mask.fFormat == SkMask::kBW_Format) { |
129 if (fSrcA == 0xFF) { | 128 if (fSrcA == 0xFF) { |
130 SkA8_BlitBW(fDevice, mask, clip); | 129 SkA8_BlitBW(fDevice, mask, clip); |
131 } else { | 130 } else { |
132 SkA8_BlendBW(fDevice, mask, clip, fSrcA, | 131 SkA8_BlendBW(fDevice, mask, clip, fSrcA, |
133 SkAlpha255To256(255 - fSrcA)); | 132 SkAlpha255To256(255 - fSrcA)); |
134 } | 133 } |
135 return; | 134 return; |
136 } | 135 } |
137 | 136 |
138 int x = clip.fLeft; | 137 int x = clip.fLeft; |
139 int y = clip.fTop; | 138 int y = clip.fTop; |
140 int width = clip.width(); | 139 int width = clip.width(); |
141 int height = clip.height(); | 140 int height = clip.height(); |
142 uint8_t* device = fDevice.getAddr8(x, y); | 141 uint8_t* device = fDevice.writable_addr8(x, y); |
143 const uint8_t* alpha = mask.getAddr8(x, y); | 142 const uint8_t* alpha = mask.getAddr8(x, y); |
144 unsigned srcA = fSrcA; | 143 unsigned srcA = fSrcA; |
145 | 144 |
146 while (--height >= 0) { | 145 while (--height >= 0) { |
147 for (int i = width - 1; i >= 0; --i) { | 146 for (int i = width - 1; i >= 0; --i) { |
148 unsigned sa; | 147 unsigned sa; |
149 // scale our src by the alpha value | 148 // scale our src by the alpha value |
150 { | 149 { |
151 int aa = alpha[i]; | 150 int aa = alpha[i]; |
152 if (aa == 0) { | 151 if (aa == 0) { |
(...skipping 19 matching lines...) Expand all Loading... |
172 } | 171 } |
173 | 172 |
174 /////////////////////////////////////////////////////////////////////////////// | 173 /////////////////////////////////////////////////////////////////////////////// |
175 | 174 |
176 void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 175 void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
177 if (fSrcA == 0) { | 176 if (fSrcA == 0) { |
178 return; | 177 return; |
179 } | 178 } |
180 | 179 |
181 unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha)); | 180 unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha)); |
182 uint8_t* device = fDevice.getAddr8(x, y); | 181 uint8_t* device = fDevice.writable_addr8(x, y); |
183 size_t rowBytes = fDevice.rowBytes(); | 182 size_t rowBytes = fDevice.rowBytes(); |
184 | 183 |
185 if (sa == 0xFF) { | 184 if (sa == 0xFF) { |
186 for (int i = 0; i < height; i++) { | 185 for (int i = 0; i < height; i++) { |
187 *device = SkToU8(sa); | 186 *device = SkToU8(sa); |
188 device += rowBytes; | 187 device += rowBytes; |
189 } | 188 } |
190 } else { | 189 } else { |
191 unsigned scale = 256 - SkAlpha255To256(sa); | 190 unsigned scale = 256 - SkAlpha255To256(sa); |
192 | 191 |
193 for (int i = 0; i < height; i++) { | 192 for (int i = 0; i < height; i++) { |
194 *device = SkToU8(sa + SkAlphaMul(*device, scale)); | 193 *device = SkToU8(sa + SkAlphaMul(*device, scale)); |
195 device += rowBytes; | 194 device += rowBytes; |
196 } | 195 } |
197 } | 196 } |
198 } | 197 } |
199 | 198 |
200 void SkA8_Blitter::blitRect(int x, int y, int width, int height) { | 199 void SkA8_Blitter::blitRect(int x, int y, int width, int height) { |
201 SkASSERT(x >= 0 && y >= 0 && | 200 SkASSERT(x >= 0 && y >= 0 && |
202 (unsigned)(x + width) <= (unsigned)fDevice.width() && | 201 (unsigned)(x + width) <= (unsigned)fDevice.width() && |
203 (unsigned)(y + height) <= (unsigned)fDevice.height()); | 202 (unsigned)(y + height) <= (unsigned)fDevice.height()); |
204 | 203 |
205 if (fSrcA == 0) { | 204 if (fSrcA == 0) { |
206 return; | 205 return; |
207 } | 206 } |
208 | 207 |
209 uint8_t* device = fDevice.getAddr8(x, y); | 208 uint8_t* device = fDevice.writable_addr8(x, y); |
210 unsigned srcA = fSrcA; | 209 unsigned srcA = fSrcA; |
211 | 210 |
212 if (srcA == 255) { | 211 if (srcA == 255) { |
213 while (--height >= 0) { | 212 while (--height >= 0) { |
214 memset(device, 0xFF, width); | 213 memset(device, 0xFF, width); |
215 device += fDevice.rowBytes(); | 214 device += fDevice.rowBytes(); |
216 } | 215 } |
217 } else { | 216 } else { |
218 unsigned scale = 256 - SkAlpha255To256(srcA); | 217 unsigned scale = 256 - SkAlpha255To256(srcA); |
219 | 218 |
220 while (--height >= 0) { | 219 while (--height >= 0) { |
221 for (int i = 0; i < width; i++) { | 220 for (int i = 0; i < width; i++) { |
222 device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale)); | 221 device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale)); |
223 } | 222 } |
224 device += fDevice.rowBytes(); | 223 device += fDevice.rowBytes(); |
225 } | 224 } |
226 } | 225 } |
227 } | 226 } |
228 | 227 |
229 /////////////////////////////////////////////////////////////////////// | 228 /////////////////////////////////////////////////////////////////////// |
230 | 229 |
231 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint&
paint, | 230 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint&
paint, |
232 SkShader::Context* shaderContext) | 231 SkShader::Context* shaderContext) |
233 : INHERITED(device, paint, shaderContext) { | 232 : INHERITED(device, paint, shaderContext) |
| 233 { |
234 if ((fXfermode = paint.getXfermode()) != NULL) { | 234 if ((fXfermode = paint.getXfermode()) != NULL) { |
235 fXfermode->ref(); | 235 fXfermode->ref(); |
236 SkASSERT(fShaderContext); | 236 SkASSERT(fShaderContext); |
237 } | 237 } |
238 | 238 |
239 int width = device.width(); | 239 int width = device.width(); |
240 fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4
(width) >> 2))); | 240 fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4
(width) >> 2))); |
241 fAAExpand = (uint8_t*)(fBuffer + width); | 241 fAAExpand = (uint8_t*)(fBuffer + width); |
242 } | 242 } |
243 | 243 |
244 SkA8_Shader_Blitter::~SkA8_Shader_Blitter() { | 244 SkA8_Shader_Blitter::~SkA8_Shader_Blitter() { |
245 if (fXfermode) SkSafeUnref(fXfermode); | 245 if (fXfermode) SkSafeUnref(fXfermode); |
246 sk_free(fBuffer); | 246 sk_free(fBuffer); |
247 } | 247 } |
248 | 248 |
249 void SkA8_Shader_Blitter::blitH(int x, int y, int width) { | 249 void SkA8_Shader_Blitter::blitH(int x, int y, int width) { |
250 SkASSERT(x >= 0 && y >= 0 && | 250 SkASSERT(x >= 0 && y >= 0 && |
251 (unsigned)(x + width) <= (unsigned)fDevice.width()); | 251 (unsigned)(x + width) <= (unsigned)fDevice.width()); |
252 | 252 |
253 uint8_t* device = fDevice.getAddr8(x, y); | 253 uint8_t* device = fDevice.writable_addr8(x, y); |
254 SkShader::Context* shaderContext = fShaderContext; | 254 SkShader::Context* shaderContext = fShaderContext; |
255 | 255 |
256 if ((shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) && !fXfermode)
{ | 256 if ((shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) && !fXfermode)
{ |
257 memset(device, 0xFF, width); | 257 memset(device, 0xFF, width); |
258 } else { | 258 } else { |
259 SkPMColor* span = fBuffer; | 259 SkPMColor* span = fBuffer; |
260 | 260 |
261 shaderContext->shadeSpan(x, y, span, width); | 261 shaderContext->shadeSpan(x, y, span, width); |
262 if (fXfermode) { | 262 if (fXfermode) { |
263 fXfermode->xferA8(device, span, width, NULL); | 263 fXfermode->xferA8(device, span, width, NULL); |
(...skipping 17 matching lines...) Expand all Loading... |
281 | 281 |
282 return SkToU8((sa * src_scale + da * dst_scale) >> 8); | 282 return SkToU8((sa * src_scale + da * dst_scale) >> 8); |
283 } | 283 } |
284 | 284 |
285 void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 285 void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
286 const int16_t runs[]) { | 286 const int16_t runs[]) { |
287 SkShader::Context* shaderContext = fShaderContext; | 287 SkShader::Context* shaderContext = fShaderContext; |
288 SkXfermode* mode = fXfermode; | 288 SkXfermode* mode = fXfermode; |
289 uint8_t* aaExpand = fAAExpand; | 289 uint8_t* aaExpand = fAAExpand; |
290 SkPMColor* span = fBuffer; | 290 SkPMColor* span = fBuffer; |
291 uint8_t* device = fDevice.getAddr8(x, y); | 291 uint8_t* device = fDevice.writable_addr8(x, y); |
292 int opaque = shaderContext->getFlags() & SkShader::kOpaqueAlp
ha_Flag; | 292 int opaque = shaderContext->getFlags() & SkShader::kOpaqueAlp
ha_Flag; |
293 | 293 |
294 for (;;) { | 294 for (;;) { |
295 int count = *runs; | 295 int count = *runs; |
296 if (count == 0) { | 296 if (count == 0) { |
297 break; | 297 break; |
298 } | 298 } |
299 int aa = *antialias; | 299 int aa = *antialias; |
300 if (aa) { | 300 if (aa) { |
301 if (opaque && aa == 255 && mode == NULL) { | 301 if (opaque && aa == 255 && mode == NULL) { |
(...skipping 20 matching lines...) Expand all Loading... |
322 void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 322 void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
323 if (mask.fFormat == SkMask::kBW_Format) { | 323 if (mask.fFormat == SkMask::kBW_Format) { |
324 this->INHERITED::blitMask(mask, clip); | 324 this->INHERITED::blitMask(mask, clip); |
325 return; | 325 return; |
326 } | 326 } |
327 | 327 |
328 int x = clip.fLeft; | 328 int x = clip.fLeft; |
329 int y = clip.fTop; | 329 int y = clip.fTop; |
330 int width = clip.width(); | 330 int width = clip.width(); |
331 int height = clip.height(); | 331 int height = clip.height(); |
332 uint8_t* device = fDevice.getAddr8(x, y); | 332 uint8_t* device = fDevice.writable_addr8(x, y); |
333 const uint8_t* alpha = mask.getAddr8(x, y); | 333 const uint8_t* alpha = mask.getAddr8(x, y); |
334 SkShader::Context* shaderContext = fShaderContext; | 334 SkShader::Context* shaderContext = fShaderContext; |
335 | 335 |
336 SkPMColor* span = fBuffer; | 336 SkPMColor* span = fBuffer; |
337 | 337 |
338 while (--height >= 0) { | 338 while (--height >= 0) { |
339 shaderContext->shadeSpan(x, y, span, width); | 339 shaderContext->shadeSpan(x, y, span, width); |
340 if (fXfermode) { | 340 if (fXfermode) { |
341 fXfermode->xferA8(device, span, width, alpha); | 341 fXfermode->xferA8(device, span, width, alpha); |
342 } else { | 342 } else { |
343 for (int i = width - 1; i >= 0; --i) { | 343 for (int i = width - 1; i >= 0; --i) { |
344 device[i] = aa_blend8(span[i], device[i], alpha[i]); | 344 device[i] = aa_blend8(span[i], device[i], alpha[i]); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 y += 1; | 348 y += 1; |
349 device += fDevice.rowBytes(); | 349 device += fDevice.rowBytes(); |
350 alpha += mask.fRowBytes; | 350 alpha += mask.fRowBytes; |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 /////////////////////////////////////////////////////////////////////////////// | 354 /////////////////////////////////////////////////////////////////////////////// |
355 | 355 |
356 SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkBitmap& device, | 356 SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device, |
357 const SkPaint& paint) : SkRasterBlitter(device) { | 357 const SkPaint& paint) : SkRasterBlitter(device) { |
358 SkASSERT(NULL == paint.getShader()); | 358 SkASSERT(NULL == paint.getShader()); |
359 SkASSERT(NULL == paint.getXfermode()); | 359 SkASSERT(NULL == paint.getXfermode()); |
360 SkASSERT(NULL == paint.getColorFilter()); | 360 SkASSERT(NULL == paint.getColorFilter()); |
361 } | 361 } |
362 | 362 |
363 void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 363 void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
364 const int16_t runs[]) { | 364 const int16_t runs[]) { |
365 uint8_t* device = fDevice.getAddr8(x, y); | 365 uint8_t* device = fDevice.writable_addr8(x, y); |
366 SkDEBUGCODE(int totalCount = 0;) | 366 SkDEBUGCODE(int totalCount = 0;) |
367 | 367 |
368 for (;;) { | 368 for (;;) { |
369 int count = runs[0]; | 369 int count = runs[0]; |
370 SkASSERT(count >= 0); | 370 SkASSERT(count >= 0); |
371 if (count == 0) { | 371 if (count == 0) { |
372 return; | 372 return; |
373 } | 373 } |
374 if (antialias[0]) { | 374 if (antialias[0]) { |
375 memset(device, antialias[0], count); | 375 memset(device, antialias[0], count); |
376 } | 376 } |
377 runs += count; | 377 runs += count; |
378 antialias += count; | 378 antialias += count; |
379 device += count; | 379 device += count; |
380 | 380 |
381 SkDEBUGCODE(totalCount += count;) | 381 SkDEBUGCODE(totalCount += count;) |
382 } | 382 } |
383 SkASSERT(fDevice.width() == totalCount); | 383 SkASSERT(fDevice.width() == totalCount); |
384 } | 384 } |
385 | 385 |
386 void SkA8_Coverage_Blitter::blitH(int x, int y, int width) { | 386 void SkA8_Coverage_Blitter::blitH(int x, int y, int width) { |
387 memset(fDevice.getAddr8(x, y), 0xFF, width); | 387 memset(fDevice.writable_addr8(x, y), 0xFF, width); |
388 } | 388 } |
389 | 389 |
390 void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 390 void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
391 if (0 == alpha) { | 391 if (0 == alpha) { |
392 return; | 392 return; |
393 } | 393 } |
394 | 394 |
395 uint8_t* dst = fDevice.getAddr8(x, y); | 395 uint8_t* dst = fDevice.writable_addr8(x, y); |
396 const size_t dstRB = fDevice.rowBytes(); | 396 const size_t dstRB = fDevice.rowBytes(); |
397 while (--height >= 0) { | 397 while (--height >= 0) { |
398 *dst = alpha; | 398 *dst = alpha; |
399 dst += dstRB; | 399 dst += dstRB; |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 void SkA8_Coverage_Blitter::blitRect(int x, int y, int width, int height) { | 403 void SkA8_Coverage_Blitter::blitRect(int x, int y, int width, int height) { |
404 uint8_t* dst = fDevice.getAddr8(x, y); | 404 uint8_t* dst = fDevice.writable_addr8(x, y); |
405 const size_t dstRB = fDevice.rowBytes(); | 405 const size_t dstRB = fDevice.rowBytes(); |
406 while (--height >= 0) { | 406 while (--height >= 0) { |
407 memset(dst, 0xFF, width); | 407 memset(dst, 0xFF, width); |
408 dst += dstRB; | 408 dst += dstRB; |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 412 void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
413 SkASSERT(SkMask::kA8_Format == mask.fFormat); | 413 SkASSERT(SkMask::kA8_Format == mask.fFormat); |
414 | 414 |
415 int x = clip.fLeft; | 415 int x = clip.fLeft; |
416 int y = clip.fTop; | 416 int y = clip.fTop; |
417 int width = clip.width(); | 417 int width = clip.width(); |
418 int height = clip.height(); | 418 int height = clip.height(); |
419 | 419 |
420 uint8_t* dst = fDevice.getAddr8(x, y); | 420 uint8_t* dst = fDevice.writable_addr8(x, y); |
421 const uint8_t* src = mask.getAddr8(x, y); | 421 const uint8_t* src = mask.getAddr8(x, y); |
422 const size_t srcRB = mask.fRowBytes; | 422 const size_t srcRB = mask.fRowBytes; |
423 const size_t dstRB = fDevice.rowBytes(); | 423 const size_t dstRB = fDevice.rowBytes(); |
424 | 424 |
425 while (--height >= 0) { | 425 while (--height >= 0) { |
426 memcpy(dst, src, width); | 426 memcpy(dst, src, width); |
427 dst += dstRB; | 427 dst += dstRB; |
428 src += srcRB; | 428 src += srcRB; |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 const SkBitmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { | 432 const SkPixmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { |
433 return NULL; | 433 return NULL; |
434 } | 434 } |
OLD | NEW |