1 | /* |
---|---|
2 | * Copyright 2018 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 "modules/sksg/include/SkSGScene.h" |
9 | |
10 | #include "include/core/SkCanvas.h" |
11 | #include "include/core/SkMatrix.h" |
12 | #include "include/core/SkPaint.h" |
13 | #include "modules/sksg/include/SkSGInvalidationController.h" |
14 | #include "modules/sksg/include/SkSGRenderNode.h" |
15 | |
16 | namespace sksg { |
17 | |
18 | std::unique_ptr<Scene> Scene::Make(sk_sp<RenderNode> root) { |
19 | return root ? std::unique_ptr<Scene>(new Scene(std::move(root))) : nullptr; |
20 | } |
21 | |
22 | Scene::Scene(sk_sp<RenderNode> root) : fRoot(std::move(root)) {} |
23 | |
24 | Scene::~Scene() = default; |
25 | |
26 | void Scene::render(SkCanvas* canvas) const { |
27 | // Ensure the SG is revalidated. |
28 | // Note: this is a no-op if the scene has already been revalidated - e.g. in animate(). |
29 | fRoot->revalidate(nullptr, SkMatrix::I()); |
30 | |
31 | fRoot->render(canvas); |
32 | } |
33 | |
34 | void Scene::revalidate(InvalidationController* ic) { |
35 | fRoot->revalidate(ic, SkMatrix::I()); |
36 | } |
37 | |
38 | const RenderNode* Scene::nodeAt(const SkPoint& p) const { |
39 | return fRoot->nodeAt(p); |
40 | } |
41 | |
42 | } // namespace sksg |
43 |