Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkClipStackUtils.cpp
Go to the documentation of this file.
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
9
10#include "include/core/SkPath.h"
14
15enum class SkClipOp;
16
17void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path) {
18 path->reset();
19 path->setFillType(SkPathFillType::kInverseEvenOdd);
20
22 while (const SkClipStack::Element* element = iter.next()) {
23 if (element->getDeviceSpaceType() == SkClipStack::Element::DeviceSpaceType::kShader) {
24 // TODO: Handle DeviceSpaceType::kShader somehow; it can't be turned into an SkPath
25 // but perhaps the pdf backend can apply shaders in another way.
26 continue;
27 }
28 SkPath operand;
29 if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
30 element->asDeviceSpacePath(&operand);
31 }
32
33 SkClipOp elementOp = element->getOp();
34 if (element->isReplaceOp()) {
35 *path = operand;
36 // TODO: Once expanding clip ops are removed, we can switch the iterator to be top
37 // to bottom, which allows us to break here on encountering a replace op.
38 } else {
39 Op(*path, operand, (SkPathOp)elementOp, path);
40 }
41 }
42}
SkClipOp
Definition SkClipOp.h:13
void SkClipStack_AsPath(const SkClipStack &cs, SkPath *path)
SkPathOp
Definition SkPathOps.h:22
@ kEmpty
This element makes the clip empty (regardless of previous elements).
const Element * next()