diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 23:43:18 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 23:43:18 +0000 |
commit | 5b10348cf8be7f63bc2a57ee1caeacfd4a5b97e0 (patch) | |
tree | cab0133c86de7c66c4071108079628752f7e9636 /webkit | |
parent | 7887aab583820e32b52a6e3c635ed509dd5d2979 (diff) | |
download | chromium_src-5b10348cf8be7f63bc2a57ee1caeacfd4a5b97e0.zip chromium_src-5b10348cf8be7f63bc2a57ee1caeacfd4a5b97e0.tar.gz chromium_src-5b10348cf8be7f63bc2a57ee1caeacfd4a5b97e0.tar.bz2 |
Fix all callers of the removed GraphicsContext functions to use only the functions in the upstream version of WebKit.
Review URL: http://codereview.chromium.org/9210
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
5 files changed, 47 insertions, 50 deletions
diff --git a/webkit/port/platform/graphics/GraphicsContextSkia.cpp b/webkit/port/platform/graphics/GraphicsContextSkia.cpp index 314e8dd..59e694e 100644 --- a/webkit/port/platform/graphics/GraphicsContextSkia.cpp +++ b/webkit/port/platform/graphics/GraphicsContextSkia.cpp @@ -574,39 +574,6 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth) platformContext()->canvas()->drawRect(rect, paint); } -FloatRect GraphicsContext::getBoundingBoxForCurrentPath(bool includeStroke) const -{ - SkPath boundingPath; - - if (includeStroke) { - SkPaint paint; - platformContext()->setupPaintForStroking(&paint, 0, 0); - paint.getFillPath(*platformContext()->currentPath(), &boundingPath); - } else - boundingPath = *platformContext()->currentPath(); - - SkRect r; - boundingPath.computeBounds(&r, SkPath::kExact_BoundsType); - - return r; -} - - -bool GraphicsContext::strokeContains(const Path& path, const FloatPoint& point) const -{ - SkPaint paint; - // The SkPaint state is not kept since platformContext() is NULL. - // If there is a non-identity matrix setup, the path won't be transformed - // correctly which may result in inconsistencies. - if (!paintingDisabled()) - platformContext()->setupPaintForStroking(&paint, 0, 0); - - SkPath strokePath; - paint.getFillPath(*path.platformPath(), &strokePath); - - return SkPathContainsPoint(&strokePath, point, SkPath::kWinding_FillType); -} - void GraphicsContext::fillRect(const FloatRect& rect, const Color& color) { if (paintingDisabled()) diff --git a/webkit/port/platform/graphics/svg/RenderPathSkia.cpp b/webkit/port/platform/graphics/svg/RenderPathSkia.cpp index 77ca9df..1212969 100644 --- a/webkit/port/platform/graphics/svg/RenderPathSkia.cpp +++ b/webkit/port/platform/graphics/svg/RenderPathSkia.cpp @@ -29,11 +29,13 @@ #include "config.h" #include "GraphicsContext.h" +#include "PlatformContextSkia.h" #include "RenderPath.h" -#include "SVGPaintServer.h" -#include "SkPath.h" - #include "SkiaSupport.h" +#include "SkiaUtils.h" +#include "SkPaint.h" +#include "SkPath.h" +#include "SVGPaintServer.h" #if ENABLE(SVG) @@ -50,9 +52,15 @@ bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) co GraphicsContext* scratch = scratchContext(); scratch->save(); applyStrokeStyleToContext(scratch, style(), this); - bool contains = scratch->strokeContains(path(), point); - scratch->restore(); + SkPaint paint; + scratch->platformContext()->setupPaintForStroking(&paint, 0, 0); + SkPath strokePath; + paint.getFillPath(*path().platformPath(), &strokePath); + bool contains = SkPathContainsPoint(&strokePath, point, + SkPath::kWinding_FillType); + + scratch->restore(); return contains; } diff --git a/webkit/port/platform/graphics/svg/SVGPaintServerGradientSkia.cpp b/webkit/port/platform/graphics/svg/SVGPaintServerGradientSkia.cpp index 76b2370..122e337 100644 --- a/webkit/port/platform/graphics/svg/SVGPaintServerGradientSkia.cpp +++ b/webkit/port/platform/graphics/svg/SVGPaintServerGradientSkia.cpp @@ -159,7 +159,7 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, // Calculate a matrix to transform a gradient to fit the bounding box if (boundingBoxMode()) { matrix.reset(); - SkRect rc = context->getBoundingBoxForCurrentPath(true); + SkRect rc = boundingBoxForCurrentStroke(context); matrix.preTranslate(rc.fLeft, rc.fTop); matrix.preScale(rc.width(), rc.height()); diff --git a/webkit/port/platform/graphics/svg/SkiaSupport.cpp b/webkit/port/platform/graphics/svg/SkiaSupport.cpp index 1a58df0..2c3fe0d 100644 --- a/webkit/port/platform/graphics/svg/SkiaSupport.cpp +++ b/webkit/port/platform/graphics/svg/SkiaSupport.cpp @@ -86,18 +86,30 @@ GraphicsContext* scratchContext() return scratch->context(); } -FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object) -{ - GraphicsContext* scratch = scratchContext(); - - scratch->save(); - scratch->beginPath(); - scratch->addPath(path); - applyStrokeStyleToContext(scratch, style, object); - FloatRect bbox = scratch->getBoundingBoxForCurrentPath(true); - scratch->restore(); +FloatRect boundingBoxForCurrentStroke(const GraphicsContext* context) +{ + SkPaint paint; + context->platformContext()->setupPaintForStroking(&paint, 0, 0); + SkPath boundingPath; + paint.getFillPath(*context->platformContext()->currentPath(), + &boundingPath); + SkRect r; + boundingPath.computeBounds(&r, SkPath::kExact_BoundsType); + return r; +} - return bbox; +FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, + const RenderObject* object) +{ + GraphicsContext* scratch = scratchContext(); + scratch->save(); + scratch->beginPath(); + scratch->addPath(path); + applyStrokeStyleToContext(scratch, style, object); + + FloatRect r = boundingBoxForCurrentStroke(scratch); + scratch->restore(); + return r; } } diff --git a/webkit/port/platform/graphics/svg/SkiaSupport.h b/webkit/port/platform/graphics/svg/SkiaSupport.h index b237d9b..c4e7547 100644 --- a/webkit/port/platform/graphics/svg/SkiaSupport.h +++ b/webkit/port/platform/graphics/svg/SkiaSupport.h @@ -22,7 +22,17 @@ class GraphicsContext; void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*); void applyFillStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*); +// Returns a statically allocated 1x1 GraphicsContext intended for temporary +// operations. Please save() the state and restore() it when you're done with +// the context. GraphicsContext* scratchContext(); + +// Computes the bounding box for the stroke and style currently selected into +// the given bounding box. This also takes into account the stroke width. +FloatRect boundingBoxForCurrentStroke(const GraphicsContext* context); + +// Returns the bounding box for the given path of the given style, including the +// stroke width. FloatRect strokeBoundingBox(const Path& path, RenderStyle*, const RenderObject*); } |