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

Side by Side Diff: src/core/SkEdge.h

Issue 270263005: Use even rounding for better results when converting from scalar to fdot6 (Closed) Base URL: https://skia.googlesource.com/skia.git@neon
Patch Set: Protect behind an ifdef Created 6 years, 3 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 | « no previous file | src/core/SkEdge.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 2006 The Android Open Source Project 3 * Copyright 2006 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 #ifndef SkEdge_DEFINED 10 #ifndef SkEdge_DEFINED
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 SkFixed fCLastX, fCLastY; 82 SkFixed fCLastX, fCLastY;
83 83
84 int setCubic(const SkPoint pts[4], const SkIRect* clip, int shiftUp); 84 int setCubic(const SkPoint pts[4], const SkIRect* clip, int shiftUp);
85 int updateCubic(); 85 int updateCubic();
86 }; 86 };
87 87
88 int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, int shift) { 88 int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, int shift) {
89 SkFDot6 x0, y0, x1, y1; 89 SkFDot6 x0, y0, x1, y1;
90 90
91 { 91 {
92 #ifdef SK_RASTERIZE_EVEN_ROUNDING
93 x0 = SkScalarRoundToFDot6(p0.fX, shift);
94 y0 = SkScalarRoundToFDot6(p0.fY, shift);
95 x1 = SkScalarRoundToFDot6(p1.fX, shift);
96 y1 = SkScalarRoundToFDot6(p1.fY, shift);
97 #else
92 float scale = float(1 << (shift + 6)); 98 float scale = float(1 << (shift + 6));
93 x0 = int(p0.fX * scale); 99 x0 = int(p0.fX * scale);
94 y0 = int(p0.fY * scale); 100 y0 = int(p0.fY * scale);
95 x1 = int(p1.fX * scale); 101 x1 = int(p1.fX * scale);
96 y1 = int(p1.fY * scale); 102 y1 = int(p1.fY * scale);
103 #endif
97 } 104 }
98 105
99 int winding = 1; 106 int winding = 1;
100 107
101 if (y0 > y1) { 108 if (y0 > y1) {
102 SkTSwap(x0, x1); 109 SkTSwap(x0, x1);
103 SkTSwap(y0, y1); 110 SkTSwap(y0, y1);
104 winding = -1; 111 winding = -1;
105 } 112 }
106 113
(...skipping 13 matching lines...) Expand all
120 fFirstY = top; 127 fFirstY = top;
121 fLastY = bot - 1; 128 fLastY = bot - 1;
122 fCurveCount = 0; 129 fCurveCount = 0;
123 fWinding = SkToS8(winding); 130 fWinding = SkToS8(winding);
124 fCurveShift = 0; 131 fCurveShift = 0;
125 return 1; 132 return 1;
126 } 133 }
127 134
128 135
129 #endif 136 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkEdge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698