| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 return result.stripWhiteSpace(); | 267 return result.stripWhiteSpace(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Computes the bounding box for the stroke and style currently selected into | 270 // Computes the bounding box for the stroke and style currently selected into |
| 271 // the given bounding box. This also takes into account the stroke width. | 271 // the given bounding box. This also takes into account the stroke width. |
| 272 static FloatRect boundingBoxForCurrentStroke(const GraphicsContext* context) | 272 static FloatRect boundingBoxForCurrentStroke(const GraphicsContext* context) |
| 273 { | 273 { |
| 274 SkPaint paint; | 274 SkPaint paint; |
| 275 context->platformContext()->setupPaintForStroking(&paint, 0, 0); | 275 context->platformContext()->setupPaintForStroking(&paint, 0, 0); |
| 276 SkPath boundingPath; | 276 SkPath boundingPath; |
| 277 paint.getFillPath(*context->platformContext()->currentPath(), &boundingPath)
; | 277 paint.getFillPath( |
| 278 context->platformContext()->currentPathInLocalCoordinates(), |
| 279 &boundingPath); |
| 278 SkRect r; | 280 SkRect r; |
| 279 boundingPath.computeBounds(&r, SkPath::kExact_BoundsType); | 281 boundingPath.computeBounds(&r, SkPath::kExact_BoundsType); |
| 280 return r; | 282 return r; |
| 281 } | 283 } |
| 282 | 284 |
| 283 FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) | 285 FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) |
| 284 { | 286 { |
| 285 GraphicsContext* scratch = scratchContext(); | 287 GraphicsContext* scratch = scratchContext(); |
| 286 scratch->save(); | 288 scratch->save(); |
| 287 scratch->beginPath(); | 289 scratch->beginPath(); |
| 288 scratch->addPath(*this); | 290 scratch->addPath(*this); |
| 289 | 291 |
| 290 if (applier) | 292 if (applier) |
| 291 applier->strokeStyle(scratch); | 293 applier->strokeStyle(scratch); |
| 292 | 294 |
| 293 FloatRect r = boundingBoxForCurrentStroke(scratch); | 295 FloatRect r = boundingBoxForCurrentStroke(scratch); |
| 294 scratch->restore(); | 296 scratch->restore(); |
| 295 return r; | 297 return r; |
| 296 } | 298 } |
| 297 | 299 |
| 298 } // namespace WebCore | 300 } // namespace WebCore |
| OLD | NEW |