| 
									
										
										
										
											2022-10-03 16:25:42 +00:00
										 |  |  | #include "clippathelement.h"
 | 
					
						
							|  |  |  | #include "parser.h"
 | 
					
						
							|  |  |  | #include "layoutcontext.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace lunasvg { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ClipPathElement::ClipPathElement() | 
					
						
							| 
									
										
										
										
											2022-10-16 10:31:43 +00:00
										 |  |  |     : GraphicsElement(ElementID::ClipPath) | 
					
						
							| 
									
										
										
										
											2022-10-03 16:25:42 +00:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Units ClipPathElement::clipPathUnits() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-16 10:31:43 +00:00
										 |  |  |     auto& value = get(PropertyID::ClipPathUnits); | 
					
						
							| 
									
										
										
										
											2022-10-03 16:25:42 +00:00
										 |  |  |     return Parser::parseUnits(value, Units::UserSpaceOnUse); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::unique_ptr<LayoutClipPath> ClipPathElement::getClipper(LayoutContext* context) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if(context->hasReference(this)) | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LayoutBreaker layoutBreaker(context, this); | 
					
						
							|  |  |  |     auto clipper = std::make_unique<LayoutClipPath>(); | 
					
						
							|  |  |  |     clipper->units = clipPathUnits(); | 
					
						
							|  |  |  |     clipper->transform = transform(); | 
					
						
							|  |  |  |     clipper->clipper = context->getClipper(clip_path()); | 
					
						
							|  |  |  |     layoutChildren(context, clipper.get()); | 
					
						
							|  |  |  |     return clipper; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::unique_ptr<Node> ClipPathElement::clone() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return cloneElement<ClipPathElement>(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace lunasvg
 |