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
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 SkPath operand;
18 if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
19 element->asDeviceSpacePath(&operand);
20 }
21
22 SkClipOp elementOp = element->getOp();
23 if (elementOp == kReplace_SkClipOp) {
24 *path = operand;
25 } else {
26 Op(*path, operand, (SkPathOp)elementOp, path);
27 }
28 }
29}
30