| 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, bool supports_implicit_msaa)
std::shared_ptr< Texture > | Flip (const ContentContext &renderer)
| Flips the backdrop and returns a readable texture that can be bound/sampled to restore the previous pass. More...
RenderTarget & | GetRenderTarget ()
void | RemoveSecondary ()
| Remove the cached secondary color texture. More...
bool | IsValid () const

## Detailed Description

Definition at line 15 of file entity_pass_target.h.

## Constructor & Destructor Documentation

## ◆ EntityPassTarget()

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

Definition at line 13 of file entity_pass_target.cc.

16 : target_(render_target),
17 supports_read_from_resolve_(supports_read_from_resolve),
18 supports_implicit_msaa_(supports_implicit_msaa) {}

## Member Function Documentation

## ◆ Flip()

std::shared_ptr< Texture > impeller::EntityPassTarget::Flip | ( | const ContentContext & | renderer | ) |

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

21 {
22 ColorAttachment color0 = target_.GetColorAttachment(0);
23 if (!color0.resolve_texture) {
24 VALIDATION_LOG << "EntityPassTarget Flip should never be called for a "
25 "non-MSAA target.";
26 // ...because there is never a circumstance where doing so would be
27 // necessary. Unlike MSAA passes, non-MSAA passes can be trivially loaded
28 // with `LoadAction::kLoad`.
29 return color0.texture;
30 }
31
32 if (supports_read_from_resolve_) {
33 // Just return the current resolve texture, which is safe to read in the
34 // next render pass that'll resolve to `target_`.
35 //
36 // Note that this can only be done when MSAA is being used.
37 return color0.resolve_texture;
38 }
39
40 if (!secondary_color_texture_) {
41 // The second texture is allocated lazily to avoid unused allocations.
42 TextureDescriptor new_descriptor =
43 color0.resolve_texture->GetTextureDescriptor();
44 RenderTarget target = renderer.GetRenderTargetCache()->CreateOffscreenMSAA(
45 *renderer.GetContext(), new_descriptor.size, 1);
46 secondary_color_texture_ = target.GetRenderTargetTexture();
47
48 if (!secondary_color_texture_) {
49 return nullptr;
50 }
51 }
52
53 // If the color0 resolve texture is the same as the texture, then we're
54 // running on the GLES backend with implicit resolve.
55 if (supports_implicit_msaa_) {
56 auto new_secondary = color0.resolve_texture;
57 color0.resolve_texture = secondary_color_texture_;
58 color0.texture = secondary_color_texture_;
59 secondary_color_texture_ = new_secondary;
60 } else {
61 std::swap(color0.resolve_texture, secondary_color_texture_);
62 }
63
64 target_.SetColorAttachment(color0, 0);
65
66 // Return the previous backdrop texture, which is safe to read in the next
67 // render pass that attaches `target_`.
68 return secondary_color_texture_;
69 }
impeller::RenderTarget::GetColorAttachment
ColorAttachment GetColorAttachment(size_t index) const
Get the color attachment at [index].
Definition: render_target.cc:233
impeller::RenderTarget::SetColorAttachment
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
Definition: render_target.cc:199
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::RenderTarget::GetColorAttachment(), impeller::ContentContext::GetContext(), impeller::ContentContext::GetRenderTargetCache(), impeller::RenderTarget::GetRenderTargetTexture(), impeller::Attachment::resolve_texture, impeller::RenderTarget::SetColorAttachment(), impeller::TextureDescriptor::size, impeller::Attachment::texture, and VALIDATION_LOG.

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

## ◆ GetRenderTarget()

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

Definition at line 71 of file entity_pass_target.cc.

71 {
72 return target_;
73 }

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

## ◆ IsValid()

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

Definition at line 75 of file entity_pass_target.cc.

75 {
76 return target_.IsValid();
77 }
impeller::RenderTarget::IsValid
bool IsValid() const
Definition: render_target.cc:23

References impeller::RenderTarget::IsValid().

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

## ◆ RemoveSecondary()

void impeller::EntityPassTarget::RemoveSecondary | ( |  | ) |

Remove the cached secondary color texture.

Definition at line 79 of file entity_pass_target.cc.

79 {
80 secondary_color_texture_ = nullptr;
81 }

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

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