1 /* 2 * Copyright 2019 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "include/pathops/SkPathOps.h" 9 #include "src/core/SkClipStack.h" 10 SkClipStack_AsPath(const SkClipStack & cs,SkPath * path)11void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path) { 12 path->reset(); 13 path->setFillType(SkPathFillType::kInverseEvenOdd); 14 15 SkClipStack::Iter iter(cs, SkClipStack::Iter::kBottom_IterStart); 16 while (const SkClipStack::Element* element = iter.next()) { 17 if (element->getDeviceSpaceType() == SkClipStack::Element::DeviceSpaceType::kShader) { 18 // TODO: Handle DeviceSpaceType::kShader somehow; it can't be turned into an SkPath 19 // but perhaps the pdf backend can apply shaders in another way. 20 continue; 21 } 22 SkPath operand; 23 if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) { 24 element->asDeviceSpacePath(&operand); 25 } 26 27 SkClipOp elementOp = element->getOp(); 28 if (element->isReplaceOp()) { 29 *path = operand; 30 // TODO: Once expanding clip ops are removed, we can switch the iterator to be top 31 // to bottom, which allows us to break here on encountering a replace op. 32 } else { 33 Op(*path, operand, (SkPathOp)elementOp, path); 34 } 35 } 36 } 37