| 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 * | 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // If all the radii cannot be accommodated, return a rect. | 370 // If all the radii cannot be accommodated, return a rect. |
| 371 addRect(rect); | 371 addRect(rect); |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 | 374 |
| 375 addPathForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius,
bottomRightRadius, strategy); | 375 addPathForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius,
bottomRightRadius, strategy); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void Path::addPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeft
Radius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, cons
t FloatSize& bottomRightRadius, RoundedRectStrategy strategy) | 378 void Path::addPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeft
Radius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, cons
t FloatSize& bottomRightRadius, RoundedRectStrategy strategy) |
| 379 { | 379 { |
| 380 if (strategy == PreferBezierRoundedRect) { | |
| 381 addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeft
Radius, bottomRightRadius); | |
| 382 return; | |
| 383 } | |
| 384 | |
| 385 addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadi
us, bottomRightRadius); | 380 addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadi
us, bottomRightRadius); |
| 386 } | 381 } |
| 387 | 382 |
| 388 // Approximation of control point positions on a bezier to simulate a quarter of
a circle. | 383 // Approximation of control point positions on a bezier to simulate a quarter of
a circle. |
| 389 // This is 1-kappa, where kappa = 4 * (sqrt(2) - 1) / 3 | 384 // This is 1-kappa, where kappa = 4 * (sqrt(2) - 1) / 3 |
| 390 static const float gCircleControlPoint = 0.447715f; | 385 static const float gCircleControlPoint = 0.447715f; |
| 391 | 386 |
| 392 void Path::addBeziersForRoundedRect(const FloatRect& rect, const FloatSize& topL
eftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, c
onst FloatSize& bottomRightRadius) | 387 void Path::addBeziersForRoundedRect(const FloatRect& rect, const FloatSize& topL
eftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, c
onst FloatSize& bottomRightRadius) |
| 393 { | 388 { |
| 394 moveTo(FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); | 389 moveTo(FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 421 { | 416 { |
| 422 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s
ize.height())); | 417 m_path.offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(s
ize.height())); |
| 423 } | 418 } |
| 424 | 419 |
| 425 bool Path::unionPath(const Path& other) | 420 bool Path::unionPath(const Path& other) |
| 426 { | 421 { |
| 427 return Op(m_path, other.m_path, kUnion_PathOp, &m_path); | 422 return Op(m_path, other.m_path, kUnion_PathOp, &m_path); |
| 428 } | 423 } |
| 429 | 424 |
| 430 } | 425 } |
| OLD | NEW |