summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/graphics/SVGResourceClipper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg/graphics/SVGResourceClipper.cpp')
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp
index f03f5c2..51bda0d 100644
--- a/WebCore/svg/graphics/SVGResourceClipper.cpp
+++ b/WebCore/svg/graphics/SVGResourceClipper.cpp
@@ -28,8 +28,14 @@
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
+#include "TransformationMatrix.h"
+#include "GraphicsContext.h"
#include "SVGRenderTreeAsText.h"
+#if PLATFORM(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
namespace WebCore {
SVGResourceClipper::SVGResourceClipper()
@@ -46,6 +52,39 @@ void SVGResourceClipper::resetClipData()
m_clipData.clear();
}
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ if (m_clipData.clipData().isEmpty())
+ return;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ context->beginPath();
+
+ for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData clipData = m_clipData.clipData()[x];
+ if (clipData.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ Path clipPath = clipData.path;
+
+ if (clipData.bboxUnits) {
+ TransformationMatrix transform;
+ transform.translate(boundingBox.x(), boundingBox.y());
+ transform.scale(boundingBox.width(), boundingBox.height());
+ clipPath.transform(transform);
+ }
+ context->addPath(clipPath);
+ }
+
+ // FIXME!
+ // We don't currently allow for heterogenous clip rules.
+ // we would have to detect such, draw to a mask, and then clip
+ // to that mask
+ context->clipPath(clipRule);
+}
+
void SVGResourceClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
{
m_clipData.addPath(path, rule, bboxUnits);