diff options
Diffstat (limited to 'WebCore/platform/graphics')
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsContextAndroid.cpp | 36 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/PathAndroid.cpp | 84 |
2 files changed, 120 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index 40d98ec..6a92a7f 100644 --- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -754,6 +754,18 @@ void GraphicsContext::clipOutEllipseInRect(const IntRect& r) GC2Canvas(this)->clipPath(path, SkRegion::kDifference_Op); } +#if ENABLE(SVG) +void GraphicsContext::clipPath(WindRule clipRule) +{ + if (paintingDisabled()) + return; + const SkPath* oldPath = m_data->getPath(); + SkPath path(*oldPath); + path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType); + GC2Canvas(this)->clipPath(path); +} +#endif + void GraphicsContext::clipOut(const Path& p) { if (paintingDisabled()) @@ -943,6 +955,30 @@ void GraphicsContext::setLineCap(LineCap cap) } } +#if ENABLE(SVG) +void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) +{ + if (paintingDisabled()) + return; + + // FIXME: This is lifted directly off SkiaSupport, lines 49-74 + // so it is not guaranteed to work correctly. + size_t dashLength = dashes.size(); + if (!dashLength) + return; + + size_t count = (dashLength % 2) == 0 ? dashLength : dashLength * 2; + SkScalar* intervals = new SkScalar[count]; + + for (unsigned int i = 0; i < count; i++) + intervals[i] = dashes[i % dashLength]; +// FIXME: setDashPathEffect not defined +// platformContext()->setDashPathEffect(new SkDashPathEffect(intervals, count, dashOffset)); + + delete[] intervals; +} +#endif + void GraphicsContext::setLineJoin(LineJoin join) { switch (join) { diff --git a/WebCore/platform/graphics/android/PathAndroid.cpp b/WebCore/platform/graphics/android/PathAndroid.cpp index af870f5..6687c2b 100644 --- a/WebCore/platform/graphics/android/PathAndroid.cpp +++ b/WebCore/platform/graphics/android/PathAndroid.cpp @@ -266,6 +266,64 @@ void Path::transform(const TransformationMatrix& xform) m_path->transform(xform); } +#if ENABLE(SVG) +String Path::debugString() const +{ + String result; + + SkPath::Iter iter(*m_path, false); + SkPoint pts[4]; + + int numPoints = m_path->getPoints(0, 0); + SkPath::Verb verb; + + do { + verb = iter.next(pts); + switch (verb) { + case SkPath::kMove_Verb: + result += String::format("M%.2f,%.2f ", pts[0].fX, pts[0].fY); + numPoints -= 1; + break; + case SkPath::kLine_Verb: + if (!iter.isCloseLine()) { + result += String::format("L%.2f,%.2f ", pts[1].fX, pts[1].fY); + numPoints -= 1; + } + break; + case SkPath::kQuad_Verb: + result += String::format("Q%.2f,%.2f,%.2f,%.2f ", + pts[1].fX, pts[1].fY, + pts[2].fX, pts[2].fY); + numPoints -= 2; + break; + case SkPath::kCubic_Verb: + result += String::format("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f ", + pts[1].fX, pts[1].fY, + pts[2].fX, pts[2].fY, + pts[3].fX, pts[3].fY); + numPoints -= 3; + break; + case SkPath::kClose_Verb: + result += "Z "; + break; + case SkPath::kDone_Verb: + break; + } + } while (verb != SkPath::kDone_Verb); + + // If you have a path that ends with an M, Skia will not iterate the + // trailing M. That's nice of it, but Apple's paths output the trailing M + // and we want out layout dumps to look like theirs + if (numPoints) { + ASSERT(numPoints==1); + m_path->getLastPt(pts); + result += String::format("M%.2f,%.2f ", pts[0].fX, pts[0].fY); + } + + return result.stripWhiteSpace(); +} +#endif + /////////////////////////////////////////////////////////////////////////////// // Computes the bounding box for the stroke and style currently selected into @@ -311,4 +369,30 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) return r; } +#if ENABLE(SVG) +bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const +{ +#if 0 + ASSERT(applier); + GraphicsContext* scratch = scratchContext(); + scratch->save(); + + applier->strokeStyle(scratch); + + SkPaint paint; + scratch->platformContext()->setupPaintForStroking(&paint, 0, 0); + SkPath strokePath; + paint.getFillPath(*platformPath(), &strokePath); + bool contains = SkPathContainsPoint(&strokePath, point, + SkPath::kWinding_FillType); + + scratch->restore(); + return contains; +#else + // FIXME: + return false; +#endif +} +#endif + } |