[Webkit-unassigned] [Bug 14440] New: [CAIRO][QT][CG] Share adjustLineToPixelBoundaries() between all GraphicsContext impls.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Jun 27 18:18:44 PDT 2007
http://bugs.webkit.org/show_bug.cgi?id=14440
Summary: [CAIRO][QT][CG] Share adjustLineToPixelBoundaries()
between all GraphicsContext impls.
Product: WebKit
Version: 522+ (nightly)
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: P2
Component: New Bugs
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: alp at atoker.com
Each of the GraphicsContext implementations have duplicated code in
adjustLineToPixelBoundaries().
The block used by Qt and Cairo is:
// FIXME: Now that this is refactored, it should be shared by all contexts.
static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float
strokeWidth,
const StrokeStyle& penStyle)
{
// For odd widths, we add in 0.5 to the appropriate x/y so that the float
arithmetic
// works out. For example, with a border width of 3, KHTML will pass us
(y1+y2)/2, e.g.,
// (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an
even width gave
// us a perfect position, but an odd width gave us a position that is off
by exactly 0.5.
if (penStyle == DottedStroke || penStyle == DashedStroke) {
if (p1.x() == p2.x()) {
p1.setY(p1.y() + strokeWidth);
p2.setY(p2.y() - strokeWidth);
} else {
p1.setX(p1.x() + strokeWidth);
p2.setX(p2.x() - strokeWidth);
}
}
if (((int) strokeWidth) % 2) {
if (p1.x() == p2.x()) {
// We're a vertical line. Adjust our x.
p1.setX(p1.x() + 0.5);
p2.setX(p2.x() + 0.5);
} else {
// We're a horizontal line. Adjust our y.
p1.setY(p1.y() + 0.5);
p2.setY(p2.y() + 0.5);
}
}
}
On CG:
// For odd widths, we add in 0.5 to the appropriate x/y so that the float
arithmetic
// works out. For example, with a border width of 3, KHTML will pass us
(y1+y2)/2, e.g.,
// (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an
even width gave
// us a perfect position, but an odd width gave us a position that is off
by exactly 0.5.
if (strokeStyle() == DottedStroke || strokeStyle() == DashedStroke) {
if (isVerticalLine) {
p1.move(0, width);
p2.move(0, -width);
} else {
p1.move(width, 0);
p2.move(-width, 0);
}
}
if (((int)width) % 2) {
if (isVerticalLine) {
// We're a vertical line. Adjust our x.
p1.move(0.5f, 0.0f);
p2.move(0.5f, 0.0f);
} else {
// We're a horizontal line. Adjust our y.
p1.move(0.0f, 0.5f);
p2.move(0.0f, 0.5f);
}
}
There may be more code that can be shared here.
--
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list