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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkFixed drawCap(int x, SkFixed fy, SkFixed dy, int mod64) override { | 156 SkFixed drawCap(int x, SkFixed fy, SkFixed dy, int mod64) override { |
| 157 int16_t runs[2]; |
| 158 uint8_t aa[1]; |
| 159 |
| 160 runs[0] = 1; |
| 161 runs[1] = 0; |
| 162 |
157 fy += SK_Fixed1/2; | 163 fy += SK_Fixed1/2; |
158 | 164 SkBlitter* blitter = this->getBlitter(); |
| 165 |
159 int lower_y = fy >> 16; | 166 int lower_y = fy >> 16; |
160 uint8_t a = (uint8_t)(fy >> 8); | 167 uint8_t a = (uint8_t)(fy >> 8); |
161 unsigned a0 = SmallDot6Scale(255 - a, mod64); | 168 unsigned ma = SmallDot6Scale(a, mod64); |
162 unsigned a1 = SmallDot6Scale(a, mod64); | 169 if (ma) { |
163 this->getBlitter()->blitAntiV2(x, lower_y - 1, a0, a1); | 170 aa[0] = ApplyGamma(gamma, ma); |
164 | 171 blitter->blitAntiH(x, lower_y, aa, runs); |
165 return fy + dy - SK_Fixed1/2; | 172 // the clipping blitters might edit runs, but should not affect us |
| 173 SkASSERT(runs[0] == 1); |
| 174 SkASSERT(runs[1] == 0); |
| 175 } |
| 176 ma = SmallDot6Scale(255 - a, mod64); |
| 177 if (ma) { |
| 178 aa[0] = ApplyGamma(gamma, ma); |
| 179 blitter->blitAntiH(x, lower_y - 1, aa, runs); |
| 180 // the clipping blitters might edit runs, but should not affect us |
| 181 SkASSERT(runs[0] == 1); |
| 182 SkASSERT(runs[1] == 0); |
| 183 } |
| 184 fy += dy; |
| 185 |
| 186 return fy - SK_Fixed1/2; |
166 } | 187 } |
167 | 188 |
168 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override { | 189 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override { |
169 SkASSERT(x < stopx); | 190 SkASSERT(x < stopx); |
170 | 191 |
| 192 int16_t runs[2]; |
| 193 uint8_t aa[1]; |
| 194 |
| 195 runs[0] = 1; |
| 196 runs[1] = 0; |
| 197 |
171 fy += SK_Fixed1/2; | 198 fy += SK_Fixed1/2; |
172 SkBlitter* blitter = this->getBlitter(); | 199 SkBlitter* blitter = this->getBlitter(); |
173 do { | 200 do { |
174 int lower_y = fy >> 16; | 201 int lower_y = fy >> 16; |
175 uint8_t a = (uint8_t)(fy >> 8); | 202 uint8_t a = (uint8_t)(fy >> 8); |
176 blitter->blitAntiV2(x, lower_y - 1, 255 - a, a); | 203 if (a) { |
| 204 aa[0] = a; |
| 205 blitter->blitAntiH(x, lower_y, aa, runs); |
| 206 // the clipping blitters might edit runs, but should not affect
us |
| 207 SkASSERT(runs[0] == 1); |
| 208 SkASSERT(runs[1] == 0); |
| 209 } |
| 210 a = 255 - a; |
| 211 if (a) { |
| 212 aa[0] = a; |
| 213 blitter->blitAntiH(x, lower_y - 1, aa, runs); |
| 214 // the clipping blitters might edit runs, but should not affect
us |
| 215 SkASSERT(runs[0] == 1); |
| 216 SkASSERT(runs[1] == 0); |
| 217 } |
177 fy += dy; | 218 fy += dy; |
178 } while (++x < stopx); | 219 } while (++x < stopx); |
179 | 220 |
180 return fy - SK_Fixed1/2; | 221 return fy - SK_Fixed1/2; |
181 } | 222 } |
182 }; | 223 }; |
183 | 224 |
184 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { | 225 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { |
185 public: | 226 public: |
186 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { | 227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { |
187 SkASSERT(0 == dx); | 228 SkASSERT(0 == dx); |
188 fx += SK_Fixed1/2; | 229 fx += SK_Fixed1/2; |
189 | 230 |
(...skipping 28 matching lines...) Expand all Loading... |
218 this->getBlitter()->blitV(x - 1, y, stopy - y, a); | 259 this->getBlitter()->blitV(x - 1, y, stopy - y, a); |
219 } | 260 } |
220 | 261 |
221 return fx - SK_Fixed1/2; | 262 return fx - SK_Fixed1/2; |
222 } | 263 } |
223 }; | 264 }; |
224 | 265 |
225 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { | 266 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { |
226 public: | 267 public: |
227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { | 268 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { |
| 269 int16_t runs[3]; |
| 270 uint8_t aa[2]; |
| 271 |
| 272 runs[0] = 1; |
| 273 runs[2] = 0; |
| 274 |
228 fx += SK_Fixed1/2; | 275 fx += SK_Fixed1/2; |
229 | |
230 int x = fx >> 16; | 276 int x = fx >> 16; |
231 uint8_t a = (uint8_t)(fx >> 8); | 277 uint8_t a = (uint8_t)(fx >> 8); |
232 this->getBlitter()->blitAntiH2(x - 1, y, | 278 |
233 SmallDot6Scale(255 - a, mod64), SmallDot6
Scale(a, mod64)); | 279 aa[0] = SmallDot6Scale(255 - a, mod64); |
234 | 280 aa[1] = SmallDot6Scale(a, mod64); |
235 return fx + dx - SK_Fixed1/2; | 281 // the clippng blitters might overwrite this guy, so we have to reset it
each time |
| 282 runs[1] = 1; |
| 283 this->getBlitter()->blitAntiH(x - 1, y, aa, runs); |
| 284 // the clipping blitters might edit runs, but should not affect us |
| 285 SkASSERT(runs[0] == 1); |
| 286 SkASSERT(runs[2] == 0); |
| 287 fx += dx; |
| 288 |
| 289 return fx - SK_Fixed1/2; |
236 } | 290 } |
237 | 291 |
238 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override { | 292 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override { |
239 SkASSERT(y < stopy); | 293 SkASSERT(y < stopy); |
| 294 int16_t runs[3]; |
| 295 uint8_t aa[2]; |
| 296 |
| 297 runs[0] = 1; |
| 298 runs[2] = 0; |
| 299 |
240 fx += SK_Fixed1/2; | 300 fx += SK_Fixed1/2; |
241 do { | 301 do { |
242 int x = fx >> 16; | 302 int x = fx >> 16; |
243 uint8_t a = (uint8_t)(fx >> 8); | 303 uint8_t a = (uint8_t)(fx >> 8); |
244 this->getBlitter()->blitAntiH2(x - 1, y, 255 - a, a); | 304 |
| 305 aa[0] = 255 - a; |
| 306 aa[1] = a; |
| 307 // the clippng blitters might overwrite this guy, so we have to rese
t it each time |
| 308 runs[1] = 1; |
| 309 this->getBlitter()->blitAntiH(x - 1, y, aa, runs); |
| 310 // the clipping blitters might edit runs, but should not affect us |
| 311 SkASSERT(runs[0] == 1); |
| 312 SkASSERT(runs[2] == 0); |
245 fx += dx; | 313 fx += dx; |
246 } while (++y < stopy); | 314 } while (++y < stopy); |
247 | 315 |
248 return fx - SK_Fixed1/2; | 316 return fx - SK_Fixed1/2; |
249 } | 317 } |
250 }; | 318 }; |
251 | 319 |
252 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) { | 320 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) { |
253 SkASSERT((a << 16 >> 16) == a); | 321 SkASSERT((a << 16 >> 16) == a); |
254 SkASSERT(b != 0); | 322 SkASSERT(b != 0); |
255 return (a << 16) / b; | 323 return (a << 16) / b; |
256 } | 324 } |
257 | 325 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 | 1062 |
995 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, | 1063 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, |
996 const SkRasterClip& clip, SkBlitter* blitter) { | 1064 const SkRasterClip& clip, SkBlitter* blitter) { |
997 if (clip.isBW()) { | 1065 if (clip.isBW()) { |
998 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); | 1066 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); |
999 } else { | 1067 } else { |
1000 SkAAClipBlitterWrapper wrap(clip, blitter); | 1068 SkAAClipBlitterWrapper wrap(clip, blitter); |
1001 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); | 1069 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); |
1002 } | 1070 } |
1003 } | 1071 } |
OLD | NEW |