Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: src/core/SkBlitter_ARGB32.cpp

Issue 1164373003: Revert of change SkDraw and all Blitters to use pixmap instead of bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBlitter_A8.cpp ('k') | src/core/SkBlitter_RGB16.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkUtils.h" 11 #include "SkUtils.h"
12 #include "SkXfermode.h" 12 #include "SkXfermode.h"
13 #include "SkBlitMask.h" 13 #include "SkBlitMask.h"
14 14
15 /////////////////////////////////////////////////////////////////////////////// 15 ///////////////////////////////////////////////////////////////////////////////
16 16
17 static void SkARGB32_Blit32(const SkPixmap& device, const SkMask& mask, 17 static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask,
18 const SkIRect& clip, SkPMColor srcColor) { 18 const SkIRect& clip, SkPMColor srcColor) {
19 U8CPU alpha = SkGetPackedA32(srcColor); 19 U8CPU alpha = SkGetPackedA32(srcColor);
20 unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32; 20 unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32;
21 if (alpha != 255) { 21 if (alpha != 255) {
22 flags |= SkBlitRow::kGlobalAlpha_Flag32; 22 flags |= SkBlitRow::kGlobalAlpha_Flag32;
23 } 23 }
24 SkBlitRow::Proc32 proc = SkBlitRow::Factory32(flags); 24 SkBlitRow::Proc32 proc = SkBlitRow::Factory32(flags);
25 25
26 int x = clip.fLeft; 26 int x = clip.fLeft;
27 int y = clip.fTop; 27 int y = clip.fTop;
28 int width = clip.width(); 28 int width = clip.width();
29 int height = clip.height(); 29 int height = clip.height();
30 30
31 SkPMColor* dstRow = device.writable_addr32(x, y); 31 SkPMColor* dstRow = device.getAddr32(x, y);
32 const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr8(x , y)); 32 const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr8(x , y));
33 33
34 do { 34 do {
35 proc(dstRow, srcRow, width, alpha); 35 proc(dstRow, srcRow, width, alpha);
36 dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes()); 36 dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes());
37 srcRow = (const SkPMColor*)((const char*)srcRow + mask.fRowBytes); 37 srcRow = (const SkPMColor*)((const char*)srcRow + mask.fRowBytes);
38 } while (--height != 0); 38 } while (--height != 0);
39 } 39 }
40 40
41 //////////////////////////////////////////////////////////////////////////////// ////// 41 //////////////////////////////////////////////////////////////////////////////// //////
42 42
43 SkARGB32_Blitter::SkARGB32_Blitter(const SkPixmap& device, const SkPaint& paint) 43 SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint)
44 : INHERITED(device) { 44 : INHERITED(device) {
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 } 55 }
56 56
57 const SkPixmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { 57 const SkBitmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) {
58 if (255 == fSrcA) { 58 if (255 == fSrcA) {
59 *value = fPMColor; 59 *value = fPMColor;
60 return &fDevice; 60 return &fDevice;
61 } 61 }
62 return NULL; 62 return NULL;
63 } 63 }
64 64
65 #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
66 #pragma warning ( push ) 66 #pragma warning ( push )
67 #pragma warning ( disable : 4701 ) 67 #pragma warning ( disable : 4701 )
68 #endif 68 #endif
69 69
70 void SkARGB32_Blitter::blitH(int x, int y, int width) { 70 void SkARGB32_Blitter::blitH(int x, int y, int width) {
71 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); 71 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
72 72
73 uint32_t* device = fDevice.writable_addr32(x, y); 73 uint32_t* device = fDevice.getAddr32(x, y);
74 SkBlitRow::Color32(device, device, width, fPMColor); 74 SkBlitRow::Color32(device, device, width, fPMColor);
75 } 75 }
76 76
77 void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 77 void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
78 const int16_t runs[]) { 78 const int16_t runs[]) {
79 if (fSrcA == 0) { 79 if (fSrcA == 0) {
80 return; 80 return;
81 } 81 }
82 82
83 uint32_t color = fPMColor; 83 uint32_t color = fPMColor;
84 uint32_t* device = fDevice.writable_addr32(x, y); 84 uint32_t* device = fDevice.getAddr32(x, y);
85 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
86 86
87 for (;;) { 87 for (;;) {
88 int count = runs[0]; 88 int count = runs[0];
89 SkASSERT(count >= 0); 89 SkASSERT(count >= 0);
90 if (count <= 0) { 90 if (count <= 0) {
91 return; 91 return;
92 } 92 }
93 unsigned aa = antialias[0]; 93 unsigned aa = antialias[0];
94 if (aa) { 94 if (aa) {
95 if ((opaqueMask & aa) == 255) { 95 if ((opaqueMask & aa) == 255) {
96 sk_memset32(device, color, count); 96 sk_memset32(device, color, count);
97 } else { 97 } else {
98 uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa)); 98 uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa));
99 SkBlitRow::Color32(device, device, count, sc); 99 SkBlitRow::Color32(device, device, count, sc);
100 } 100 }
101 } 101 }
102 runs += count; 102 runs += count;
103 antialias += count; 103 antialias += count;
104 device += count; 104 device += count;
105 } 105 }
106 } 106 }
107 107
108 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) {
109 uint32_t* device = fDevice.writable_addr32(x, y); 109 uint32_t* device = fDevice.getAddr32(x, y);
110 SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);) 110 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
111 111
112 device[0] = SkBlendARGB32(fPMColor, device[0], a0); 112 device[0] = SkBlendARGB32(fPMColor, device[0], a0);
113 device[1] = SkBlendARGB32(fPMColor, device[1], a1); 113 device[1] = SkBlendARGB32(fPMColor, device[1], a1);
114 } 114 }
115 115
116 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) {
117 uint32_t* device = fDevice.writable_addr32(x, y); 117 uint32_t* device = fDevice.getAddr32(x, y);
118 SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);) 118 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
119 119
120 device[0] = SkBlendARGB32(fPMColor, device[0], a0); 120 device[0] = SkBlendARGB32(fPMColor, device[0], a0);
121 device = (uint32_t*)((char*)device + fDevice.rowBytes()); 121 device = (uint32_t*)((char*)device + fDevice.rowBytes());
122 device[0] = SkBlendARGB32(fPMColor, device[0], a1); 122 device[0] = SkBlendARGB32(fPMColor, device[0], a1);
123 } 123 }
124 124
125 //////////////////////////////////////////////////////////////////////////////// ////// 125 //////////////////////////////////////////////////////////////////////////////// //////
126 126
127 #define solid_8_pixels(mask, dst, color) \ 127 #define solid_8_pixels(mask, dst, color) \
128 do { \ 128 do { \
129 if (mask & 0x80) dst[0] = color; \ 129 if (mask & 0x80) dst[0] = color; \
130 if (mask & 0x40) dst[1] = color; \ 130 if (mask & 0x40) dst[1] = color; \
131 if (mask & 0x20) dst[2] = color; \ 131 if (mask & 0x20) dst[2] = color; \
132 if (mask & 0x10) dst[3] = color; \ 132 if (mask & 0x10) dst[3] = color; \
133 if (mask & 0x08) dst[4] = color; \ 133 if (mask & 0x08) dst[4] = color; \
134 if (mask & 0x04) dst[5] = color; \ 134 if (mask & 0x04) dst[5] = color; \
135 if (mask & 0x02) dst[6] = color; \ 135 if (mask & 0x02) dst[6] = color; \
136 if (mask & 0x01) dst[7] = color; \ 136 if (mask & 0x01) dst[7] = color; \
137 } while (0) 137 } while (0)
138 138
139 #define SK_BLITBWMASK_NAME SkARGB32_BlitBW 139 #define SK_BLITBWMASK_NAME SkARGB32_BlitBW
140 #define SK_BLITBWMASK_ARGS , SkPMColor color 140 #define SK_BLITBWMASK_ARGS , SkPMColor color
141 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color) 141 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color)
142 #define SK_BLITBWMASK_GETADDR writable_addr32 142 #define SK_BLITBWMASK_GETADDR getAddr32
143 #define SK_BLITBWMASK_DEVTYPE uint32_t 143 #define SK_BLITBWMASK_DEVTYPE uint32_t
144 #include "SkBlitBWMaskTemplate.h" 144 #include "SkBlitBWMaskTemplate.h"
145 145
146 #define blend_8_pixels(mask, dst, sc, dst_scale) \ 146 #define blend_8_pixels(mask, dst, sc, dst_scale) \
147 do { \ 147 do { \
148 if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); } \ 148 if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); } \
149 if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); } \ 149 if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); } \
150 if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); } \ 150 if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); } \
151 if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); } \ 151 if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); } \
152 if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); } \ 152 if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); } \
153 if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); } \ 153 if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); } \
154 if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); } \ 154 if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); } \
155 if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); } \ 155 if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); } \
156 } while (0) 156 } while (0)
157 157
158 #define SK_BLITBWMASK_NAME SkARGB32_BlendBW 158 #define SK_BLITBWMASK_NAME SkARGB32_BlendBW
159 #define SK_BLITBWMASK_ARGS , uint32_t sc, unsigned dst_scale 159 #define SK_BLITBWMASK_ARGS , uint32_t sc, unsigned dst_scale
160 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sc, dst_sc ale) 160 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, sc, dst_sc ale)
161 #define SK_BLITBWMASK_GETADDR writable_addr32 161 #define SK_BLITBWMASK_GETADDR getAddr32
162 #define SK_BLITBWMASK_DEVTYPE uint32_t 162 #define SK_BLITBWMASK_DEVTYPE uint32_t
163 #include "SkBlitBWMaskTemplate.h" 163 #include "SkBlitBWMaskTemplate.h"
164 164
165 void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { 165 void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
166 SkASSERT(mask.fBounds.contains(clip)); 166 SkASSERT(mask.fBounds.contains(clip));
167 SkASSERT(fSrcA != 0xFF); 167 SkASSERT(fSrcA != 0xFF);
168 168
169 if (fSrcA == 0) { 169 if (fSrcA == 0) {
170 return; 170 return;
171 } 171 }
(...skipping 18 matching lines...) Expand all
190 } 190 }
191 191
192 if (mask.fFormat == SkMask::kBW_Format) { 192 if (mask.fFormat == SkMask::kBW_Format) {
193 SkARGB32_BlitBW(fDevice, mask, clip, fPMColor); 193 SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
194 } else if (SkMask::kARGB32_Format == mask.fFormat) { 194 } else if (SkMask::kARGB32_Format == mask.fFormat) {
195 SkARGB32_Blit32(fDevice, mask, clip, fPMColor); 195 SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
196 } 196 }
197 } 197 }
198 198
199 void SkARGB32_Opaque_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { 199 void SkARGB32_Opaque_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
200 uint32_t* device = fDevice.writable_addr32(x, y); 200 uint32_t* device = fDevice.getAddr32(x, y);
201 SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);) 201 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
202 202
203 device[0] = SkFastFourByteInterp(fPMColor, device[0], a0); 203 device[0] = SkFastFourByteInterp(fPMColor, device[0], a0);
204 device[1] = SkFastFourByteInterp(fPMColor, device[1], a1); 204 device[1] = SkFastFourByteInterp(fPMColor, device[1], a1);
205 } 205 }
206 206
207 void SkARGB32_Opaque_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { 207 void SkARGB32_Opaque_Blitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
208 uint32_t* device = fDevice.writable_addr32(x, y); 208 uint32_t* device = fDevice.getAddr32(x, y);
209 SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);) 209 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
210 210
211 device[0] = SkFastFourByteInterp(fPMColor, device[0], a0); 211 device[0] = SkFastFourByteInterp(fPMColor, device[0], a0);
212 device = (uint32_t*)((char*)device + fDevice.rowBytes()); 212 device = (uint32_t*)((char*)device + fDevice.rowBytes());
213 device[0] = SkFastFourByteInterp(fPMColor, device[0], a1); 213 device[0] = SkFastFourByteInterp(fPMColor, device[0], a1);
214 } 214 }
215 215
216 /////////////////////////////////////////////////////////////////////////////// 216 ///////////////////////////////////////////////////////////////////////////////
217 217
218 void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 218 void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
219 if (alpha == 0 || fSrcA == 0) { 219 if (alpha == 0 || fSrcA == 0) {
220 return; 220 return;
221 } 221 }
222 222
223 uint32_t* device = fDevice.writable_addr32(x, y); 223 uint32_t* device = fDevice.getAddr32(x, y);
224 uint32_t color = fPMColor; 224 uint32_t color = fPMColor;
225 225
226 if (alpha != 255) { 226 if (alpha != 255) {
227 color = SkAlphaMulQ(color, SkAlpha255To256(alpha)); 227 color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
228 } 228 }
229 229
230 unsigned dst_scale = 255 - SkGetPackedA32(color); 230 unsigned dst_scale = 255 - SkGetPackedA32(color);
231 size_t rowBytes = fDevice.rowBytes(); 231 size_t rowBytes = fDevice.rowBytes();
232 while (--height >= 0) { 232 while (--height >= 0) {
233 device[0] = color + SkAlphaMulQ(device[0], dst_scale); 233 device[0] = color + SkAlphaMulQ(device[0], dst_scale);
234 device = (uint32_t*)((char*)device + rowBytes); 234 device = (uint32_t*)((char*)device + rowBytes);
235 } 235 }
236 } 236 }
237 237
238 void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) { 238 void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) {
239 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= f Device.height()); 239 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= f Device.height());
240 240
241 if (fSrcA == 0) { 241 if (fSrcA == 0) {
242 return; 242 return;
243 } 243 }
244 244
245 uint32_t* device = fDevice.writable_addr32(x, y); 245 uint32_t* device = fDevice.getAddr32(x, y);
246 uint32_t color = fPMColor; 246 uint32_t color = fPMColor;
247 size_t rowBytes = fDevice.rowBytes(); 247 size_t rowBytes = fDevice.rowBytes();
248 248
249 while (--height >= 0) { 249 while (--height >= 0) {
250 SkBlitRow::Color32(device, device, width, color); 250 SkBlitRow::Color32(device, device, width, color);
251 device = (uint32_t*)((char*)device + rowBytes); 251 device = (uint32_t*)((char*)device + rowBytes);
252 } 252 }
253 } 253 }
254 254
255 #if defined _WIN32 && _MSC_VER >= 1300 255 #if defined _WIN32 && _MSC_VER >= 1300
256 #pragma warning ( pop ) 256 #pragma warning ( pop )
257 #endif 257 #endif
258 258
259 /////////////////////////////////////////////////////////////////////// 259 ///////////////////////////////////////////////////////////////////////
260 260
261 void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 261 void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
262 const int16_t runs[]) { 262 const int16_t runs[]) {
263 uint32_t* device = fDevice.writable_addr32(x, y); 263 uint32_t* device = fDevice.getAddr32(x, y);
264 SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT); 264 SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT);
265 265
266 for (;;) { 266 for (;;) {
267 int count = runs[0]; 267 int count = runs[0];
268 SkASSERT(count >= 0); 268 SkASSERT(count >= 0);
269 if (count <= 0) { 269 if (count <= 0) {
270 return; 270 return;
271 } 271 }
272 unsigned aa = antialias[0]; 272 unsigned aa = antialias[0];
273 if (aa) { 273 if (aa) {
274 if (aa == 255) { 274 if (aa == 255) {
275 sk_memset32(device, black, count); 275 sk_memset32(device, black, count);
276 } else { 276 } else {
277 SkPMColor src = aa << SK_A32_SHIFT; 277 SkPMColor src = aa << SK_A32_SHIFT;
278 unsigned dst_scale = 256 - aa; 278 unsigned dst_scale = 256 - aa;
279 int n = count; 279 int n = count;
280 do { 280 do {
281 --n; 281 --n;
282 device[n] = src + SkAlphaMulQ(device[n], dst_scale); 282 device[n] = src + SkAlphaMulQ(device[n], dst_scale);
283 } while (n > 0); 283 } while (n > 0);
284 } 284 }
285 } 285 }
286 runs += count; 286 runs += count;
287 antialias += count; 287 antialias += count;
288 device += count; 288 device += count;
289 } 289 }
290 } 290 }
291 291
292 void SkARGB32_Black_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { 292 void SkARGB32_Black_Blitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
293 uint32_t* device = fDevice.writable_addr32(x, y); 293 uint32_t* device = fDevice.getAddr32(x, y);
294 SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);) 294 SkDEBUGCODE((void)fDevice.getAddr32(x + 1, y);)
295 295
296 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); 296 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0);
297 device[1] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[1], 256 - a1); 297 device[1] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[1], 256 - a1);
298 } 298 }
299 299
300 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) {
301 uint32_t* device = fDevice.writable_addr32(x, y); 301 uint32_t* device = fDevice.getAddr32(x, y);
302 SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);) 302 SkDEBUGCODE((void)fDevice.getAddr32(x, y + 1);)
303 303
304 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0); 304 device[0] = (a0 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a0);
305 device = (uint32_t*)((char*)device + fDevice.rowBytes()); 305 device = (uint32_t*)((char*)device + fDevice.rowBytes());
306 device[0] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a1); 306 device[0] = (a1 << SK_A32_SHIFT) + SkAlphaMulQ(device[0], 256 - a1);
307 } 307 }
308 308
309 /////////////////////////////////////////////////////////////////////////////// 309 ///////////////////////////////////////////////////////////////////////////////
310 310
311 // 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,
312 // instead of kSrcOver_Mode 312 // instead of kSrcOver_Mode
313 static void blend_srcmode(SkPMColor* SK_RESTRICT device, 313 static void blend_srcmode(SkPMColor* SK_RESTRICT device,
314 const SkPMColor* SK_RESTRICT span, 314 const SkPMColor* SK_RESTRICT span,
315 int count, U8CPU aa) { 315 int count, U8CPU aa) {
316 int aa256 = SkAlpha255To256(aa); 316 int aa256 = SkAlpha255To256(aa);
317 for (int i = 0; i < count; ++i) { 317 for (int i = 0; i < count; ++i) {
318 device[i] = SkFourByteInterp256(span[i], device[i], aa256); 318 device[i] = SkFourByteInterp256(span[i], device[i], aa256);
319 } 319 }
320 } 320 }
321 321
322 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device, 322 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device,
323 const SkPaint& paint, SkShader::Context* shaderContext) 323 const SkPaint& paint, SkShader::Context* shaderContext)
324 : INHERITED(device, paint, shaderContext) 324 : INHERITED(device, paint, shaderContext)
325 { 325 {
326 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); 326 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
327 327
328 fXfermode = paint.getXfermode(); 328 fXfermode = paint.getXfermode();
329 SkSafeRef(fXfermode); 329 SkSafeRef(fXfermode);
330 330
331 int flags = 0; 331 int flags = 0;
332 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { 332 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) {
(...skipping 23 matching lines...) Expand all
356 } 356 }
357 357
358 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { 358 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() {
359 SkSafeUnref(fXfermode); 359 SkSafeUnref(fXfermode);
360 sk_free(fBuffer); 360 sk_free(fBuffer);
361 } 361 }
362 362
363 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { 363 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) {
364 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); 364 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
365 365
366 uint32_t* device = fDevice.writable_addr32(x, y); 366 uint32_t* device = fDevice.getAddr32(x, y);
367 367
368 if (fShadeDirectlyIntoDevice) { 368 if (fShadeDirectlyIntoDevice) {
369 fShaderContext->shadeSpan(x, y, device, width); 369 fShaderContext->shadeSpan(x, y, device, width);
370 } else { 370 } else {
371 SkPMColor* span = fBuffer; 371 SkPMColor* span = fBuffer;
372 fShaderContext->shadeSpan(x, y, span, width); 372 fShaderContext->shadeSpan(x, y, span, width);
373 if (fXfermode) { 373 if (fXfermode) {
374 fXfermode->xfer32(device, span, width, NULL); 374 fXfermode->xfer32(device, span, width, NULL);
375 } else { 375 } else {
376 fProc32(device, span, width, 255); 376 fProc32(device, span, width, 255);
377 } 377 }
378 } 378 }
379 } 379 }
380 380
381 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { 381 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
382 SkASSERT(x >= 0 && y >= 0 && 382 SkASSERT(x >= 0 && y >= 0 &&
383 x + width <= fDevice.width() && y + height <= fDevice.height()); 383 x + width <= fDevice.width() && y + height <= fDevice.height());
384 384
385 uint32_t* device = fDevice.writable_addr32(x, y); 385 uint32_t* device = fDevice.getAddr32(x, y);
386 size_t deviceRB = fDevice.rowBytes(); 386 size_t deviceRB = fDevice.rowBytes();
387 SkShader::Context* shaderContext = fShaderContext; 387 SkShader::Context* shaderContext = fShaderContext;
388 SkPMColor* span = fBuffer; 388 SkPMColor* span = fBuffer;
389 389
390 if (fConstInY) { 390 if (fConstInY) {
391 if (fShadeDirectlyIntoDevice) { 391 if (fShadeDirectlyIntoDevice) {
392 // shade the first row directly into the device 392 // shade the first row directly into the device
393 shaderContext->shadeSpan(x, y, device, width); 393 shaderContext->shadeSpan(x, y, device, width);
394 span = device; 394 span = device;
395 while (--height > 0) { 395 while (--height > 0) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 y += 1; 450 y += 1;
451 device = (uint32_t*)((char*)device + deviceRB); 451 device = (uint32_t*)((char*)device + deviceRB);
452 } while (--height > 0); 452 } while (--height > 0);
453 } 453 }
454 } 454 }
455 } 455 }
456 456
457 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], 457 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
458 const int16_t runs[]) { 458 const int16_t runs[]) {
459 SkPMColor* span = fBuffer; 459 SkPMColor* span = fBuffer;
460 uint32_t* device = fDevice.writable_addr32(x, y); 460 uint32_t* device = fDevice.getAddr32(x, y);
461 SkShader::Context* shaderContext = fShaderContext; 461 SkShader::Context* shaderContext = fShaderContext;
462 462
463 if (fXfermode && !fShadeDirectlyIntoDevice) { 463 if (fXfermode && !fShadeDirectlyIntoDevice) {
464 for (;;) { 464 for (;;) {
465 SkXfermode* xfer = fXfermode; 465 SkXfermode* xfer = fXfermode;
466 466
467 int count = *runs; 467 int count = *runs;
468 if (count <= 0) 468 if (count <= 0)
469 break; 469 break;
470 int aa = *antialias; 470 int aa = *antialias;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 this->INHERITED::blitMask(mask, clip); 551 this->INHERITED::blitMask(mask, clip);
552 return; 552 return;
553 } 553 }
554 } 554 }
555 555
556 const int x = clip.fLeft; 556 const int x = clip.fLeft;
557 const int width = clip.width(); 557 const int width = clip.width();
558 int y = clip.fTop; 558 int y = clip.fTop;
559 int height = clip.height(); 559 int height = clip.height();
560 560
561 char* dstRow = (char*)fDevice.writable_addr32(x, y); 561 char* dstRow = (char*)fDevice.getAddr32(x, y);
562 const size_t dstRB = fDevice.rowBytes(); 562 const size_t dstRB = fDevice.rowBytes();
563 const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); 563 const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
564 const size_t maskRB = mask.fRowBytes; 564 const size_t maskRB = mask.fRowBytes;
565 565
566 SkPMColor* span = fBuffer; 566 SkPMColor* span = fBuffer;
567 567
568 if (fXfermode) { 568 if (fXfermode) {
569 SkASSERT(SkMask::kA8_Format == mask.fFormat); 569 SkASSERT(SkMask::kA8_Format == mask.fFormat);
570 SkXfermode* xfer = fXfermode; 570 SkXfermode* xfer = fXfermode;
571 do { 571 do {
(...skipping 10 matching lines...) Expand all
582 dstRow += dstRB; 582 dstRow += dstRB;
583 maskRow += maskRB; 583 maskRow += maskRB;
584 y += 1; 584 y += 1;
585 } while (--height > 0); 585 } while (--height > 0);
586 } 586 }
587 } 587 }
588 588
589 void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 589 void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
590 SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); 590 SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height());
591 591
592 uint32_t* device = fDevice.writable_addr32(x, y); 592 uint32_t* device = fDevice.getAddr32(x, y);
593 size_t deviceRB = fDevice.rowBytes(); 593 size_t deviceRB = fDevice.rowBytes();
594 SkShader::Context* shaderContext = fShaderContext; 594 SkShader::Context* shaderContext = fShaderContext;
595 595
596 if (fConstInY) { 596 if (fConstInY) {
597 SkPMColor c; 597 SkPMColor c;
598 shaderContext->shadeSpan(x, y, &c, 1); 598 shaderContext->shadeSpan(x, y, &c, 1);
599 599
600 if (fShadeDirectlyIntoDevice) { 600 if (fShadeDirectlyIntoDevice) {
601 if (255 == alpha) { 601 if (255 == alpha) {
602 do { 602 do {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; 676 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend;
677 do { 677 do {
678 shaderContext->shadeSpan(x, y, span, 1); 678 shaderContext->shadeSpan(x, y, span, 1);
679 proc(device, span, 1, alpha); 679 proc(device, span, 1, alpha);
680 y += 1; 680 y += 1;
681 device = (uint32_t*)((char*)device + deviceRB); 681 device = (uint32_t*)((char*)device + deviceRB);
682 } while (--height > 0); 682 } while (--height > 0);
683 } 683 }
684 } 684 }
685 } 685 }
OLDNEW
« no previous file with comments | « src/core/SkBlitter_A8.cpp ('k') | src/core/SkBlitter_RGB16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698