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

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

Issue 1273203002: The compiler can generate smulbb perfectly well nowadays. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: parens Created 5 years, 4 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/SkMathPriv.h ('k') | src/opts/SkBlitRow_opts_arm_neon.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 /*
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 16 matching lines...) Expand all
27 to. If we can improve/fix the actual calculations, then we can remove this 27 to. If we can improve/fix the actual calculations, then we can remove this
28 step. 28 step.
29 */ 29 */
30 #define OUTSET_BEFORE_CLIP_TEST true 30 #define OUTSET_BEFORE_CLIP_TEST true
31 31
32 #define HLINE_STACK_BUFFER 100 32 #define HLINE_STACK_BUFFER 100
33 33
34 static inline int SmallDot6Scale(int value, int dot6) { 34 static inline int SmallDot6Scale(int value, int dot6) {
35 SkASSERT((int16_t)value == value); 35 SkASSERT((int16_t)value == value);
36 SkASSERT((unsigned)dot6 <= 64); 36 SkASSERT((unsigned)dot6 <= 64);
37 return SkMulS16(value, dot6) >> 6; 37 return (value * dot6) >> 6;
38 } 38 }
39 39
40 //#define TEST_GAMMA 40 //#define TEST_GAMMA
41 41
42 #ifdef TEST_GAMMA 42 #ifdef TEST_GAMMA
43 static uint8_t gGammaTable[256]; 43 static uint8_t gGammaTable[256];
44 #define ApplyGamma(table, alpha) (table)[alpha] 44 #define ApplyGamma(table, alpha) (table)[alpha]
45 45
46 static void build_gamma_table() { 46 static void build_gamma_table() {
47 static bool gInit = false; 47 static bool gInit = false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 fy += SK_Fixed1/2; 157 fy += SK_Fixed1/2;
158 158
159 int lower_y = fy >> 16; 159 int lower_y = fy >> 16;
160 uint8_t a = (uint8_t)(fy >> 8); 160 uint8_t a = (uint8_t)(fy >> 8);
161 unsigned a0 = SmallDot6Scale(255 - a, mod64); 161 unsigned a0 = SmallDot6Scale(255 - a, mod64);
162 unsigned a1 = SmallDot6Scale(a, mod64); 162 unsigned a1 = SmallDot6Scale(a, mod64);
163 this->getBlitter()->blitAntiV2(x, lower_y - 1, a0, a1); 163 this->getBlitter()->blitAntiV2(x, lower_y - 1, a0, a1);
164 164
165 return fy + dy - SK_Fixed1/2; 165 return fy + dy - SK_Fixed1/2;
166 } 166 }
167 167
168 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override { 168 SkFixed drawLine(int x, int stopx, SkFixed fy, SkFixed dy) override {
169 SkASSERT(x < stopx); 169 SkASSERT(x < stopx);
170 170
171 fy += SK_Fixed1/2; 171 fy += SK_Fixed1/2;
172 SkBlitter* blitter = this->getBlitter(); 172 SkBlitter* blitter = this->getBlitter();
173 do { 173 do {
174 int lower_y = fy >> 16; 174 int lower_y = fy >> 16;
175 uint8_t a = (uint8_t)(fy >> 8); 175 uint8_t a = (uint8_t)(fy >> 8);
176 blitter->blitAntiV2(x, lower_y - 1, 255 - a, a); 176 blitter->blitAntiV2(x, lower_y - 1, 255 - a, a);
177 fy += dy; 177 fy += dy;
178 } while (++x < stopx); 178 } while (++x < stopx);
179 179
180 return fy - SK_Fixed1/2; 180 return fy - SK_Fixed1/2;
181 } 181 }
182 }; 182 };
183 183
184 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter { 184 class VLine_SkAntiHairBlitter : public SkAntiHairBlitter {
185 public: 185 public:
186 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { 186 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override {
187 SkASSERT(0 == dx); 187 SkASSERT(0 == dx);
188 fx += SK_Fixed1/2; 188 fx += SK_Fixed1/2;
189 189
(...skipping 29 matching lines...) Expand all
219 } 219 }
220 220
221 return fx - SK_Fixed1/2; 221 return fx - SK_Fixed1/2;
222 } 222 }
223 }; 223 };
224 224
225 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter { 225 class Vertish_SkAntiHairBlitter : public SkAntiHairBlitter {
226 public: 226 public:
227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override { 227 SkFixed drawCap(int y, SkFixed fx, SkFixed dx, int mod64) override {
228 fx += SK_Fixed1/2; 228 fx += SK_Fixed1/2;
229 229
230 int x = fx >> 16; 230 int x = fx >> 16;
231 uint8_t a = (uint8_t)(fx >> 8); 231 uint8_t a = (uint8_t)(fx >> 8);
232 this->getBlitter()->blitAntiH2(x - 1, y, 232 this->getBlitter()->blitAntiH2(x - 1, y,
233 SmallDot6Scale(255 - a, mod64), SmallDot6 Scale(a, mod64)); 233 SmallDot6Scale(255 - a, mod64), SmallDot6 Scale(a, mod64));
234 234
235 return fx + dx - SK_Fixed1/2; 235 return fx + dx - SK_Fixed1/2;
236 } 236 }
237 237
238 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override { 238 SkFixed drawLine(int y, int stopy, SkFixed fx, SkFixed dx) override {
239 SkASSERT(y < stopy); 239 SkASSERT(y < stopy);
240 fx += SK_Fixed1/2; 240 fx += SK_Fixed1/2;
241 do { 241 do {
242 int x = fx >> 16; 242 int x = fx >> 16;
243 uint8_t a = (uint8_t)(fx >> 8); 243 uint8_t a = (uint8_t)(fx >> 8);
244 this->getBlitter()->blitAntiH2(x - 1, y, 255 - a, a); 244 this->getBlitter()->blitAntiH2(x - 1, y, 255 - a, a);
245 fx += dx; 245 fx += dx;
246 } while (++y < stopy); 246 } while (++y < stopy);
247 247
248 return fx - SK_Fixed1/2; 248 return fx - SK_Fixed1/2;
249 } 249 }
250 }; 250 };
251 251
252 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) { 252 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b) {
253 SkASSERT((a << 16 >> 16) == a); 253 SkASSERT((a << 16 >> 16) == a);
254 SkASSERT(b != 0); 254 SkASSERT(b != 0);
255 return (a << 16) / b; 255 return (a << 16) / b;
256 } 256 }
257 257
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 #endif 533 #endif
534 534
535 const SkScalar max = SkIntToScalar(32767); 535 const SkScalar max = SkIntToScalar(32767);
536 const SkRect fixedBounds = SkRect::MakeLTRB(-max, -max, max, max); 536 const SkRect fixedBounds = SkRect::MakeLTRB(-max, -max, max, max);
537 537
538 SkRect clipBounds; 538 SkRect clipBounds;
539 if (clip) { 539 if (clip) {
540 clipBounds.set(clip->getBounds()); 540 clipBounds.set(clip->getBounds());
541 /* We perform integral clipping later on, but we do a scalar clip first 541 /* We perform integral clipping later on, but we do a scalar clip first
542 to ensure that our coordinates are expressible in fixed/integers. 542 to ensure that our coordinates are expressible in fixed/integers.
543 543
544 antialiased hairlines can draw up to 1/2 of a pixel outside of 544 antialiased hairlines can draw up to 1/2 of a pixel outside of
545 their bounds, so we need to outset the clip before calling the 545 their bounds, so we need to outset the clip before calling the
546 clipper. To make the numerics safer, we outset by a whole pixel, 546 clipper. To make the numerics safer, we outset by a whole pixel,
547 since the 1/2 pixel boundary is important to the antihair blitter, 547 since the 1/2 pixel boundary is important to the antihair blitter,
548 we don't want to risk numerical fate by chopping on that edge. 548 we don't want to risk numerical fate by chopping on that edge.
549 */ 549 */
550 clipBounds.outset(SK_Scalar1, SK_Scalar1); 550 clipBounds.outset(SK_Scalar1, SK_Scalar1);
551 } 551 }
552 552
553 for (int i = 0; i < arrayCount - 1; ++i) { 553 for (int i = 0; i < arrayCount - 1; ++i) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 994
995 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, 995 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize,
996 const SkRasterClip& clip, SkBlitter* blitter) { 996 const SkRasterClip& clip, SkBlitter* blitter) {
997 if (clip.isBW()) { 997 if (clip.isBW()) {
998 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); 998 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter);
999 } else { 999 } else {
1000 SkAAClipBlitterWrapper wrap(clip, blitter); 1000 SkAAClipBlitterWrapper wrap(clip, blitter);
1001 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); 1001 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter());
1002 } 1002 }
1003 } 1003 }
OLDNEW
« no previous file with comments | « src/core/SkMathPriv.h ('k') | src/opts/SkBlitRow_opts_arm_neon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698