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

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

Issue 1148793007: change SkDraw and all Blitters to use pixmap instead of bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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_ARGB32.cpp ('k') | src/core/SkCanvas.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
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #include "SkBlitRow.h" 8 #include "SkBlitRow.h"
11 #include "SkCoreBlitters.h" 9 #include "SkCoreBlitters.h"
12 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
13 #include "SkDither.h" 11 #include "SkDither.h"
14 #include "SkShader.h" 12 #include "SkShader.h"
15 #include "SkUtils.h" 13 #include "SkUtils.h"
16 #include "SkUtilsArm.h" 14 #include "SkUtilsArm.h"
17 #include "SkXfermode.h" 15 #include "SkXfermode.h"
18 16
19 #if SK_MIPS_HAS_DSP 17 #if SK_MIPS_HAS_DSP
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (count & 1) { 49 if (count & 1) {
52 dst[count - 1] = value; 50 dst[count - 1] = value;
53 } 51 }
54 } 52 }
55 } 53 }
56 54
57 /////////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////////
58 56
59 class SkRGB16_Blitter : public SkRasterBlitter { 57 class SkRGB16_Blitter : public SkRasterBlitter {
60 public: 58 public:
61 SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint); 59 SkRGB16_Blitter(const SkPixmap& device, const SkPaint& paint);
62 void blitH(int x, int y, int width) override; 60 void blitH(int x, int y, int width) override;
63 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 61 virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
64 const int16_t* runs) override; 62 const int16_t* runs) override;
65 void blitV(int x, int y, int height, SkAlpha alpha) override; 63 void blitV(int x, int y, int height, SkAlpha alpha) override;
66 void blitRect(int x, int y, int width, int height) override; 64 void blitRect(int x, int y, int width, int height) override;
67 virtual void blitMask(const SkMask&, 65 void blitMask(const SkMask&, const SkIRect&) override;
68 const SkIRect&) override; 66 const SkPixmap* justAnOpaqueColor(uint32_t*) override;
69 const SkBitmap* justAnOpaqueColor(uint32_t*) override;
70 67
71 protected: 68 protected:
72 SkPMColor fSrcColor32; 69 SkPMColor fSrcColor32;
73 uint32_t fExpandedRaw16; 70 uint32_t fExpandedRaw16;
74 unsigned fScale; 71 unsigned fScale;
75 uint16_t fColor16; // already scaled by fScale 72 uint16_t fColor16; // already scaled by fScale
76 uint16_t fRawColor16; // unscaled 73 uint16_t fRawColor16; // unscaled
77 uint16_t fRawDither16; // unscaled 74 uint16_t fRawDither16; // unscaled
78 SkBool8 fDoDither; 75 SkBool8 fDoDither;
79 76
80 SkBlitRow::ColorProc16 fColorProc16; 77 SkBlitRow::ColorProc16 fColorProc16;
81 78
82 // illegal 79 // illegal
83 SkRGB16_Blitter& operator=(const SkRGB16_Blitter&); 80 SkRGB16_Blitter& operator=(const SkRGB16_Blitter&);
84 81
85 typedef SkRasterBlitter INHERITED; 82 typedef SkRasterBlitter INHERITED;
86 }; 83 };
87 84
88 class SkRGB16_Opaque_Blitter : public SkRGB16_Blitter { 85 class SkRGB16_Opaque_Blitter : public SkRGB16_Blitter {
89 public: 86 public:
90 SkRGB16_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint); 87 SkRGB16_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint);
91 void blitH(int x, int y, int width) override; 88 void blitH(int x, int y, int width) override;
92 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 89 void blitAntiH(int x, int y, const SkAlpha* antialias, const int16_t* runs) override;
93 const int16_t* runs) override;
94 void blitV(int x, int y, int height, SkAlpha alpha) override; 90 void blitV(int x, int y, int height, SkAlpha alpha) override;
95 void blitRect(int x, int y, int width, int height) override; 91 void blitRect(int x, int y, int width, int height) override;
96 virtual void blitMask(const SkMask&, 92 void blitMask(const SkMask&, const SkIRect&) override;
97 const SkIRect&) override;
98 93
99 private: 94 private:
100 typedef SkRGB16_Blitter INHERITED; 95 typedef SkRGB16_Blitter INHERITED;
101 }; 96 };
102 97
103 #ifdef USE_BLACK_BLITTER 98 #ifdef USE_BLACK_BLITTER
104 class SkRGB16_Black_Blitter : public SkRGB16_Opaque_Blitter { 99 class SkRGB16_Black_Blitter : public SkRGB16_Opaque_Blitter {
105 public: 100 public:
106 SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint); 101 SkRGB16_Black_Blitter(const SkPixmap& device, const SkPaint& paint);
107 void blitMask(const SkMask&, const SkIRect&) override; 102 void blitMask(const SkMask&, const SkIRect&) override;
108 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 103 void blitAntiH(int x, int y, const SkAlpha* antialias, const int16_t* runs) override;
109 const int16_t* runs) override;
110 104
111 private: 105 private:
112 typedef SkRGB16_Opaque_Blitter INHERITED; 106 typedef SkRGB16_Opaque_Blitter INHERITED;
113 }; 107 };
114 #endif 108 #endif
115 109
116 class SkRGB16_Shader_Blitter : public SkShaderBlitter { 110 class SkRGB16_Shader_Blitter : public SkShaderBlitter {
117 public: 111 public:
118 SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint, 112 SkRGB16_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
119 SkShader::Context* shaderContext); 113 SkShader::Context* shaderContext);
120 virtual ~SkRGB16_Shader_Blitter(); 114 virtual ~SkRGB16_Shader_Blitter();
121 void blitH(int x, int y, int width) override; 115 void blitH(int x, int y, int width) override;
122 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 116 virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
123 const int16_t* runs) override; 117 const int16_t* runs) override;
124 void blitRect(int x, int y, int width, int height) override; 118 void blitRect(int x, int y, int width, int height) override;
125 119
126 protected: 120 protected:
127 SkPMColor* fBuffer; 121 SkPMColor* fBuffer;
128 SkBlitRow::Proc16 fOpaqueProc; 122 SkBlitRow::Proc16 fOpaqueProc;
129 SkBlitRow::Proc16 fAlphaProc; 123 SkBlitRow::Proc16 fAlphaProc;
130 124
131 private: 125 private:
132 // illegal 126 // illegal
133 SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&); 127 SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&);
134 128
135 typedef SkShaderBlitter INHERITED; 129 typedef SkShaderBlitter INHERITED;
136 }; 130 };
137 131
138 // used only if the shader can perform shadSpan16 132 // used only if the shader can perform shadSpan16
139 class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter { 133 class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter {
140 public: 134 public:
141 SkRGB16_Shader16_Blitter(const SkBitmap& device, const SkPaint& paint, 135 SkRGB16_Shader16_Blitter(const SkPixmap& device, const SkPaint& paint,
142 SkShader::Context* shaderContext); 136 SkShader::Context* shaderContext);
143 void blitH(int x, int y, int width) override; 137 void blitH(int x, int y, int width) override;
144 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 138 virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
145 const int16_t* runs) override; 139 const int16_t* runs) override;
146 void blitRect(int x, int y, int width, int height) override; 140 void blitRect(int x, int y, int width, int height) override;
147 141
148 private: 142 private:
149 typedef SkRGB16_Shader_Blitter INHERITED; 143 typedef SkRGB16_Shader_Blitter INHERITED;
150 }; 144 };
151 145
152 class SkRGB16_Shader_Xfermode_Blitter : public SkShaderBlitter { 146 class SkRGB16_Shader_Xfermode_Blitter : public SkShaderBlitter {
153 public: 147 public:
154 SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint , 148 SkRGB16_Shader_Xfermode_Blitter(const SkPixmap& device, const SkPaint& paint ,
155 SkShader::Context* shaderContext); 149 SkShader::Context* shaderContext);
156 virtual ~SkRGB16_Shader_Xfermode_Blitter(); 150 virtual ~SkRGB16_Shader_Xfermode_Blitter();
157 void blitH(int x, int y, int width) override; 151 void blitH(int x, int y, int width) override;
158 virtual void blitAntiH(int x, int y, const SkAlpha* antialias, 152 virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
159 const int16_t* runs) override; 153 const int16_t* runs) override;
160 154
161 private: 155 private:
162 SkXfermode* fXfermode; 156 SkXfermode* fXfermode;
163 SkPMColor* fBuffer; 157 SkPMColor* fBuffer;
164 uint8_t* fAAExpand; 158 uint8_t* fAAExpand;
165 159
166 // illegal 160 // illegal
167 SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Bli tter&); 161 SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Bli tter&);
168 162
169 typedef SkShaderBlitter INHERITED; 163 typedef SkShaderBlitter INHERITED;
170 }; 164 };
171 165
172 /////////////////////////////////////////////////////////////////////////////// 166 ///////////////////////////////////////////////////////////////////////////////
173 #ifdef USE_BLACK_BLITTER 167 #ifdef USE_BLACK_BLITTER
174 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkBitmap& device, const SkPai nt& paint) 168 SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai nt& paint)
175 : INHERITED(device, paint) { 169 : INHERITED(device, paint) {
176 SkASSERT(paint.getShader() == NULL); 170 SkASSERT(paint.getShader() == NULL);
177 SkASSERT(paint.getColorFilter() == NULL); 171 SkASSERT(paint.getColorFilter() == NULL);
178 SkASSERT(paint.getXfermode() == NULL); 172 SkASSERT(paint.getXfermode() == NULL);
179 SkASSERT(paint.getColor() == SK_ColorBLACK); 173 SkASSERT(paint.getColor() == SK_ColorBLACK);
180 } 174 }
181 175
182 #if 1 176 #if 1
183 #define black_8_pixels(mask, dst) \ 177 #define black_8_pixels(mask, dst) \
184 do { \ 178 do { \
(...skipping 16 matching lines...) Expand all
201 if (mask & 0x08) dst[4] = 0; 195 if (mask & 0x08) dst[4] = 0;
202 if (mask & 0x04) dst[5] = 0; 196 if (mask & 0x04) dst[5] = 0;
203 if (mask & 0x02) dst[6] = 0; 197 if (mask & 0x02) dst[6] = 0;
204 if (mask & 0x01) dst[7] = 0; 198 if (mask & 0x01) dst[7] = 0;
205 } 199 }
206 #endif 200 #endif
207 201
208 #define SK_BLITBWMASK_NAME SkRGB16_Black_BlitBW 202 #define SK_BLITBWMASK_NAME SkRGB16_Black_BlitBW
209 #define SK_BLITBWMASK_ARGS 203 #define SK_BLITBWMASK_ARGS
210 #define SK_BLITBWMASK_BLIT8(mask, dst) black_8_pixels(mask, dst) 204 #define SK_BLITBWMASK_BLIT8(mask, dst) black_8_pixels(mask, dst)
211 #define SK_BLITBWMASK_GETADDR getAddr16 205 #define SK_BLITBWMASK_GETADDR writable_addr16
212 #define SK_BLITBWMASK_DEVTYPE uint16_t 206 #define SK_BLITBWMASK_DEVTYPE uint16_t
213 #include "SkBlitBWMaskTemplate.h" 207 #include "SkBlitBWMaskTemplate.h"
214 208
215 void SkRGB16_Black_Blitter::blitMask(const SkMask& mask, 209 void SkRGB16_Black_Blitter::blitMask(const SkMask& mask,
216 const SkIRect& clip) { 210 const SkIRect& clip) {
217 if (mask.fFormat == SkMask::kBW_Format) { 211 if (mask.fFormat == SkMask::kBW_Format) {
218 SkRGB16_Black_BlitBW(fDevice, mask, clip); 212 SkRGB16_Black_BlitBW(fDevice, mask, clip);
219 } else { 213 } else {
220 uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop); 214 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip. fTop);
221 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop); 215 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
222 unsigned width = clip.width(); 216 unsigned width = clip.width();
223 unsigned height = clip.height(); 217 unsigned height = clip.height();
224 size_t deviceRB = fDevice.rowBytes() - (width << 1); 218 size_t deviceRB = fDevice.rowBytes() - (width << 1);
225 unsigned maskRB = mask.fRowBytes - width; 219 unsigned maskRB = mask.fRowBytes - width;
226 220
227 SkASSERT((int)height > 0); 221 SkASSERT((int)height > 0);
228 SkASSERT((int)width > 0); 222 SkASSERT((int)width > 0);
229 SkASSERT((int)deviceRB >= 0); 223 SkASSERT((int)deviceRB >= 0);
230 SkASSERT((int)maskRB >= 0); 224 SkASSERT((int)maskRB >= 0);
231 225
232 do { 226 do {
233 unsigned w = width; 227 unsigned w = width;
234 do { 228 do {
235 unsigned aa = *alpha++; 229 unsigned aa = *alpha++;
236 *device = SkAlphaMulRGB16(*device, SkAlpha255To256(255 - aa)); 230 *device = SkAlphaMulRGB16(*device, SkAlpha255To256(255 - aa));
237 device += 1; 231 device += 1;
238 } while (--w != 0); 232 } while (--w != 0);
239 device = (uint16_t*)((char*)device + deviceRB); 233 device = (uint16_t*)((char*)device + deviceRB);
240 alpha += maskRB; 234 alpha += maskRB;
241 } while (--height != 0); 235 } while (--height != 0);
242 } 236 }
243 } 237 }
244 238
245 void SkRGB16_Black_Blitter::blitAntiH(int x, int y, 239 void SkRGB16_Black_Blitter::blitAntiH(int x, int y,
246 const SkAlpha* SK_RESTRICT antialias, 240 const SkAlpha* SK_RESTRICT antialias,
247 const int16_t* SK_RESTRICT runs) { 241 const int16_t* SK_RESTRICT runs) {
248 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 242 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
249 243
250 for (;;) { 244 for (;;) {
251 int count = runs[0]; 245 int count = runs[0];
252 SkASSERT(count >= 0); 246 SkASSERT(count >= 0);
253 if (count <= 0) { 247 if (count <= 0) {
254 return; 248 return;
255 } 249 }
256 runs += count; 250 runs += count;
257 251
258 unsigned aa = antialias[0]; 252 unsigned aa = antialias[0];
(...skipping 11 matching lines...) Expand all
270 } 264 }
271 } 265 }
272 device += count; 266 device += count;
273 } 267 }
274 } 268 }
275 #endif 269 #endif
276 270
277 /////////////////////////////////////////////////////////////////////////////// 271 ///////////////////////////////////////////////////////////////////////////////
278 /////////////////////////////////////////////////////////////////////////////// 272 ///////////////////////////////////////////////////////////////////////////////
279 273
280 SkRGB16_Opaque_Blitter::SkRGB16_Opaque_Blitter(const SkBitmap& device, 274 SkRGB16_Opaque_Blitter::SkRGB16_Opaque_Blitter(const SkPixmap& device, const SkP aint& paint)
281 const SkPaint& paint) 275 : INHERITED(device, paint) {}
282 : INHERITED(device, paint) {}
283 276
284 void SkRGB16_Opaque_Blitter::blitH(int x, int y, int width) { 277 void SkRGB16_Opaque_Blitter::blitH(int x, int y, int width) {
285 SkASSERT(width > 0); 278 SkASSERT(width > 0);
286 SkASSERT(x + width <= fDevice.width()); 279 SkASSERT(x + width <= fDevice.width());
287 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 280 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
288 uint16_t srcColor = fColor16; 281 uint16_t srcColor = fColor16;
289 282
290 SkASSERT(fRawColor16 == srcColor); 283 SkASSERT(fRawColor16 == srcColor);
291 if (fDoDither) { 284 if (fDoDither) {
292 uint16_t ditherColor = fRawDither16; 285 uint16_t ditherColor = fRawDither16;
293 if ((x ^ y) & 1) { 286 if ((x ^ y) & 1) {
294 SkTSwap(ditherColor, srcColor); 287 SkTSwap(ditherColor, srcColor);
295 } 288 }
296 sk_dither_memset16(device, srcColor, ditherColor, width); 289 sk_dither_memset16(device, srcColor, ditherColor, width);
297 } else { 290 } else {
298 sk_memset16(device, srcColor, width); 291 sk_memset16(device, srcColor, width);
299 } 292 }
300 } 293 }
301 294
302 // return 1 or 0 from a bool 295 // return 1 or 0 from a bool
303 static inline int Bool2Int(int value) { 296 static inline int Bool2Int(int value) {
304 return !!value; 297 return !!value;
305 } 298 }
306 299
307 void SkRGB16_Opaque_Blitter::blitAntiH(int x, int y, 300 void SkRGB16_Opaque_Blitter::blitAntiH(int x, int y,
308 const SkAlpha* SK_RESTRICT antialias, 301 const SkAlpha* SK_RESTRICT antialias,
309 const int16_t* SK_RESTRICT runs) { 302 const int16_t* SK_RESTRICT runs) {
310 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 303 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
311 uint16_t srcColor = fRawColor16; 304 uint16_t srcColor = fRawColor16;
312 uint32_t srcExpanded = fExpandedRaw16; 305 uint32_t srcExpanded = fExpandedRaw16;
313 int ditherInt = Bool2Int(fDoDither); 306 int ditherInt = Bool2Int(fDoDither);
314 uint16_t ditherColor = fRawDither16; 307 uint16_t ditherColor = fRawDither16;
315 // if we have no dithering, this will always fail 308 // if we have no dithering, this will always fail
316 if ((x ^ y) & ditherInt) { 309 if ((x ^ y) & ditherInt) {
317 SkTSwap(ditherColor, srcColor); 310 SkTSwap(ditherColor, srcColor);
318 } 311 }
319 for (;;) { 312 for (;;) {
320 int count = runs[0]; 313 int count = runs[0];
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (mask & 0x10) dst[3] = color; \ 358 if (mask & 0x10) dst[3] = color; \
366 if (mask & 0x08) dst[4] = color; \ 359 if (mask & 0x08) dst[4] = color; \
367 if (mask & 0x04) dst[5] = color; \ 360 if (mask & 0x04) dst[5] = color; \
368 if (mask & 0x02) dst[6] = color; \ 361 if (mask & 0x02) dst[6] = color; \
369 if (mask & 0x01) dst[7] = color; \ 362 if (mask & 0x01) dst[7] = color; \
370 } while (0) 363 } while (0)
371 364
372 #define SK_BLITBWMASK_NAME SkRGB16_BlitBW 365 #define SK_BLITBWMASK_NAME SkRGB16_BlitBW
373 #define SK_BLITBWMASK_ARGS , uint16_t color 366 #define SK_BLITBWMASK_ARGS , uint16_t color
374 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color) 367 #define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst, color)
375 #define SK_BLITBWMASK_GETADDR getAddr16 368 #define SK_BLITBWMASK_GETADDR writable_addr16
376 #define SK_BLITBWMASK_DEVTYPE uint16_t 369 #define SK_BLITBWMASK_DEVTYPE uint16_t
377 #include "SkBlitBWMaskTemplate.h" 370 #include "SkBlitBWMaskTemplate.h"
378 371
379 #if !defined(SK_MIPS_HAS_DSP) 372 #if !defined(SK_MIPS_HAS_DSP)
380 static U16CPU blend_compact(uint32_t src32, uint32_t dst32, unsigned scale5) { 373 static U16CPU blend_compact(uint32_t src32, uint32_t dst32, unsigned scale5) {
381 return SkCompact_rgb_16(dst32 + ((src32 - dst32) * scale5 >> 5)); 374 return SkCompact_rgb_16(dst32 + ((src32 - dst32) * scale5 >> 5));
382 } 375 }
383 #endif 376 #endif
384 377
385 void SkRGB16_Opaque_Blitter::blitMask(const SkMask& mask, 378 void SkRGB16_Opaque_Blitter::blitMask(const SkMask& mask,
386 const SkIRect& clip) { 379 const SkIRect& clip) {
387 if (mask.fFormat == SkMask::kBW_Format) { 380 if (mask.fFormat == SkMask::kBW_Format) {
388 SkRGB16_BlitBW(fDevice, mask, clip, fColor16); 381 SkRGB16_BlitBW(fDevice, mask, clip, fColor16);
389 return; 382 return;
390 } 383 }
391 384
392 uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop); 385 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop );
393 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop); 386 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
394 int width = clip.width(); 387 int width = clip.width();
395 int height = clip.height(); 388 int height = clip.height();
396 size_t deviceRB = fDevice.rowBytes() - (width << 1); 389 size_t deviceRB = fDevice.rowBytes() - (width << 1);
397 unsigned maskRB = mask.fRowBytes - width; 390 unsigned maskRB = mask.fRowBytes - width;
398 uint32_t expanded32 = fExpandedRaw16; 391 uint32_t expanded32 = fExpandedRaw16;
399 392
400 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN) 393 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN)
401 #define UNROLL 8 394 #define UNROLL 8
402 do { 395 do {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 SkAlpha255To256(*alpha++) >> 3); 470 SkAlpha255To256(*alpha++) >> 3);
478 device += 1; 471 device += 1;
479 } while (--w != 0); 472 } while (--w != 0);
480 device = (uint16_t*)((char*)device + deviceRB); 473 device = (uint16_t*)((char*)device + deviceRB);
481 alpha += maskRB; 474 alpha += maskRB;
482 } while (--height != 0); 475 } while (--height != 0);
483 #endif 476 #endif
484 } 477 }
485 478
486 void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 479 void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
487 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 480 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
488 size_t deviceRB = fDevice.rowBytes(); 481 size_t deviceRB = fDevice.rowBytes();
489 482
490 // TODO: respect fDoDither 483 // TODO: respect fDoDither
491 unsigned scale5 = SkAlpha255To256(alpha) >> 3; 484 unsigned scale5 = SkAlpha255To256(alpha) >> 3;
492 uint32_t src32 = fExpandedRaw16 * scale5; 485 uint32_t src32 = fExpandedRaw16 * scale5;
493 scale5 = 32 - scale5; 486 scale5 = 32 - scale5;
494 do { 487 do {
495 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; 488 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5;
496 *device = SkCompact_rgb_16((src32 + dst32) >> 5); 489 *device = SkCompact_rgb_16((src32 + dst32) >> 5);
497 device = (uint16_t*)((char*)device + deviceRB); 490 device = (uint16_t*)((char*)device + deviceRB);
498 } while (--height != 0); 491 } while (--height != 0);
499 } 492 }
500 493
501 void SkRGB16_Opaque_Blitter::blitRect(int x, int y, int width, int height) { 494 void SkRGB16_Opaque_Blitter::blitRect(int x, int y, int width, int height) {
502 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height()); 495 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
503 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 496 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
504 size_t deviceRB = fDevice.rowBytes(); 497 size_t deviceRB = fDevice.rowBytes();
505 uint16_t color16 = fColor16; 498 uint16_t color16 = fColor16;
506 499
507 if (fDoDither) { 500 if (fDoDither) {
508 uint16_t ditherColor = fRawDither16; 501 uint16_t ditherColor = fRawDither16;
509 if ((x ^ y) & 1) { 502 if ((x ^ y) & 1) {
510 SkTSwap(ditherColor, color16); 503 SkTSwap(ditherColor, color16);
511 } 504 }
512 while (--height >= 0) { 505 while (--height >= 0) {
513 sk_dither_memset16(device, color16, ditherColor, width); 506 sk_dither_memset16(device, color16, ditherColor, width);
514 SkTSwap(ditherColor, color16); 507 SkTSwap(ditherColor, color16);
515 device = (uint16_t*)((char*)device + deviceRB); 508 device = (uint16_t*)((char*)device + deviceRB);
516 } 509 }
517 } else { // no dither 510 } else { // no dither
518 while (--height >= 0) { 511 while (--height >= 0) {
519 sk_memset16(device, color16, width); 512 sk_memset16(device, color16, width);
520 device = (uint16_t*)((char*)device + deviceRB); 513 device = (uint16_t*)((char*)device + deviceRB);
521 } 514 }
522 } 515 }
523 } 516 }
524 517
525 /////////////////////////////////////////////////////////////////////////////// 518 ///////////////////////////////////////////////////////////////////////////////
526 519
527 SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint) 520 SkRGB16_Blitter::SkRGB16_Blitter(const SkPixmap& device, const SkPaint& paint)
528 : INHERITED(device) { 521 : INHERITED(device) {
529 SkColor color = paint.getColor(); 522 SkColor color = paint.getColor();
530 523
531 fSrcColor32 = SkPreMultiplyColor(color); 524 fSrcColor32 = SkPreMultiplyColor(color);
532 fScale = SkAlpha255To256(SkColorGetA(color)); 525 fScale = SkAlpha255To256(SkColorGetA(color));
533 526
534 int r = SkColorGetR(color); 527 int r = SkColorGetR(color);
535 int g = SkColorGetG(color); 528 int g = SkColorGetG(color);
536 int b = SkColorGetB(color); 529 int b = SkColorGetB(color);
537 530
(...skipping 16 matching lines...) Expand all
554 flags |= SkBlitRow::kSrcPixelAlpha_Flag; 547 flags |= SkBlitRow::kSrcPixelAlpha_Flag;
555 } 548 }
556 549
557 if (fDoDither) { 550 if (fDoDither) {
558 flags |= SkBlitRow::kDither_Flag; 551 flags |= SkBlitRow::kDither_Flag;
559 } 552 }
560 553
561 fColorProc16 = SkBlitRow::ColorFactory16(flags); 554 fColorProc16 = SkBlitRow::ColorFactory16(flags);
562 } 555 }
563 556
564 const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { 557 const SkPixmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) {
565 if (!fDoDither && 256 == fScale) { 558 if (!fDoDither && 256 == fScale) {
566 *value = fRawColor16; 559 *value = fRawColor16;
567 return &fDevice; 560 return &fDevice;
568 } 561 }
569 return NULL; 562 return NULL;
570 } 563 }
571 564
572 void SkRGB16_Blitter::blitH(int x, int y, int width) { 565 void SkRGB16_Blitter::blitH(int x, int y, int width) {
573 SkASSERT(width > 0); 566 SkASSERT(width > 0);
574 SkASSERT(x + width <= fDevice.width()); 567 SkASSERT(x + width <= fDevice.width());
575 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 568 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
576 569
577 fColorProc16(device, fSrcColor32, width, x, y); 570 fColorProc16(device, fSrcColor32, width, x, y);
578 } 571 }
579 572
580 void SkRGB16_Blitter::blitAntiH(int x, int y, 573 void SkRGB16_Blitter::blitAntiH(int x, int y,
581 const SkAlpha* SK_RESTRICT antialias, 574 const SkAlpha* SK_RESTRICT antialias,
582 const int16_t* SK_RESTRICT runs) { 575 const int16_t* SK_RESTRICT runs) {
583 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 576 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
584 uint32_t srcExpanded = fExpandedRaw16; 577 uint32_t srcExpanded = fExpandedRaw16;
585 unsigned scale = fScale; 578 unsigned scale = fScale;
586 579
587 // TODO: respect fDoDither 580 // TODO: respect fDoDither
588 for (;;) { 581 for (;;) {
589 int count = runs[0]; 582 int count = runs[0];
590 SkASSERT(count >= 0); 583 SkASSERT(count >= 0);
591 if (count <= 0) { 584 if (count <= 0) {
592 return; 585 return;
593 } 586 }
(...skipping 23 matching lines...) Expand all
617 if (bw & 0x10) dst[3] = srcColor + SkAlphaMulRGB16(dst[3], dst_scale); 610 if (bw & 0x10) dst[3] = srcColor + SkAlphaMulRGB16(dst[3], dst_scale);
618 if (bw & 0x08) dst[4] = srcColor + SkAlphaMulRGB16(dst[4], dst_scale); 611 if (bw & 0x08) dst[4] = srcColor + SkAlphaMulRGB16(dst[4], dst_scale);
619 if (bw & 0x04) dst[5] = srcColor + SkAlphaMulRGB16(dst[5], dst_scale); 612 if (bw & 0x04) dst[5] = srcColor + SkAlphaMulRGB16(dst[5], dst_scale);
620 if (bw & 0x02) dst[6] = srcColor + SkAlphaMulRGB16(dst[6], dst_scale); 613 if (bw & 0x02) dst[6] = srcColor + SkAlphaMulRGB16(dst[6], dst_scale);
621 if (bw & 0x01) dst[7] = srcColor + SkAlphaMulRGB16(dst[7], dst_scale); 614 if (bw & 0x01) dst[7] = srcColor + SkAlphaMulRGB16(dst[7], dst_scale);
622 } 615 }
623 616
624 #define SK_BLITBWMASK_NAME SkRGB16_BlendBW 617 #define SK_BLITBWMASK_NAME SkRGB16_BlendBW
625 #define SK_BLITBWMASK_ARGS , unsigned dst_scale, U16CPU src_col or 618 #define SK_BLITBWMASK_ARGS , unsigned dst_scale, U16CPU src_col or
626 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, dst_scale, src_color) 619 #define SK_BLITBWMASK_BLIT8(mask, dst) blend_8_pixels(mask, dst, dst_scale, src_color)
627 #define SK_BLITBWMASK_GETADDR getAddr16 620 #define SK_BLITBWMASK_GETADDR writable_addr16
628 #define SK_BLITBWMASK_DEVTYPE uint16_t 621 #define SK_BLITBWMASK_DEVTYPE uint16_t
629 #include "SkBlitBWMaskTemplate.h" 622 #include "SkBlitBWMaskTemplate.h"
630 623
631 void SkRGB16_Blitter::blitMask(const SkMask& mask, 624 void SkRGB16_Blitter::blitMask(const SkMask& mask,
632 const SkIRect& clip) { 625 const SkIRect& clip) {
633 if (mask.fFormat == SkMask::kBW_Format) { 626 if (mask.fFormat == SkMask::kBW_Format) {
634 SkRGB16_BlendBW(fDevice, mask, clip, 256 - fScale, fColor16); 627 SkRGB16_BlendBW(fDevice, mask, clip, 256 - fScale, fColor16);
635 return; 628 return;
636 } 629 }
637 630
638 uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop); 631 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop );
639 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop); 632 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
640 int width = clip.width(); 633 int width = clip.width();
641 int height = clip.height(); 634 int height = clip.height();
642 size_t deviceRB = fDevice.rowBytes() - (width << 1); 635 size_t deviceRB = fDevice.rowBytes() - (width << 1);
643 unsigned maskRB = mask.fRowBytes - width; 636 unsigned maskRB = mask.fRowBytes - width;
644 uint32_t color32 = fExpandedRaw16; 637 uint32_t color32 = fExpandedRaw16;
645 638
646 unsigned scale256 = fScale; 639 unsigned scale256 = fScale;
647 do { 640 do {
648 int w = width; 641 int w = width;
649 do { 642 do {
650 unsigned aa = *alpha++; 643 unsigned aa = *alpha++;
651 unsigned scale = SkAlpha255To256(aa) * scale256 >> (8 + 3); 644 unsigned scale = SkAlpha255To256(aa) * scale256 >> (8 + 3);
652 uint32_t src32 = color32 * scale; 645 uint32_t src32 = color32 * scale;
653 uint32_t dst32 = SkExpand_rgb_16(*device) * (32 - scale); 646 uint32_t dst32 = SkExpand_rgb_16(*device) * (32 - scale);
654 *device++ = SkCompact_rgb_16((src32 + dst32) >> 5); 647 *device++ = SkCompact_rgb_16((src32 + dst32) >> 5);
655 } while (--w != 0); 648 } while (--w != 0);
656 device = (uint16_t*)((char*)device + deviceRB); 649 device = (uint16_t*)((char*)device + deviceRB);
657 alpha += maskRB; 650 alpha += maskRB;
658 } while (--height != 0); 651 } while (--height != 0);
659 } 652 }
660 653
661 void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { 654 void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
662 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 655 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
663 size_t deviceRB = fDevice.rowBytes(); 656 size_t deviceRB = fDevice.rowBytes();
664 657
665 // TODO: respect fDoDither 658 // TODO: respect fDoDither
666 unsigned scale5 = SkAlpha255To256(alpha) * fScale >> (8 + 3); 659 unsigned scale5 = SkAlpha255To256(alpha) * fScale >> (8 + 3);
667 uint32_t src32 = fExpandedRaw16 * scale5; 660 uint32_t src32 = fExpandedRaw16 * scale5;
668 scale5 = 32 - scale5; 661 scale5 = 32 - scale5;
669 do { 662 do {
670 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; 663 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5;
671 *device = SkCompact_rgb_16((src32 + dst32) >> 5); 664 *device = SkCompact_rgb_16((src32 + dst32) >> 5);
672 device = (uint16_t*)((char*)device + deviceRB); 665 device = (uint16_t*)((char*)device + deviceRB);
673 } while (--height != 0); 666 } while (--height != 0);
674 } 667 }
675 668
676 void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) { 669 void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) {
677 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height()); 670 SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
678 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 671 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
679 size_t deviceRB = fDevice.rowBytes(); 672 size_t deviceRB = fDevice.rowBytes();
680 673
681 while (--height >= 0) { 674 while (--height >= 0) {
682 fColorProc16(device, fSrcColor32, width, x, y); 675 fColorProc16(device, fSrcColor32, width, x, y);
683 device = (uint16_t*)((char*)device + deviceRB); 676 device = (uint16_t*)((char*)device + deviceRB);
684 } 677 }
685 } 678 }
686 679
687 /////////////////////////////////////////////////////////////////////////////// 680 ///////////////////////////////////////////////////////////////////////////////
688 681
689 SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkBitmap& device, 682 SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkPixmap& device,
690 const SkPaint& paint, 683 const SkPaint& paint,
691 SkShader::Context* shaderCont ext) 684 SkShader::Context* shaderCont ext)
692 : SkRGB16_Shader_Blitter(device, paint, shaderContext) { 685 : SkRGB16_Shader_Blitter(device, paint, shaderContext)
686 {
693 SkASSERT(SkShader::CanCallShadeSpan16(fShaderFlags)); 687 SkASSERT(SkShader::CanCallShadeSpan16(fShaderFlags));
694 } 688 }
695 689
696 void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) { 690 void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) {
697 SkASSERT(x + width <= fDevice.width()); 691 SkASSERT(x + width <= fDevice.width());
698 692
699 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 693 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
700 SkShader::Context* shaderContext = fShaderContext; 694 SkShader::Context* shaderContext = fShaderContext;
701 695
702 int alpha = shaderContext->getSpan16Alpha(); 696 int alpha = shaderContext->getSpan16Alpha();
703 if (0xFF == alpha) { 697 if (0xFF == alpha) {
704 shaderContext->shadeSpan16(x, y, device, width); 698 shaderContext->shadeSpan16(x, y, device, width);
705 } else { 699 } else {
706 uint16_t* span16 = (uint16_t*)fBuffer; 700 uint16_t* span16 = (uint16_t*)fBuffer;
707 shaderContext->shadeSpan16(x, y, span16, width); 701 shaderContext->shadeSpan16(x, y, span16, width);
708 SkBlendRGB16(span16, device, SkAlpha255To256(alpha), width); 702 SkBlendRGB16(span16, device, SkAlpha255To256(alpha), width);
709 } 703 }
710 } 704 }
711 705
712 void SkRGB16_Shader16_Blitter::blitRect(int x, int y, int width, int height) { 706 void SkRGB16_Shader16_Blitter::blitRect(int x, int y, int width, int height) {
713 SkShader::Context* shaderContext = fShaderContext; 707 SkShader::Context* shaderContext = fShaderContext;
714 uint16_t* dst = fDevice.getAddr16(x, y); 708 uint16_t* dst = fDevice.writable_addr16(x, y);
715 size_t dstRB = fDevice.rowBytes(); 709 size_t dstRB = fDevice.rowBytes();
716 int alpha = shaderContext->getSpan16Alpha(); 710 int alpha = shaderContext->getSpan16Alpha();
717 711
718 if (0xFF == alpha) { 712 if (0xFF == alpha) {
719 if (fShaderFlags & SkShader::kConstInY16_Flag) { 713 if (fShaderFlags & SkShader::kConstInY16_Flag) {
720 // have the shader blit directly into the device the first time 714 // have the shader blit directly into the device the first time
721 shaderContext->shadeSpan16(x, y, dst, width); 715 shaderContext->shadeSpan16(x, y, dst, width);
722 // and now just memcpy that line on the subsequent lines 716 // and now just memcpy that line on the subsequent lines
723 if (--height > 0) { 717 if (--height > 0) {
724 const uint16_t* orig = dst; 718 const uint16_t* orig = dst;
(...skipping 27 matching lines...) Expand all
752 } while (--height); 746 } while (--height);
753 } 747 }
754 } 748 }
755 } 749 }
756 750
757 void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y, 751 void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y,
758 const SkAlpha* SK_RESTRICT antialias, 752 const SkAlpha* SK_RESTRICT antialias,
759 const int16_t* SK_RESTRICT runs) { 753 const int16_t* SK_RESTRICT runs) {
760 SkShader::Context* shaderContext = fShaderContext; 754 SkShader::Context* shaderContext = fShaderContext;
761 SkPMColor* SK_RESTRICT span = fBuffer; 755 SkPMColor* SK_RESTRICT span = fBuffer;
762 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 756 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
763 757
764 int alpha = shaderContext->getSpan16Alpha(); 758 int alpha = shaderContext->getSpan16Alpha();
765 uint16_t* span16 = (uint16_t*)span; 759 uint16_t* span16 = (uint16_t*)span;
766 760
767 if (0xFF == alpha) { 761 if (0xFF == alpha) {
768 for (;;) { 762 for (;;) {
769 int count = *runs; 763 int count = *runs;
770 if (count <= 0) { 764 if (count <= 0) {
771 break; 765 break;
772 } 766 }
(...skipping 30 matching lines...) Expand all
803 device += count; 797 device += count;
804 runs += count; 798 runs += count;
805 antialias += count; 799 antialias += count;
806 x += count; 800 x += count;
807 } 801 }
808 } 802 }
809 } 803 }
810 804
811 /////////////////////////////////////////////////////////////////////////////// 805 ///////////////////////////////////////////////////////////////////////////////
812 806
813 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkBitmap& device, 807 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
814 const SkPaint& paint, 808 const SkPaint& paint,
815 SkShader::Context* shaderContext) 809 SkShader::Context* shaderContext)
816 : INHERITED(device, paint, shaderContext) { 810 : INHERITED(device, paint, shaderContext)
811 {
817 SkASSERT(paint.getXfermode() == NULL); 812 SkASSERT(paint.getXfermode() == NULL);
818 813
819 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor)); 814 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
820 815
821 // compute SkBlitRow::Procs 816 // compute SkBlitRow::Procs
822 unsigned flags = 0; 817 unsigned flags = 0;
823 818
824 uint32_t shaderFlags = fShaderFlags; 819 uint32_t shaderFlags = fShaderFlags;
825 // shaders take care of global alpha, so we never set it in SkBlitRow 820 // shaders take care of global alpha, so we never set it in SkBlitRow
826 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { 821 if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) {
(...skipping 11 matching lines...) Expand all
838 833
839 SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter() { 834 SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter() {
840 sk_free(fBuffer); 835 sk_free(fBuffer);
841 } 836 }
842 837
843 void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) { 838 void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) {
844 SkASSERT(x + width <= fDevice.width()); 839 SkASSERT(x + width <= fDevice.width());
845 840
846 fShaderContext->shadeSpan(x, y, fBuffer, width); 841 fShaderContext->shadeSpan(x, y, fBuffer, width);
847 // shaders take care of global alpha, so we pass 0xFF (should be ignored) 842 // shaders take care of global alpha, so we pass 0xFF (should be ignored)
848 fOpaqueProc(fDevice.getAddr16(x, y), fBuffer, width, 0xFF, x, y); 843 fOpaqueProc(fDevice.writable_addr16(x, y), fBuffer, width, 0xFF, x, y);
849 } 844 }
850 845
851 void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) { 846 void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) {
852 SkShader::Context* shaderContext = fShaderContext; 847 SkShader::Context* shaderContext = fShaderContext;
853 SkBlitRow::Proc16 proc = fOpaqueProc; 848 SkBlitRow::Proc16 proc = fOpaqueProc;
854 SkPMColor* buffer = fBuffer; 849 SkPMColor* buffer = fBuffer;
855 uint16_t* dst = fDevice.getAddr16(x, y); 850 uint16_t* dst = fDevice.writable_addr16(x, y);
856 size_t dstRB = fDevice.rowBytes(); 851 size_t dstRB = fDevice.rowBytes();
857 852
858 if (fShaderFlags & SkShader::kConstInY32_Flag) { 853 if (fShaderFlags & SkShader::kConstInY32_Flag) {
859 shaderContext->shadeSpan(x, y, buffer, width); 854 shaderContext->shadeSpan(x, y, buffer, width);
860 do { 855 do {
861 proc(dst, buffer, width, 0xFF, x, y); 856 proc(dst, buffer, width, 0xFF, x, y);
862 y += 1; 857 y += 1;
863 dst = (uint16_t*)((char*)dst + dstRB); 858 dst = (uint16_t*)((char*)dst + dstRB);
864 } while (--height); 859 } while (--height);
865 } else { 860 } else {
(...skipping 18 matching lines...) Expand all
884 count += n; 879 count += n;
885 } 880 }
886 return count; 881 return count;
887 } 882 }
888 883
889 void SkRGB16_Shader_Blitter::blitAntiH(int x, int y, 884 void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
890 const SkAlpha* SK_RESTRICT antialias, 885 const SkAlpha* SK_RESTRICT antialias,
891 const int16_t* SK_RESTRICT runs) { 886 const int16_t* SK_RESTRICT runs) {
892 SkShader::Context* shaderContext = fShaderContext; 887 SkShader::Context* shaderContext = fShaderContext;
893 SkPMColor* SK_RESTRICT span = fBuffer; 888 SkPMColor* SK_RESTRICT span = fBuffer;
894 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 889 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
895 890
896 for (;;) { 891 for (;;) {
897 int count = *runs; 892 int count = *runs;
898 if (count <= 0) { 893 if (count <= 0) {
899 break; 894 break;
900 } 895 }
901 int aa = *antialias; 896 int aa = *antialias;
902 if (0 == aa) { 897 if (0 == aa) {
903 device += count; 898 device += count;
904 runs += count; 899 runs += count;
(...skipping 25 matching lines...) Expand all
930 count = *runs; 925 count = *runs;
931 SkASSERT(count > 0); 926 SkASSERT(count > 0);
932 aa = *antialias; 927 aa = *antialias;
933 } 928 }
934 } 929 }
935 } 930 }
936 931
937 /////////////////////////////////////////////////////////////////////// 932 ///////////////////////////////////////////////////////////////////////
938 933
939 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter( 934 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
940 const SkBitmap& device, const SkPaint& paint, 935 const SkPixmap& device, const SkPaint& paint,
941 SkShader::Context* shaderContext) 936 SkShader::Context* shaderContext)
942 : INHERITED(device, paint, shaderContext) { 937 : INHERITED(device, paint, shaderContext)
938 {
943 fXfermode = paint.getXfermode(); 939 fXfermode = paint.getXfermode();
944 SkASSERT(fXfermode); 940 SkASSERT(fXfermode);
945 fXfermode->ref(); 941 fXfermode->ref();
946 942
947 int width = device.width(); 943 int width = device.width();
948 fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * siz eof(SkPMColor)); 944 fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * siz eof(SkPMColor));
949 fAAExpand = (uint8_t*)(fBuffer + width); 945 fAAExpand = (uint8_t*)(fBuffer + width);
950 } 946 }
951 947
952 SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() { 948 SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() {
953 fXfermode->unref(); 949 fXfermode->unref();
954 sk_free(fBuffer); 950 sk_free(fBuffer);
955 } 951 }
956 952
957 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) { 953 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) {
958 SkASSERT(x + width <= fDevice.width()); 954 SkASSERT(x + width <= fDevice.width());
959 955
960 uint16_t* device = fDevice.getAddr16(x, y); 956 uint16_t* device = fDevice.writable_addr16(x, y);
961 SkPMColor* span = fBuffer; 957 SkPMColor* span = fBuffer;
962 958
963 fShaderContext->shadeSpan(x, y, span, width); 959 fShaderContext->shadeSpan(x, y, span, width);
964 fXfermode->xfer16(device, span, width, NULL); 960 fXfermode->xfer16(device, span, width, NULL);
965 } 961 }
966 962
967 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y, 963 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
968 const SkAlpha* SK_RESTRICT antialias, 964 const SkAlpha* SK_RESTRICT antialias,
969 const int16_t* SK_RESTRICT runs) { 965 const int16_t* SK_RESTRICT runs) {
970 SkShader::Context* shaderContext = fShaderContext; 966 SkShader::Context* shaderContext = fShaderContext;
971 SkXfermode* mode = fXfermode; 967 SkXfermode* mode = fXfermode;
972 SkPMColor* SK_RESTRICT span = fBuffer; 968 SkPMColor* SK_RESTRICT span = fBuffer;
973 uint8_t* SK_RESTRICT aaExpand = fAAExpand; 969 uint8_t* SK_RESTRICT aaExpand = fAAExpand;
974 uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); 970 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y);
975 971
976 for (;;) { 972 for (;;) {
977 int count = *runs; 973 int count = *runs;
978 if (count <= 0) { 974 if (count <= 0) {
979 break; 975 break;
980 } 976 }
981 int aa = *antialias; 977 int aa = *antialias;
982 if (0 == aa) { 978 if (0 == aa) {
983 device += count; 979 device += count;
984 runs += count; 980 runs += count;
(...skipping 29 matching lines...) Expand all
1014 SkASSERT(nonZeroCount > 0); 1010 SkASSERT(nonZeroCount > 0);
1015 count = *runs; 1011 count = *runs;
1016 SkASSERT(count > 0); 1012 SkASSERT(count > 0);
1017 aa = *antialias; 1013 aa = *antialias;
1018 } 1014 }
1019 } 1015 }
1020 } 1016 }
1021 1017
1022 /////////////////////////////////////////////////////////////////////////////// 1018 ///////////////////////////////////////////////////////////////////////////////
1023 1019
1024 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint, 1020 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
1025 SkShader::Context* shaderContext, 1021 SkShader::Context* shaderContext,
1026 SkTBlitterAllocator* allocator) { 1022 SkTBlitterAllocator* allocator) {
1027 SkASSERT(allocator != NULL); 1023 SkASSERT(allocator != NULL);
1028 1024
1029 SkBlitter* blitter; 1025 SkBlitter* blitter;
1030 SkShader* shader = paint.getShader(); 1026 SkShader* shader = paint.getShader();
1031 SkXfermode* mode = paint.getXfermode(); 1027 SkXfermode* mode = paint.getXfermode();
1032 1028
1033 // we require a shader if there is an xfermode, handled by our caller 1029 // we require a shader if there is an xfermode, handled by our caller
1034 SkASSERT(NULL == mode || shader); 1030 SkASSERT(NULL == mode || shader);
(...skipping 19 matching lines...) Expand all
1054 #endif 1050 #endif
1055 } else if (0xFF == SkColorGetA(color)) { 1051 } else if (0xFF == SkColorGetA(color)) {
1056 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); 1052 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint);
1057 } else { 1053 } else {
1058 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); 1054 blitter = allocator->createT<SkRGB16_Blitter>(device, paint);
1059 } 1055 }
1060 } 1056 }
1061 1057
1062 return blitter; 1058 return blitter;
1063 } 1059 }
OLDNEW
« no previous file with comments | « src/core/SkBlitter_ARGB32.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698