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