summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics
diff options
context:
space:
mode:
authorCary Clark <>2009-04-08 08:09:33 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-08 08:09:33 -0700
commit05f9657eb2c4baad54f87aa1f9dd9b51c5a6d149 (patch)
tree5b580d83cf57d319175f065e93316ccbdfeaac11 /WebCore/platform/graphics
parentc398112a54344846e338f2722709d9c00af10263 (diff)
downloadexternal_webkit-05f9657eb2c4baad54f87aa1f9dd9b51c5a6d149.zip
external_webkit-05f9657eb2c4baad54f87aa1f9dd9b51c5a6d149.tar.gz
external_webkit-05f9657eb2c4baad54f87aa1f9dd9b51c5a6d149.tar.bz2
AI 145053: add SVG to the browser [disabled by default]
To enable SVG, edit your buildspec.mk to ENABLE_SVG:=true then make clean-libwebcore && make Some SVG functionality has been stubbed out in this checkin. //branches/master/android/build/buildspec.mk.default # edit - add ENABLE_SVG, commented out by default - fix up WEBCORE_INSTRUMENTATION define while I was in there //branches/master/android/external/webkit/Android.mk # edit - add ENABLE_SVG C define - add svg paths to C includes //branches/master/android/external/webkit/WebCore/Android.derived.mk # edit - update merge tool rules - add svg to css property names, keywords, generated bindings - add svg names, element factory, wrappers - remove obsolete ksvgcssproperties.h - add XLinkNames, required by SVG //branches/master/android/external/webkit/WebCore/Android.mk # edit - update merge tool rules - add svg bindings, css svg parsing, svg rendering, svg engine //branches/master/android/external/webkit/WebCore/config.h # edit - leave ENABLE_SVG alone if it is already defined //branches/master/android/external/webkit/WebCore/loader/EmptyClients.h # edit - add some Android extensions as empty virtuals (EmptyClients is only used by SVG) //branches/master/android/external/webkit/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp # edit //branches/master/android/external/webkit/WebCore/platform/graphics/android/PathAndroid.cpp # edit - add SVG graphics porting functions. Note the FIXMEs -- some are unimplemented. BUG=1474412 Automated import of CL 145053
Diffstat (limited to 'WebCore/platform/graphics')
-rw-r--r--WebCore/platform/graphics/android/GraphicsContextAndroid.cpp36
-rw-r--r--WebCore/platform/graphics/android/PathAndroid.cpp84
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
+
}