| 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 21 of file renderer.h.

## Member Typedef Documentation

## ◆ RenderCallback

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

Definition at line 25 of file renderer.h.

## Constructor & Destructor Documentation

## ◆ Renderer()

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

Definition at line 17 of file renderer.cc.

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

## ◆ ~Renderer()

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

## Member Function Documentation

## ◆ GetContext()

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

Definition at line 63 of file renderer.cc.

63 {
64 return context_;
65 }

## ◆ IsValid()

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

Definition at line 31 of file renderer.cc.

31 {
32 return is_valid_;
33 }

Referenced by Render().

## ◆ Render()

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

Definition at line 35 of file renderer.cc.

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

References IsValid().

## Member Data Documentation

## ◆ kDefaultMaxFramesInFlight

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

Definition at line 23 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:31