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