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