| Flutter Impeller |

Public Member Functions | List of all members
impeller::scene::Scene Class Reference

`#include <scene.h>`

## Public Member Functions
| Scene ()=delete
| Scene (std::shared_ptr< SceneContext > scene_context)
| ~Scene ()
Node & | GetRoot ()
bool | Render (const RenderTarget &render_target, const Matrix &camera_transform)
bool | Render (const RenderTarget &render_target, const Camera &camera)

## Detailed Description

Definition at line 18 of file scene.h.

## Constructor & Destructor Documentation

## ◆ Scene() [1/2]

impeller::scene::Scene::Scene | ( |  | ) |
| delete

## ◆ Scene() [2/2]

impeller::scene::Scene::Scene | ( | std::shared_ptr< SceneContext > | scene_context | ) |
| explicit

Definition at line 19 of file scene.cc.

20 : scene_context_(std::move(scene_context)) {
21 root_.is_root_ = true;
22 };

## ◆ ~Scene()

impeller::scene::Scene::~Scene | ( |  | ) |

Definition at line 24 of file scene.cc.

24 {
25 for (auto& child : GetRoot().GetChildren()) {
26 child->parent_ = nullptr;
27 }
28 }

References GetRoot().

## Member Function Documentation

## ◆ GetRoot()

Node & impeller::scene::Scene::GetRoot | ( |  | ) |

Definition at line 30 of file scene.cc.

30 {
31 return root_;
32 }

Referenced by impeller::SceneContents::Render(), and ~Scene().

## ◆ Render() [1/2]

bool impeller::scene::Scene::Render | ( | const RenderTarget & | render_target,
|  | const Camera & | camera
| ) |  |

Definition at line 67 of file scene.cc.

67 {
68 return Render(render_target,
69 camera.GetTransform(render_target.GetRenderTargetSize()));
70 }

References impeller::RenderTarget::GetRenderTargetSize(), impeller::scene::Camera::GetTransform(), and Render().

## ◆ Render() [2/2]

bool impeller::scene::Scene::Render | ( | const RenderTarget & | render_target,
|  | const Matrix & | camera_transform
| ) |  |

Definition at line 34 of file scene.cc.

35 {
36 fml::ScopedCleanupClosure reset_state(
37 [context = scene_context_]() { context->GetTransientsBuffer().Reset(); });
38
39 // Collect the render commands from the scene.
40 SceneEncoder encoder;
41 if (!root_.Render(encoder,
42 *scene_context_->GetContext()->GetResourceAllocator(),
43 Matrix())) {
44 FML_LOG(ERROR) << "Failed to render frame.";
45 return false;
46 }
47
48 // Encode the commands.
49
50 std::shared_ptr<CommandBuffer> command_buffer =
51 encoder.BuildSceneCommandBuffer(*scene_context_, camera_transform,
52 render_target);
53
54 // TODO(bdero): Do post processing.
55
56 if (!scene_context_->GetContext()
57 ->GetCommandQueue()
58 ->Submit({command_buffer})
59 .ok()) {
60 FML_LOG(ERROR) << "Failed to submit command buffer.";
61 return false;
62 }
63
64 return true;
65 }

References impeller::scene::Node::Render().

Referenced by Render(), and impeller::SceneContents::Render().

The documentation for this class was generated from the following files:

- impeller/scene/scene.h
- impeller/scene/scene.cc

impeller::scene::Scene::GetRoot
Node & GetRoot()
Definition: scene.cc:30
impeller::scene::Node::Render
bool Render(SceneEncoder &encoder, Allocator &allocator, const Matrix &parent_transform)
Definition: node.cc:345
impeller::scene::Scene::Render
bool Render(const RenderTarget &render_target, const Matrix &camera_transform)
Definition: scene.cc:34