| Flutter Impeller |

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

`#include <entity_pass_target.h>`

## Public Member Functions
| EntityPassTarget (const RenderTarget &render_target, bool supports_read_from_resolve)
std::shared_ptr< Texture > | Flip (Allocator &allocator)
| Flips the backdrop and returns a readable texture that can be bound/sampled to restore the previous pass. More...
const RenderTarget & | GetRenderTarget () const
bool | IsValid () const

## Detailed Description

Definition at line 14 of file entity_pass_target.h.

## Constructor & Destructor Documentation

## ◆ EntityPassTarget()

impeller::EntityPassTarget::EntityPassTarget | ( | const RenderTarget & | render_target,
|  | bool | supports_read_from_resolve
| ) |  |
| explicit

Definition at line 13 of file entity_pass_target.cc.

15 : target_(render_target),
16 supports_read_from_resolve_(supports_read_from_resolve) {}

## Member Function Documentation

## ◆ Flip()

std::shared_ptr< Texture > impeller::EntityPassTarget::Flip | ( | Allocator & | allocator | ) |

Flips the backdrop and returns a readable texture that can be bound/sampled to restore the previous pass.

After this method is called, a new `RenderPass` that attaches the result of `GetRenderTarget` is guaranteed to be able to read the previous pass's backdrop texture (which is returned by this method).

Definition at line 18 of file entity_pass_target.cc.

18 {
19 auto color0 = target_.GetColorAttachments().find(0)->second;
20 if (!color0.resolve_texture) {
21 VALIDATION_LOG << "EntityPassTarget Flip should never be called for a "
22 "non-MSAA target.";
23 // ...because there is never a circumstance where doing so would be
24 // necessary. Unlike MSAA passes, non-MSAA passes can be trivially loaded
25 // with `LoadAction::kLoad`.
26 return color0.texture;
27 }
28
29 if (supports_read_from_resolve_) {
30 // Just return the current resolve texture, which is safe to read in the
31 // next render pass that'll resolve to `target_`.
32 //
33 // Note that this can only be done when MSAA is being used.
34 return color0.resolve_texture;
35 }
36
37 if (!secondary_color_texture_) {
38 // The second texture is allocated lazily to avoid unused allocations.
39 TextureDescriptor new_descriptor =
40 color0.resolve_texture->GetTextureDescriptor();
41 secondary_color_texture_ = allocator.CreateTexture(new_descriptor);
42
43 if (!secondary_color_texture_) {
44 return nullptr;
45 }
46 }
47
48 std::swap(color0.resolve_texture, secondary_color_texture_);
49
50 target_.SetColorAttachment(color0, 0);
51
52 // Return the previous backdrop texture, which is safe to read in the next
53 // render pass that attaches `target_`.
54 return secondary_color_texture_;
55 }

References impeller::Allocator::CreateTexture(), impeller::RenderTarget::GetColorAttachments(), impeller::RenderTarget::SetColorAttachment(), and VALIDATION_LOG.

Referenced by impeller::InlinePassContext::GetRenderPass().

## ◆ GetRenderTarget()

const RenderTarget & impeller::EntityPassTarget::GetRenderTarget | ( |  | ) | const

Definition at line 57 of file entity_pass_target.cc.

57 {
58 return target_;
59 }

Referenced by impeller::InlinePassContext::GetRenderPass(), and impeller::InlinePassContext::GetTexture().

## ◆ IsValid()

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

Definition at line 61 of file entity_pass_target.cc.

61 {
62 return target_.IsValid();
63 }

References impeller::RenderTarget::IsValid().

Referenced by impeller::InlinePassContext::IsValid().

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

- impeller/entity/entity_pass_target.h
- impeller/entity/entity_pass_target.cc

impeller::RenderTarget::SetColorAttachment
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
Definition: render_target.cc:180
impeller::RenderTarget::GetColorAttachments
const std::map< size_t, ColorAttachment > & GetColorAttachments() const
Definition: render_target.cc:209
impeller::RenderTarget::IsValid
bool IsValid() const
Definition: render_target.cc:34
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60