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

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