Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / utils / SkClipStackUtils.cpp
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 "src/utils/SkClipStackUtils.h"
9
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"
15
16 void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path) {
17     path->reset();
18     path->setFillType(SkPathFillType::kInverseEvenOdd);
19
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.
25             continue;
26         }
27         SkPath operand;
28         if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
29             element->asDeviceSpacePath(&operand);
30         }
31
32         SkClipOp elementOp = element->getOp();
33         if (element->isReplaceOp()) {
34             *path = operand;
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.
37         } else {
38             Op(*path, operand, (SkPathOp)elementOp, path);
39         }
40     }
41 }