Mike Reed | c15afe4 | 2019-12-20 14:00:41 -0500 | [diff] [blame] | 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 | |
| 11 | void 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()) { |
Michael Ludwig | 4e221bd | 2020-06-05 11:29:36 -0400 | [diff] [blame^] | 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 | } |
Mike Reed | c15afe4 | 2019-12-20 14:00:41 -0500 | [diff] [blame] | 22 | SkPath operand; |
| 23 | if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) { |
| 24 | element->asDeviceSpacePath(&operand); |
| 25 | } |
| 26 | |
| 27 | SkClipOp elementOp = element->getOp(); |
| 28 | if (elementOp == kReplace_SkClipOp) { |
| 29 | *path = operand; |
| 30 | } else { |
| 31 | Op(*path, operand, (SkPathOp)elementOp, path); |
| 32 | } |
| 33 | } |
| 34 | } |