OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 The Android Open Source Project | 3 * Copyright 2011 The Android Open Source Project |
4 * | 4 * |
5 * 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 |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkScan.h" | 10 #include "SkScan.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 virtual SkFixed drawCap(int x, SkFixed fy, SkFixed slope, int mod64) = 0; | 100 virtual SkFixed drawCap(int x, SkFixed fy, SkFixed slope, int mod64) = 0; |
101 virtual SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed slope) = 0; | 101 virtual SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed slope) = 0; |
102 | 102 |
103 private: | 103 private: |
104 SkBlitter* fBlitter; | 104 SkBlitter* fBlitter; |
105 }; | 105 }; |
106 | 106 |
107 class HLine_SkAntiHairBlitter : public SkAntiHairBlitter { | 107 class HLine_SkAntiHairBlitter : public SkAntiHairBlitter { |
108 public: | 108 public: |
109 virtual SkFixed drawCap(int x, SkFixed fy, SkFixed slope, int mod64) SK_OVER
RIDE { | 109 SkFixed drawCap(int x, SkFixed fy, SkFixed slope, int mod64) SK_OVERRIDE { |
110 fy += SK_Fixed1/2; | 110 fy += SK_Fixed1/2; |
111 | 111 |
112 int y = fy >> 16; | 112 int y = fy >> 16; |
113 uint8_t a = (uint8_t)(fy >> 8); | 113 uint8_t a = (uint8_t)(fy >> 8); |
114 | 114 |
115 // lower line | 115 // lower line |
116 unsigned ma = SmallDot6Scale(a, mod64); | 116 unsigned ma = SmallDot6Scale(a, mod64); |
117 if (ma) { | 117 if (ma) { |
118 call_hline_blitter(this->getBlitter(), x, y, 1, ma); | 118 call_hline_blitter(this->getBlitter(), x, y, 1, ma); |
119 } | 119 } |
(...skipping 26 matching lines...) Expand all Loading... |
146 if (a) { | 146 if (a) { |
147 call_hline_blitter(this->getBlitter(), x, y - 1, count, a); | 147 call_hline_blitter(this->getBlitter(), x, y - 1, count, a); |
148 } | 148 } |
149 | 149 |
150 return fy - SK_Fixed1/2; | 150 return fy - SK_Fixed1/2; |
151 } | 151 } |
152 }; | 152 }; |
153 | 153 |
154 class Horish_SkAntiHairBlitter : public SkAntiHairBlitter { | 154 class Horish_SkAntiHairBlitter : public SkAntiHairBlitter { |
155 public: | 155 public: |
156 virtual SkFixed drawCap(int x, SkFixed fy, SkFixed dy, int mod64) SK_OVERRID
E { | 156 SkFixed drawCap(int x, SkFixed fy, SkFixed dy, int mod64) SK_OVERRIDE { |
157 int16_t runs[2]; | 157 int16_t runs[2]; |
158 uint8_t aa[1]; | 158 uint8_t aa[1]; |
159 | 159 |
160 runs[0] = 1; | 160 runs[0] = 1; |
161 runs[1] = 0; | 161 runs[1] = 0; |
162 | 162 |
163 fy += SK_Fixed1/2; | 163 fy += SK_Fixed1/2; |
164 SkBlitter* blitter = this->getBlitter(); | 164 SkBlitter* blitter = this->getBlitter(); |
165 | 165 |
166 int lower_y = fy >> 16; | 166 int lower_y = fy >> 16; |
(...skipping 12 matching lines...) Expand all Loading... |
179 blitter->blitAntiH(x, lower_y - 1, aa, runs); | 179 blitter->blitAntiH(x, lower_y - 1, aa, runs); |
180 // the clipping blitters might edit runs, but should not affect us | 180 // the clipping blitters might edit runs, but should not affect us |
181 SkASSERT(runs[0] == 1); | 181 SkASSERT(runs[0] == 1); |
182 SkASSERT(runs[1] == 0); | 182 SkASSERT(runs[1] == 0); |
183 } | 183 } |
184 fy += dy; | 184 fy += dy; |
185 | 185 |
186 return fy - SK_Fixed1/2; | 186 return fy - SK_Fixed1/2; |
187 } | 187 } |
188 | 188 |
189 virtual SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) SK_OVERRI
DE { | 189 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) SK_OVERRIDE { |
190 SkASSERT(x < stopx); | 190 SkASSERT(x < stopx); |
191 | 191 |
192 int16_t runs[2]; | 192 int16_t runs[2]; |
193 uint8_t aa[1]; | 193 uint8_t aa[1]; |
194 | 194 |
195 runs[0] = 1; | 195 runs[0] = 1; |
196 runs[1] = 0; | 196 runs[1] = 0; |
197 | 197 |
198 fy += SK_Fixed1/2; | 198 fy += SK_Fixed1/2; |
199 SkBlitter* blitter = this->getBlitter(); | 199 SkBlitter* blitter = this->getBlitter(); |
(...skipping 17 matching lines...) Expand all Loading... |
217 } | 217 } |
218 fy += dy; | 218 fy += dy; |
219 } while (++x < stopx); | 219 } while (++x < stopx); |
220 | 220 |
221 return fy - SK_Fixed1/2; | 221 return fy - SK_Fixed1/2; |
222 } | 222 } |
223 }; | 223 }; |
224 | 224 |
225 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { | 225 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { |
226 public: | 226 public: |
227 virtual SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) SK_OVERRID
E { | 227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) SK_OVERRIDE { |
228 SkASSERT(0 == dx); | 228 SkASSERT(0 == dx); |
229 fx += SK_Fixed1/2; | 229 fx += SK_Fixed1/2; |
230 | 230 |
231 int x = fx >> 16; | 231 int x = fx >> 16; |
232 int a = (uint8_t)(fx >> 8); | 232 int a = (uint8_t)(fx >> 8); |
233 | 233 |
234 unsigned ma = SmallDot6Scale(a, mod64); | 234 unsigned ma = SmallDot6Scale(a, mod64); |
235 if (ma) { | 235 if (ma) { |
236 this->getBlitter()->blitV(x, y, 1, ma); | 236 this->getBlitter()->blitV(x, y, 1, ma); |
237 } | 237 } |
238 ma = SmallDot6Scale(255 - a, mod64); | 238 ma = SmallDot6Scale(255 - a, mod64); |
239 if (ma) { | 239 if (ma) { |
240 this->getBlitter()->blitV(x - 1, y, 1, ma); | 240 this->getBlitter()->blitV(x - 1, y, 1, ma); |
241 } | 241 } |
242 | 242 |
243 return fx - SK_Fixed1/2; | 243 return fx - SK_Fixed1/2; |
244 } | 244 } |
245 | 245 |
246 virtual SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) SK_OVERRI
DE { | 246 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) SK_OVERRIDE { |
247 SkASSERT(y < stopy); | 247 SkASSERT(y < stopy); |
248 SkASSERT(0 == dx); | 248 SkASSERT(0 == dx); |
249 fx += SK_Fixed1/2; | 249 fx += SK_Fixed1/2; |
250 | 250 |
251 int x = fx >> 16; | 251 int x = fx >> 16; |
252 int a = (uint8_t)(fx >> 8); | 252 int a = (uint8_t)(fx >> 8); |
253 | 253 |
254 if (a) { | 254 if (a) { |
255 this->getBlitter()->blitV(x, y, stopy - y, a); | 255 this->getBlitter()->blitV(x, y, stopy - y, a); |
256 } | 256 } |
257 a = 255 - a; | 257 a = 255 - a; |
258 if (a) { | 258 if (a) { |
259 this->getBlitter()->blitV(x - 1, y, stopy - y, a); | 259 this->getBlitter()->blitV(x - 1, y, stopy - y, a); |
260 } | 260 } |
261 | 261 |
262 return fx - SK_Fixed1/2; | 262 return fx - SK_Fixed1/2; |
263 } | 263 } |
264 }; | 264 }; |
265 | 265 |
266 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { | 266 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { |
267 public: | 267 public: |
268 virtual SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) SK_OVERRID
E { | 268 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) SK_OVERRIDE { |
269 int16_t runs[3]; | 269 int16_t runs[3]; |
270 uint8_t aa[2]; | 270 uint8_t aa[2]; |
271 | 271 |
272 runs[0] = 1; | 272 runs[0] = 1; |
273 runs[2] = 0; | 273 runs[2] = 0; |
274 | 274 |
275 fx += SK_Fixed1/2; | 275 fx += SK_Fixed1/2; |
276 int x = fx >> 16; | 276 int x = fx >> 16; |
277 uint8_t a = (uint8_t)(fx >> 8); | 277 uint8_t a = (uint8_t)(fx >> 8); |
278 | 278 |
279 aa[0] = SmallDot6Scale(255 - a, mod64); | 279 aa[0] = SmallDot6Scale(255 - a, mod64); |
280 aa[1] = SmallDot6Scale(a, mod64); | 280 aa[1] = SmallDot6Scale(a, mod64); |
281 // the clippng blitters might overwrite this guy, so we have to reset it
each time | 281 // the clippng blitters might overwrite this guy, so we have to reset it
each time |
282 runs[1] = 1; | 282 runs[1] = 1; |
283 this->getBlitter()->blitAntiH(x - 1, y, aa, runs); | 283 this->getBlitter()->blitAntiH(x - 1, y, aa, runs); |
284 // the clipping blitters might edit runs, but should not affect us | 284 // the clipping blitters might edit runs, but should not affect us |
285 SkASSERT(runs[0] == 1); | 285 SkASSERT(runs[0] == 1); |
286 SkASSERT(runs[2] == 0); | 286 SkASSERT(runs[2] == 0); |
287 fx += dx; | 287 fx += dx; |
288 | 288 |
289 return fx - SK_Fixed1/2; | 289 return fx - SK_Fixed1/2; |
290 } | 290 } |
291 | 291 |
292 virtual SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) SK_OVERRI
DE { | 292 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) SK_OVERRIDE { |
293 SkASSERT(y < stopy); | 293 SkASSERT(y < stopy); |
294 int16_t runs[3]; | 294 int16_t runs[3]; |
295 uint8_t aa[2]; | 295 uint8_t aa[2]; |
296 | 296 |
297 runs[0] = 1; | 297 runs[0] = 1; |
298 runs[2] = 0; | 298 runs[2] = 0; |
299 | 299 |
300 fx += SK_Fixed1/2; | 300 fx += SK_Fixed1/2; |
301 do { | 301 do { |
302 int x = fx >> 16; | 302 int x = fx >> 16; |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 | 1065 |
1066 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, | 1066 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, |
1067 const SkRasterClip& clip, SkBlitter* blitter) { | 1067 const SkRasterClip& clip, SkBlitter* blitter) { |
1068 if (clip.isBW()) { | 1068 if (clip.isBW()) { |
1069 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); | 1069 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); |
1070 } else { | 1070 } else { |
1071 SkAAClipBlitterWrapper wrap(clip, blitter); | 1071 SkAAClipBlitterWrapper wrap(clip, blitter); |
1072 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); | 1072 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); |
1073 } | 1073 } |
1074 } | 1074 } |
OLD | NEW |