OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCoreBlitters.h" | 8 #include "SkCoreBlitters.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 SkColor color = paint.getColor(); | 45 SkColor color = paint.getColor(); |
46 fColor = color; | 46 fColor = color; |
47 | 47 |
48 fSrcA = SkColorGetA(color); | 48 fSrcA = SkColorGetA(color); |
49 unsigned scale = SkAlpha255To256(fSrcA); | 49 unsigned scale = SkAlpha255To256(fSrcA); |
50 fSrcR = SkAlphaMul(SkColorGetR(color), scale); | 50 fSrcR = SkAlphaMul(SkColorGetR(color), scale); |
51 fSrcG = SkAlphaMul(SkColorGetG(color), scale); | 51 fSrcG = SkAlphaMul(SkColorGetG(color), scale); |
52 fSrcB = SkAlphaMul(SkColorGetB(color), scale); | 52 fSrcB = SkAlphaMul(SkColorGetB(color), scale); |
53 | 53 |
54 fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); | 54 fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); |
| 55 fColor32Proc = SkBlitRow::ColorProcFactory(); |
55 } | 56 } |
56 | 57 |
57 const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { | 58 const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { |
58 if (255 == fSrcA) { | 59 if (255 == fSrcA) { |
59 *value = fPMColor; | 60 *value = fPMColor; |
60 return &fDevice; | 61 return &fDevice; |
61 } | 62 } |
62 return NULL; | 63 return NULL; |
63 } | 64 } |
64 | 65 |
65 #if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used
without having been initialized | 66 #if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used
without having been initialized |
66 #pragma warning ( push ) | 67 #pragma warning ( push ) |
67 #pragma warning ( disable : 4701 ) | 68 #pragma warning ( disable : 4701 ) |
68 #endif | 69 #endif |
69 | 70 |
70 void SkARGB32_Blitter::blitH(int x, int y, int width) { | 71 void SkARGB32_Blitter::blitH(int x, int y, int width) { |
71 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); | 72 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); |
72 | 73 |
73 uint32_t* device = fDevice.getAddr32(x, y); | 74 uint32_t* device = fDevice.getAddr32(x, y); |
74 SkBlitRow::Color32(device, device, width, fPMColor); | 75 fColor32Proc(device, device, width, fPMColor); |
75 } | 76 } |
76 | 77 |
77 void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 78 void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
78 const int16_t runs[]) { | 79 const int16_t runs[]) { |
79 if (fSrcA == 0) { | 80 if (fSrcA == 0) { |
80 return; | 81 return; |
81 } | 82 } |
82 | 83 |
83 uint32_t color = fPMColor; | 84 uint32_t color = fPMColor; |
84 uint32_t* device = fDevice.getAddr32(x, y); | 85 uint32_t* device = fDevice.getAddr32(x, y); |
85 unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the
fast opaque case | 86 unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the
fast opaque case |
86 | 87 |
87 for (;;) { | 88 for (;;) { |
88 int count = runs[0]; | 89 int count = runs[0]; |
89 SkASSERT(count >= 0); | 90 SkASSERT(count >= 0); |
90 if (count <= 0) { | 91 if (count <= 0) { |
91 return; | 92 return; |
92 } | 93 } |
93 unsigned aa = antialias[0]; | 94 unsigned aa = antialias[0]; |
94 if (aa) { | 95 if (aa) { |
95 if ((opaqueMask & aa) == 255) { | 96 if ((opaqueMask & aa) == 255) { |
96 sk_memset32(device, color, count); | 97 sk_memset32(device, color, count); |
97 } else { | 98 } else { |
98 uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa)); | 99 uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa)); |
99 SkBlitRow::Color32(device, device, count, sc); | 100 fColor32Proc(device, device, count, sc); |
100 } | 101 } |
101 } | 102 } |
102 runs += count; | 103 runs += count; |
103 antialias += count; | 104 antialias += count; |
104 device += count; | 105 device += count; |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 void SkARGB32_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { | 109 void SkARGB32_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { |
109 uint32_t* device = fDevice.getAddr32(x, y); | 110 uint32_t* device = fDevice.getAddr32(x, y); |
110 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);) | 111 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);) |
111 | 112 |
112 device[0] = SkBlendARGB32(fPMColor, device[0], a0); | 113 device[0] = SkBlendARGB32(fPMColor, device[0], a0); |
113 device[1] = SkBlendARGB32(fPMColor, device[1], a1); | 114 device[1] = SkBlendARGB32(fPMColor, device[1], a1); |
114 } | 115 } |
115 | 116 |
116 void SkARGB32_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { | 117 void SkARGB32_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { |
117 uint32_t* device = fDevice.getAddr32(x, y); | 118 uint32_t* device = fDevice.getAddr32(x, y); |
118 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);) | 119 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);) |
119 | 120 |
120 device[0] = SkBlendARGB32(fPMColor, device[0], a0); | 121 device[0] = SkBlendARGB32(fPMColor, device[0], a0); |
121 device = (uint32_t*)((char*)device + fDevice.rowBytes()); | 122 device = (uint32_t*)((char*)device + fDevice.rowBytes()); |
122 device[0] = SkBlendARGB32(fPMColor, device[0], a1); | 123 device[0] = SkBlendARGB32(fPMColor, device[0], a1); |
123 } | 124 } |
124 | 125 |
125 ////////////////////////////////////////////////////////////////////////////////
////// | 126 ////////////////////////////////////////////////////////////////////////////////
////// |
126 | 127 |
127 #define solid_8_pixels(mask, dst, color) \ | 128 #define solid_8_pixels(mask, dst, color) \ |
128 do { \ | 129 do { \ |
129 if (mask & 0x80) dst[0] = color; \ | 130 if (mask & 0x80) dst[0] = color; \ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 241 |
241 if (fSrcA == 0) { | 242 if (fSrcA == 0) { |
242 return; | 243 return; |
243 } | 244 } |
244 | 245 |
245 uint32_t* device = fDevice.getAddr32(x, y); | 246 uint32_t* device = fDevice.getAddr32(x, y); |
246 uint32_t color = fPMColor; | 247 uint32_t color = fPMColor; |
247 size_t rowBytes = fDevice.rowBytes(); | 248 size_t rowBytes = fDevice.rowBytes(); |
248 | 249 |
249 while (--height >= 0) { | 250 while (--height >= 0) { |
250 SkBlitRow::Color32(device, device, width, color); | 251 fColor32Proc(device, device, width, color); |
251 device = (uint32_t*)((char*)device + rowBytes); | 252 device = (uint32_t*)((char*)device + rowBytes); |
252 } | 253 } |
253 } | 254 } |
254 | 255 |
255 #if defined _WIN32 && _MSC_VER >= 1300 | 256 #if defined _WIN32 && _MSC_VER >= 1300 |
256 #pragma warning ( pop ) | 257 #pragma warning ( pop ) |
257 #endif | 258 #endif |
258 | 259 |
259 /////////////////////////////////////////////////////////////////////// | 260 /////////////////////////////////////////////////////////////////////// |
260 | 261 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 uint32_t* device = fDevice.getAddr32(x, y); | 294 uint32_t* device = fDevice.getAddr32(x, y); |
294 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);) | 295 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);) |
295 | 296 |
296 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); | 297 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); |
297 device[1] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[1], 256 - a1); | 298 device[1] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[1], 256 - a1); |
298 } | 299 } |
299 | 300 |
300 void SkARGB32_Black_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { | 301 void SkARGB32_Black_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { |
301 uint32_t* device = fDevice.getAddr32(x, y); | 302 uint32_t* device = fDevice.getAddr32(x, y); |
302 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);) | 303 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);) |
303 | 304 |
304 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); | 305 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); |
305 device = (uint32_t*)((char*)device + fDevice.rowBytes()); | 306 device = (uint32_t*)((char*)device + fDevice.rowBytes()); |
306 device[0] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a1); | 307 device[0] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a1); |
307 } | 308 } |
308 | 309 |
309 /////////////////////////////////////////////////////////////////////////////// | 310 /////////////////////////////////////////////////////////////////////////////// |
310 | 311 |
311 // Special version of SkBlitRow::Factory32 that knows we're in kSrc_Mode, | 312 // Special version of SkBlitRow::Factory32 that knows we're in kSrc_Mode, |
312 // instead of kSrcOver_Mode | 313 // instead of kSrcOver_Mode |
313 static void blend_srcmode(SkPMColor* SK_RESTRICT device, | 314 static void blend_srcmode(SkPMColor* SK_RESTRICT device, |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; | 677 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; |
677 do { | 678 do { |
678 shaderContext->shadeSpan(x, y, span, 1); | 679 shaderContext->shadeSpan(x, y, span, 1); |
679 proc(device, span, 1, alpha); | 680 proc(device, span, 1, alpha); |
680 y += 1; | 681 y += 1; |
681 device = (uint32_t*)((char*)device + deviceRB); | 682 device = (uint32_t*)((char*)device + deviceRB); |
682 } while (--height > 0); | 683 } while (--height > 0); |
683 } | 684 } |
684 } | 685 } |
685 } | 686 } |
OLD | NEW |