| 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 20 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 18 of file scene.cc.

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

## ◆ ~Scene()

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

Definition at line 23 of file scene.cc.

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

References GetRoot().

## Member Function Documentation

## ◆ GetRoot()

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

Definition at line 29 of file scene.cc.

29 {
30 return root_;
31 }

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 60 of file scene.cc.

60 {
61 return Render(render_target,
62 camera.GetTransform(render_target.GetRenderTargetSize()));
63 }

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 33 of file scene.cc.

34 {
35 // Collect the render commands from the scene.
36 SceneEncoder encoder;
37 if (!root_.Render(encoder,
38 *scene_context_->GetContext()->GetResourceAllocator(),
39 Matrix())) {
40 FML_LOG(ERROR) << "Failed to render frame.";
41 return false;
42 }
43
44 // Encode the commands.
45
46 std::shared_ptr<CommandBuffer> command_buffer =
47 encoder.BuildSceneCommandBuffer(*scene_context_, camera_transform,
48 render_target);
49
50 // TODO(bdero): Do post processing.
51
52 if (!command_buffer->SubmitCommands()) {
53 FML_LOG(ERROR) << "Failed to submit command buffer.";
54 return false;
55 }
56
57 return true;
58 }

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

Referenced by impeller::SceneContents::Render(), and 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:29
impeller::scene::Node::Render
bool Render(SceneEncoder &encoder, Allocator &allocator, const Matrix &parent_transform)
Definition: node.cc:354
impeller::scene::Scene::Render
bool Render(const RenderTarget &render_target, const Matrix &camera_transform)
Definition: scene.cc:33