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

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

Issue 1060153003: add new blit2 methods in support of antialiased hairlines guard flag SK_SUPPORT_LEGACY_BLITANTIH2V2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: specialize non-opaque color as well Created 5 years, 8 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/SkCoreBlitters.h ('k') | no next file » | 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 /*
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
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
163 fy += SK_Fixed1/2; 157 fy += SK_Fixed1/2;
164 SkBlitter* blitter = this->getBlitter(); 158
165
166 int lower_y = fy >> 16; 159 int lower_y = fy >> 16;
167 uint8_t a = (uint8_t)(fy >> 8); 160 uint8_t a = (uint8_t)(fy >> 8);
168 unsigned ma = SmallDot6Scale(a, mod64); 161 unsigned a0 = SmallDot6Scale(255 - a, mod64);
169 if (ma) { 162 unsigned a1 = SmallDot6Scale(a, mod64);
170 aa[0] = ApplyGamma(gamma, ma); 163 this->getBlitter()->blitAntiV2(x, lower_y - 1, a0, a1);
171 blitter->blitAntiH(x, lower_y, aa, runs); 164
172 // the clipping blitters might edit runs, but should not affect us 165 return fy + dy - SK_Fixed1/2;
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;
187 } 166 }
188 167
189 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override { 168 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override {
190 SkASSERT(x < stopx); 169 SkASSERT(x < stopx);
191 170
192 int16_t runs[2];
193 uint8_t aa[1];
194
195 runs[0] = 1;
196 runs[1] = 0;
197
198 fy += SK_Fixed1/2; 171 fy += SK_Fixed1/2;
199 SkBlitter* blitter = this->getBlitter(); 172 SkBlitter* blitter = this->getBlitter();
200 do { 173 do {
201 int lower_y = fy >> 16; 174 int lower_y = fy >> 16;
202 uint8_t a = (uint8_t)(fy >> 8); 175 uint8_t a = (uint8_t)(fy >> 8);
203 if (a) { 176 blitter->blitAntiV2(x, lower_y - 1, 255 - a, 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 }
218 fy += dy; 177 fy += dy;
219 } while (++x < stopx); 178 } while (++x < stopx);
220 179
221 return fy - SK_Fixed1/2; 180 return fy - SK_Fixed1/2;
222 } 181 }
223 }; 182 };
224 183
225 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { 184 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter {
226 public: 185 public:
227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { 186 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override {
228 SkASSERT(0 == dx); 187 SkASSERT(0 == dx);
229 fx += SK_Fixed1/2; 188 fx += SK_Fixed1/2;
230 189
(...skipping 28 matching lines...) Expand all
259 this->getBlitter()->blitV(x - 1, y, stopy - y, a); 218 this->getBlitter()->blitV(x - 1, y, stopy - y, a);
260 } 219 }
261 220
262 return fx - SK_Fixed1/2; 221 return fx - SK_Fixed1/2;
263 } 222 }
264 }; 223 };
265 224
266 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { 225 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter {
267 public: 226 public:
268 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { 227 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
275 fx += SK_Fixed1/2; 228 fx += SK_Fixed1/2;
229
276 int x = fx >> 16; 230 int x = fx >> 16;
277 uint8_t a = (uint8_t)(fx >> 8); 231 uint8_t a = (uint8_t)(fx >> 8);
278 232 this->getBlitter()->blitAntiH2(x - 1, y,
279 aa[0] = SmallDot6Scale(255 - a, mod64); 233 SmallDot6Scale(255 - a, mod64), SmallDot6 Scale(a, mod64));
280 aa[1] = SmallDot6Scale(a, mod64); 234
281 // the clippng blitters might overwrite this guy, so we have to reset it each time 235 return fx + dx - SK_Fixed1/2;
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;
290 } 236 }
291 237
292 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override { 238 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override {
293 SkASSERT(y < stopy); 239 SkASSERT(y < stopy);
294 int16_t runs[3];
295 uint8_t aa[2];
296
297 runs[0] = 1;
298 runs[2] = 0;
299
300 fx += SK_Fixed1/2; 240 fx += SK_Fixed1/2;
301 do { 241 do {
302 int x = fx >> 16; 242 int x = fx >> 16;
303 uint8_t a = (uint8_t)(fx >> 8); 243 uint8_t a = (uint8_t)(fx >> 8);
304 244 this->getBlitter()->blitAntiH2(x - 1, y, 255 - a, a);
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);
313 fx += dx; 245 fx += dx;
314 } while (++y < stopy); 246 } while (++y < stopy);
315 247
316 return fx - SK_Fixed1/2; 248 return fx - SK_Fixed1/2;
317 } 249 }
318 }; 250 };
319 251
320 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) { 252 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) {
321 SkASSERT((a << 16 >> 16) == a); 253 SkASSERT((a << 16 >> 16) == a);
322 SkASSERT(b != 0); 254 SkASSERT(b != 0);
323 return (a << 16) / b; 255 return (a << 16) / b;
324 } 256 }
325 257
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 994
1063 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, 995 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize,
1064 const SkRasterClip& clip, SkBlitter* blitter) { 996 const SkRasterClip& clip, SkBlitter* blitter) {
1065 if (clip.isBW()) { 997 if (clip.isBW()) {
1066 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); 998 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter);
1067 } else { 999 } else {
1068 SkAAClipBlitterWrapper wrap(clip, blitter); 1000 SkAAClipBlitterWrapper wrap(clip, blitter);
1069 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); 1001 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter());
1070 } 1002 }
1071 } 1003 }
OLDNEW
« no previous file with comments | « src/core/SkCoreBlitters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698