OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. |
3 * (C) 2005 Rob Buis <buis@kde.org> | 3 * (C) 2005 Rob Buis <buis@kde.org> |
4 * (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * (C) 2006 Alexander Kellett <lypanov@kde.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 ts << "}]"; | 320 ts << "}]"; |
321 } | 321 } |
322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); | 322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); |
323 } | 323 } |
324 | 324 |
325 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); | 325 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); |
326 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource()); | 326 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource()); |
327 writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource()); | 327 writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource()); |
328 } | 328 } |
329 | 329 |
330 static float snapToCloseInteger(float value) | |
331 { | |
332 // Due to floating point arithmetic uncertainties we may sometimes end up at | |
333 // something like 4.99999952 when pure arithmetic would have given 5. | |
334 // To give predictable results in debug ouput, snap numbers very close to | |
335 // integers to integers. This matters because sometimes numbers are truncate d | |
336 // rather than rounded before being viewed as integers. | |
337 const double epsilon = 0.00001; | |
338 if (fabs(value - round(value)) < epsilon) | |
339 return static_cast<float>(round(value)); | |
340 return value; | |
341 } | |
342 | |
343 static FloatPoint snapToCloseInteger(FloatPoint point) | |
344 { | |
345 return FloatPoint(snapToCloseInteger(point.x()), snapToCloseInteger(point.y( ))); | |
346 } | |
347 | |
348 static FloatRect snapToCloseInteger(FloatRect rect) | |
349 { | |
350 FloatPoint bottomRight = snapToCloseInteger(rect.maxXMaxYCorner()); | |
351 FloatPoint topLeft = snapToCloseInteger(rect.minXMinYCorner()); | |
352 return FloatRect(topLeft, bottomRight - topLeft); | |
353 } | |
354 | |
330 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& obj ect) | 355 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& obj ect) |
331 { | 356 { |
332 ts << " " << enclosingIntRect(const_cast<RenderObject&>(object).absoluteClip pedOverflowRect()); | 357 FloatRect rect = snapToCloseInteger(object.absoluteClippedOverflowRect()); |
Daniel Bratell
2015/01/22 09:21:40
This is too late. It's in the conversion from floa
| |
358 ts << " " << enclosingIntRect(rect); | |
333 writeStyle(ts, object); | 359 writeStyle(ts, object); |
334 return ts; | 360 return ts; |
335 } | 361 } |
336 | 362 |
337 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape) | 363 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape) |
338 { | 364 { |
339 writePositionAndStyle(ts, shape); | 365 writePositionAndStyle(ts, shape); |
340 | 366 |
341 SVGElement* svgElement = shape.element(); | 367 SVGElement* svgElement = shape.element(); |
342 ASSERT(svgElement); | 368 ASSERT(svgElement); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 ts << " "; | 700 ts << " "; |
675 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); | 701 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); |
676 ts << " "; | 702 ts << " "; |
677 writeStandardPrefix(ts, *filter, 0); | 703 writeStandardPrefix(ts, *filter, 0); |
678 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; | 704 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; |
679 } | 705 } |
680 } | 706 } |
681 } | 707 } |
682 | 708 |
683 } // namespace blink | 709 } // namespace blink |
OLD | NEW |