| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * 2006 Rob Buis <buis@kde.org> | 3 * 2006 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return *this; | 67 return *this; |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool Path::operator==(const Path& other) const | 70 bool Path::operator==(const Path& other) const |
| 71 { | 71 { |
| 72 return m_path == other.m_path; | 72 return m_path == other.m_path; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool Path::contains(const FloatPoint& point) const | 75 bool Path::contains(const FloatPoint& point) const |
| 76 { | 76 { |
| 77 return SkPathContainsPoint(m_path, point, m_path.getFillType()); | 77 return m_path.contains(WebCoreFloatToSkScalar(point.x()), WebCoreFloatToSkSc
alar(point.y())); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool Path::contains(const FloatPoint& point, WindRule rule) const | 80 bool Path::contains(const FloatPoint& point, WindRule rule) const |
| 81 { | 81 { |
| 82 return SkPathContainsPoint(m_path, point, WebCoreWindRuleToSkFillType(rule))
; | 82 SkScalar x = WebCoreFloatToSkScalar(point.x()); |
| 83 SkScalar y = WebCoreFloatToSkScalar(point.y()); |
| 84 SkPath::FillType fillType = WebCoreWindRuleToSkFillType(rule); |
| 85 if (m_path.getFillType() != fillType) { |
| 86 SkPath tmp(m_path); |
| 87 tmp.setFillType(fillType); |
| 88 return tmp.contains(x, y); |
| 89 } |
| 90 return m_path.contains(x, y); |
| 83 } | 91 } |
| 84 | 92 |
| 85 // FIXME: this method ignores the CTM and may yield inaccurate results for large
scales. | 93 // FIXME: this method ignores the CTM and may yield inaccurate results for large
scales. |
| 86 SkPath Path::strokePath(const StrokeData& strokeData) const | 94 SkPath Path::strokePath(const StrokeData& strokeData) const |
| 87 { | 95 { |
| 88 SkPaint paint; | 96 SkPaint paint; |
| 89 strokeData.setupPaint(&paint); | 97 strokeData.setupPaint(&paint); |
| 90 | 98 |
| 91 // Skia stroke resolution scale. This is multiplied by 4 internally | 99 // Skia stroke resolution scale. This is multiplied by 4 internally |
| 92 // (i.e. 1.0 corresponds to 1/4 pixel res). | 100 // (i.e. 1.0 corresponds to 1/4 pixel res). |
| 93 static const SkScalar kResScale = 0.3f; | 101 static const SkScalar kResScale = 0.3f; |
| 94 | 102 |
| 95 SkPath strokePath; | 103 SkPath strokePath; |
| 96 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); | 104 paint.getFillPath(m_path, &strokePath, nullptr, kResScale); |
| 97 | 105 |
| 98 return strokePath; | 106 return strokePath; |
| 99 } | 107 } |
| 100 | 108 |
| 101 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData)
const | 109 bool Path::strokeContains(const FloatPoint& point, const StrokeData& strokeData)
const |
| 102 { | 110 { |
| 103 return SkPathContainsPoint(strokePath(strokeData), point, SkPath::kWinding_F
illType); | 111 return strokePath(strokeData).contains(WebCoreFloatToSkScalar(point.x()), We
bCoreFloatToSkScalar(point.y())); |
| 104 } | 112 } |
| 105 | 113 |
| 106 FloatRect Path::boundingRect() const | 114 FloatRect Path::boundingRect() const |
| 107 { | 115 { |
| 108 return m_path.getBounds(); | 116 return m_path.getBounds(); |
| 109 } | 117 } |
| 110 | 118 |
| 111 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const | 119 FloatRect Path::strokeBoundingRect(const StrokeData& strokeData) const |
| 112 { | 120 { |
| 113 return strokePath(strokeData).getBounds(); | 121 return strokePath(strokeData).getBounds(); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 496 |
| 489 #if ENABLE(ASSERT) | 497 #if ENABLE(ASSERT) |
| 490 bool ellipseIsRenderable(float startAngle, float endAngle) | 498 bool ellipseIsRenderable(float startAngle, float endAngle) |
| 491 { | 499 { |
| 492 return (std::abs(endAngle - startAngle) < twoPiFloat) | 500 return (std::abs(endAngle - startAngle) < twoPiFloat) |
| 493 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); | 501 || WebCoreFloatNearlyEqual(std::abs(endAngle - startAngle), twoPiFloat); |
| 494 } | 502 } |
| 495 #endif | 503 #endif |
| 496 | 504 |
| 497 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |