2016-07-27 01:46:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "experimental/svg/model/SkSVGContainer.h"
|
2016-07-27 01:46:34 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
|
|
|
#include "include/pathops/SkPathOps.h"
|
2016-12-08 14:26:47 +00:00
|
|
|
|
2016-07-27 01:46:34 +00:00
|
|
|
SkSVGContainer::SkSVGContainer(SkSVGTag t) : INHERITED(t) { }
|
|
|
|
|
|
|
|
void SkSVGContainer::appendChild(sk_sp<SkSVGNode> node) {
|
|
|
|
SkASSERT(node);
|
|
|
|
fChildren.push_back(std::move(node));
|
|
|
|
}
|
|
|
|
|
2016-09-20 22:45:57 +00:00
|
|
|
bool SkSVGContainer::hasChildren() const {
|
|
|
|
return !fChildren.empty();
|
|
|
|
}
|
|
|
|
|
2016-08-08 18:38:55 +00:00
|
|
|
void SkSVGContainer::onRender(const SkSVGRenderContext& ctx) const {
|
2016-07-27 01:46:34 +00:00
|
|
|
for (int i = 0; i < fChildren.count(); ++i) {
|
2016-08-08 18:38:55 +00:00
|
|
|
fChildren[i]->render(ctx);
|
2016-07-27 01:46:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-08 14:26:47 +00:00
|
|
|
|
|
|
|
SkPath SkSVGContainer::onAsPath(const SkSVGRenderContext& ctx) const {
|
|
|
|
SkPath path;
|
|
|
|
|
|
|
|
for (int i = 0; i < fChildren.count(); ++i) {
|
|
|
|
const SkPath childPath = fChildren[i]->asPath(ctx);
|
|
|
|
|
|
|
|
Op(path, childPath, kUnion_SkPathOp, &path);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->mapToParent(&path);
|
|
|
|
return path;
|
|
|
|
}
|