diff options
author | Steve Block <steveblock@google.com> | 2011-05-19 12:30:26 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-25 15:27:42 +0100 |
commit | 1db27a13dbd4fb89dc18870bd92cc4ec87a65a62 (patch) | |
tree | 3bc57983444e1f73a823c525138a57b66e9678ad /Source | |
parent | f68e15471b3701aa588af98e9a0308b202381151 (diff) | |
download | external_webkit-1db27a13dbd4fb89dc18870bd92cc4ec87a65a62.zip external_webkit-1db27a13dbd4fb89dc18870bd92cc4ec87a65a62.tar.gz external_webkit-1db27a13dbd4fb89dc18870bd92cc4ec87a65a62.tar.bz2 |
Merge WebKit at r78450: GraphicsContext current path removed
See http://trac.webkit.org/changeset/76688
Change-Id: I1de96683ffe1805f710ac8161579d3a399065f4d
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp | 60 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/PathAndroid.cpp | 31 |
2 files changed, 12 insertions, 79 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index 888be5b..012c1a8 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -115,7 +115,6 @@ struct ShadowRec { class GraphicsContextPlatformPrivate { public: struct State { - SkPath* path; SkPathEffect* pathEffect; float miterLimit; float alpha; @@ -133,8 +132,7 @@ public: WTF::Vector<SkPath> antiAliasClipPaths; State() - : path(0) // Lazily allocated - , pathEffect(0) + : pathEffect(0) , miterLimit(4) , alpha(1) , strokeThickness(0) // Same as default in GraphicsContextPrivate.h @@ -162,13 +160,11 @@ public: , strokeColor(other.strokeColor) , useAA(other.useAA) { - path = deepCopyPtr<SkPath>(other.path); SkSafeRef(pathEffect); } ~State() { - delete path; SkSafeUnref(pathEffect); } @@ -273,26 +269,6 @@ public: m_state->strokeThickness = f; } - void beginPath() - { - if (m_state->path) - m_state->path->reset(); - } - - void addPath(const SkPath& other) - { - if (!m_state->path) - m_state->path = new SkPath(other); - else - m_state->path->addPath(other); - } - - // May return null - SkPath* getPath() const - { - return m_state->path; - } - void setupPaintCommon(SkPaint* paint) const { paint->setAntiAlias(m_state->useAA); @@ -538,11 +514,6 @@ bool GraphicsContext::willStroke() const return m_data->getState()->strokeColor; } -const SkPath* GraphicsContext::getCurrPath() const -{ - return m_data->getState()->path; -} - // Draws a filled rectangle with a stroked border. void GraphicsContext::drawRect(const IntRect& rect) { @@ -909,12 +880,7 @@ void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToClip); - - const SkPath* oldPath = m_data->getPath(); - SkPath path(*oldPath); + SkPath path = *pathToClip.platformPath(); path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType); GC2CANVAS(this)->clipPath(path); } @@ -1231,23 +1197,9 @@ AffineTransform GraphicsContext::getCTM() const /////////////////////////////////////////////////////////////////////////////// -void GraphicsContext::beginPath() -{ - m_data->beginPath(); -} - -void GraphicsContext::addPath(const Path& p) -{ - m_data->addPath(*p.platformPath()); -} - void GraphicsContext::fillPath(const Path& pathToFill) { - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToFill); - - SkPath* path = m_data->getPath(); + SkPath* path = pathToFill.platformPath(); if (paintingDisabled() || !path) return; @@ -1272,11 +1224,7 @@ void GraphicsContext::fillPath(const Path& pathToFill) void GraphicsContext::strokePath(const Path& pathToStroke) { - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToStroke); - - const SkPath* path = m_data->getPath(); + const SkPath* path = pathToStroke.platformPath(); if (paintingDisabled() || !path) return; diff --git a/Source/WebCore/platform/graphics/android/PathAndroid.cpp b/Source/WebCore/platform/graphics/android/PathAndroid.cpp index e0d7171..ad345bb 100644 --- a/Source/WebCore/platform/graphics/android/PathAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/PathAndroid.cpp @@ -285,35 +285,20 @@ void Path::transform(const AffineTransform& xform) /////////////////////////////////////////////////////////////////////////////// -// Computes the bounding box for the stroke and style currently selected into -// the given bounding box. This also takes into account the stroke width. -static FloatRect boundingBoxForCurrentStroke(GraphicsContext* context) -{ - const SkPath* path = context->getCurrPath(); - if (NULL == path) { - return FloatRect(); - } - - SkPaint paint; - context->setupStrokePaint(&paint); - SkPath fillPath; - paint.getFillPath(*path, &fillPath); - const SkRect& r = fillPath.getBounds(); - return FloatRect(SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), - SkScalarToFloat(r.width()), SkScalarToFloat(r.height())); -} - FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) { GraphicsContext* scratch = scratchContext(); scratch->save(); - scratch->beginPath(); - scratch->addPath(*this); - + if (applier) applier->strokeStyle(scratch); - - FloatRect r = boundingBoxForCurrentStroke(scratch); + + SkPaint paint; + scratch->setupStrokePaint(&paint); + SkPath boundingPath; + paint.getFillPath(*platformPath(), &boundingPath); + + FloatRect r = boundingPath.getBounds(); scratch->restore(); return r; } |