Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/core/layout/svg/LayoutSVGResourceClipper.cpp

Issue 1185383002: [SVG] Re-enable experimental PathOpsSVGClipping support (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expectations Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 22 matching lines...) Expand all
33 #include "core/paint/PaintInfo.h" 33 #include "core/paint/PaintInfo.h"
34 #include "core/paint/TransformRecorder.h" 34 #include "core/paint/TransformRecorder.h"
35 #include "core/svg/SVGUseElement.h" 35 #include "core/svg/SVGUseElement.h"
36 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
37 #include "platform/graphics/paint/ClipPathDisplayItem.h" 37 #include "platform/graphics/paint/ClipPathDisplayItem.h"
38 #include "platform/graphics/paint/CompositingDisplayItem.h" 38 #include "platform/graphics/paint/CompositingDisplayItem.h"
39 #include "platform/graphics/paint/DisplayItemList.h" 39 #include "platform/graphics/paint/DisplayItemList.h"
40 #include "platform/graphics/paint/DrawingDisplayItem.h" 40 #include "platform/graphics/paint/DrawingDisplayItem.h"
41 #include "platform/graphics/paint/SkPictureBuilder.h" 41 #include "platform/graphics/paint/SkPictureBuilder.h"
42 #include "third_party/skia/include/core/SkPicture.h" 42 #include "third_party/skia/include/core/SkPicture.h"
43 #include "third_party/skia/include/pathops/SkPathOps.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 LayoutSVGResourceClipper::LayoutSVGResourceClipper(SVGClipPathElement* node) 47 LayoutSVGResourceClipper::LayoutSVGResourceClipper(SVGClipPathElement* node)
47 : LayoutSVGResourceContainer(node) 48 : LayoutSVGResourceContainer(node)
48 , m_inClipExpansion(false) 49 , m_inClipExpansion(false)
49 { 50 {
50 } 51 }
51 52
52 LayoutSVGResourceClipper::~LayoutSVGResourceClipper() 53 LayoutSVGResourceClipper::~LayoutSVGResourceClipper()
(...skipping 13 matching lines...) Expand all
66 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation); 67 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation);
67 } 68 }
68 69
69 bool LayoutSVGResourceClipper::tryPathOnlyClipping(const LayoutObject& layoutObj ect, GraphicsContext* context, 70 bool LayoutSVGResourceClipper::tryPathOnlyClipping(const LayoutObject& layoutObj ect, GraphicsContext* context,
70 const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundi ngBox) { 71 const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundi ngBox) {
71 // If the current clip-path gets clipped itself, we have to fallback to mask ing. 72 // If the current clip-path gets clipped itself, we have to fallback to mask ing.
72 if (!style()->svgStyle().clipperResource().isEmpty()) 73 if (!style()->svgStyle().clipperResource().isEmpty())
73 return false; 74 return false;
74 75
75 Path clipPath; 76 Path clipPath;
77 bool usingBuilder = false;
78 SkOpBuilder clipPathBuilder;
76 79
77 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 80 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
78 LayoutObject* childLayoutObject = childElement->layoutObject(); 81 LayoutObject* childLayoutObject = childElement->layoutObject();
79 if (!childLayoutObject) 82 if (!childLayoutObject)
80 continue; 83 continue;
81 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts. 84 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts.
82 if (childLayoutObject->isSVGText()) 85 if (childLayoutObject->isSVGText())
83 return false; 86 return false;
84 if (!childElement->isSVGGraphicsElement()) 87 if (!childElement->isSVGGraphicsElement())
85 continue; 88 continue;
86 SVGGraphicsElement* styled = toSVGGraphicsElement(childElement); 89 SVGGraphicsElement* styled = toSVGGraphicsElement(childElement);
87 const ComputedStyle* style = childLayoutObject->style(); 90 const ComputedStyle* style = childLayoutObject->style();
88 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 91 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
89 continue; 92 continue;
90 const SVGComputedStyle& svgStyle = style->svgStyle(); 93 const SVGComputedStyle& svgStyle = style->svgStyle();
91 // Current shape in clip-path gets clipped too. Fallback to masking. 94 // Current shape in clip-path gets clipped too. Fallback to masking.
92 if (!svgStyle.clipperResource().isEmpty()) 95 if (!svgStyle.clipperResource().isEmpty())
93 return false; 96 return false;
94 97
98 // First clip shape.
95 if (clipPath.isEmpty()) { 99 if (clipPath.isEmpty()) {
96 // First clip shape.
97 styled->toClipPath(clipPath); 100 styled->toClipPath(clipPath);
101
98 continue; 102 continue;
99 } 103 }
100 104
101 if (RuntimeEnabledFeatures::pathOpsSVGClippingEnabled()) { 105 // Multiple shapes require PathOps.
102 // Attempt to generate a combined clip path, fall back to masking if not possible. 106 if (!RuntimeEnabledFeatures::pathOpsSVGClippingEnabled())
103 Path subPath;
104 styled->toClipPath(subPath);
105 if (!clipPath.unionPath(subPath))
106 return false;
107 } else {
108 return false; 107 return false;
108
109 // Second clip shape => start using the builder.
110 if (!usingBuilder) {
111 clipPathBuilder.add(clipPath.skPath(), kUnion_SkPathOp);
112 usingBuilder = true;
109 } 113 }
114
115 Path subPath;
116 styled->toClipPath(subPath);
117 clipPathBuilder.add(subPath.skPath(), kUnion_SkPathOp);
118 }
119
120 if (usingBuilder) {
121 SkPath resolvedPath;
122 clipPathBuilder.resolve(&resolvedPath);
123 clipPath = resolvedPath;
110 } 124 }
111 125
112 // We are able to represent the clip as a path. Continue with direct clippin g, 126 // We are able to represent the clip as a path. Continue with direct clippin g,
113 // and transform the content to userspace if necessary. 127 // and transform the content to userspace if necessary.
114 if (clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { 128 if (clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
115 AffineTransform transform; 129 AffineTransform transform;
116 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); 130 transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
117 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); 131 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight());
118 clipPath.transform(transform); 132 clipPath.transform(transform);
119 } 133 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 AffineTransform transform; 269 AffineTransform transform;
256 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); 270 transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
257 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); 271 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight());
258 return transform.mapRect(m_clipBoundaries); 272 return transform.mapRect(m_clipBoundaries);
259 } 273 }
260 274
261 return m_clipBoundaries; 275 return m_clipBoundaries;
262 } 276 }
263 277
264 } 278 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698