| Flutter Impeller |

Public Types | Public Member Functions | Static Public Attributes | List of all members
impeller::Renderer Class Reference

`#include <renderer.h>`

## Public Types
using | RenderCallback = std::function< bool(RenderTarget &render_target)>

## Public Member Functions
| Renderer (std::shared_ptr< Context > context, size_t max_frames_in_flight=kDefaultMaxFramesInFlight)
| ~Renderer ()
bool | IsValid () const
bool | Render (std::unique_ptr< Surface > surface, const RenderCallback &callback) const
std::shared_ptr< Context > | GetContext () const

## Static Public Attributes
static constexpr size_t | kDefaultMaxFramesInFlight = 3u

## Detailed Description

Definition at line 19 of file renderer.h.

## Member Typedef Documentation

## ◆ RenderCallback

using impeller::Renderer::RenderCallback = std::function<bool(RenderTarget& render_target)>

Definition at line 23 of file renderer.h.

## Constructor & Destructor Documentation

## ◆ Renderer()

impeller::Renderer::Renderer | ( | std::shared_ptr< Context > | context,
|  | size_t | max_frames_in_flight = `kDefaultMaxFramesInFlight`
| ) |  |
| explicit

Definition at line 15 of file renderer.cc.

17 : frames_in_flight_sema_(std::make_shared<fml::Semaphore>(
18 std::max<std::size_t>(1u, max_frames_in_flight))),
19 context_(std::move(context)) {
20 if (!context_ || !context_->IsValid()) {
21 return;
22 }
23
24 is_valid_ = true;
25 }

## ◆ ~Renderer()

impeller::Renderer::~Renderer | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetContext()

std::shared_ptr< Context > impeller::Renderer::GetContext | ( |  | ) | const

Definition at line 61 of file renderer.cc.

61 {
62 return context_;
63 }

## ◆ IsValid()

bool impeller::Renderer::IsValid | ( |  | ) | const

Definition at line 29 of file renderer.cc.

29 {
30 return is_valid_;
31 }

Referenced by Render().

## ◆ Render()

bool impeller::Renderer::Render | ( | std::unique_ptr< Surface > | surface,
|  | const RenderCallback & | callback
| ) |  | const

Definition at line 33 of file renderer.cc.

34 {
35 TRACE_EVENT0("impeller", "Renderer::Render");
36 if (!IsValid()) {
37 return false;
38 }
39
40 if (!surface || !surface->IsValid()) {
41 return false;
42 }
43
44 RenderTarget render_target = surface->GetTargetRenderPassDescriptor();
45
46 if (render_callback && !render_callback(render_target)) {
47 return false;
48 }
49
50 if (!frames_in_flight_sema_->Wait()) {
51 return false;
52 }
53
54 const auto present_result = surface->Present();
55
56 frames_in_flight_sema_->Signal();
57
58 return present_result;
59 }

References IsValid().

## Member Data Documentation

## ◆ kDefaultMaxFramesInFlight

constexpr size_t impeller::Renderer::kDefaultMaxFramesInFlight = 3u
| static constexpr

Definition at line 21 of file renderer.h.

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

- impeller/renderer/renderer.h
- impeller/renderer/renderer.cc

impeller::Renderer::IsValid
bool IsValid() const
Definition: renderer.cc:29