| Flutter Impeller |

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

`#include <multi_arch_shader_archive.h>`

## Public Member Functions
| MultiArchShaderArchive (const std::shared_ptr< const fml::Mapping > &mapping)
| ~MultiArchShaderArchive ()
std::shared_ptr< const fml::Mapping > | GetArchive (ArchiveRenderingBackend backend) const
std::shared_ptr< ShaderArchive > | GetShaderArchive (ArchiveRenderingBackend backend) const
bool | IsValid () const

## Static Public Member Functions
static std::shared_ptr< ShaderArchive > | CreateArchiveFromMapping (const std::shared_ptr< const fml::Mapping > &mapping, ArchiveRenderingBackend backend)

## Detailed Description

Definition at line 18 of file multi_arch_shader_archive.h.

## Constructor & Destructor Documentation

## ◆ MultiArchShaderArchive()

impeller::MultiArchShaderArchive::MultiArchShaderArchive | ( | const std::shared_ptr< const fml::Mapping > & | mapping | ) |
| explicit

Definition at line 43 of file multi_arch_shader_archive.cc.

44 {
45 if (!mapping) {
46 return;
47 }
48
49 if (!fb::MultiArchShaderArchiveBufferHasIdentifier(mapping->GetMapping())) {
50 return;
51 }
52
53 const auto* multi_arch = fb::GetMultiArchShaderArchive(mapping->GetMapping());
54
55 if (!multi_arch) {
56 return;
57 }
58
59 if (auto archives = multi_arch->items()) {
60 for (auto i = archives->begin(), end = archives->end(); i != end; i++) {
61 // This implementation is unable to handle multiple archives for the same
62 // backend.
63 backend_mappings_[ToArchiveRenderingBackend(i->rendering_backend())] =
64 std::make_shared<fml::NonOwnedMapping>(i->mapping()->Data(),
65 i->mapping()->size(),
66 [mapping](auto, auto) {
67 // Just hold the mapping.
68 });
69 }
70 }
71
72 is_valid_ = true;
73 }

References impeller::ToArchiveRenderingBackend().

## ◆ ~MultiArchShaderArchive()

impeller::MultiArchShaderArchive::~MultiArchShaderArchive | ( |  | ) |
| default

## Member Function Documentation

## ◆ CreateArchiveFromMapping()

std::shared_ptr< ShaderArchive > impeller::MultiArchShaderArchive::CreateArchiveFromMapping | ( | const std::shared_ptr< const fml::Mapping > & | mapping,
|  | ArchiveRenderingBackend | backend
| ) |  |
| static

Definition at line 24 of file multi_arch_shader_archive.cc.

26 {
27 {
28 auto multi_archive = std::make_shared<MultiArchShaderArchive>(mapping);
29 if (multi_archive->IsValid()) {
30 return multi_archive->GetShaderArchive(backend);
31 }
32 }
33 {
34 auto single_archive =
35 std::shared_ptr<ShaderArchive>(new ShaderArchive(mapping));
36 if (single_archive->IsValid()) {
37 return single_archive;
38 }
39 }
40 return nullptr;
41 }

Referenced by impeller::testing::TEST().

## ◆ GetArchive()

std::shared_ptr< const fml::Mapping > impeller::MultiArchShaderArchive::GetArchive | ( | ArchiveRenderingBackend | backend | ) | const

Definition at line 81 of file multi_arch_shader_archive.cc.

82 {
83 auto found = backend_mappings_.find(backend);
84 if (found == backend_mappings_.end()) {
85 return nullptr;
86 }
87 return found->second;
88 }

Referenced by GetShaderArchive().

## ◆ GetShaderArchive()

std::shared_ptr< ShaderArchive > impeller::MultiArchShaderArchive::GetShaderArchive | ( | ArchiveRenderingBackend | backend | ) | const

Definition at line 90 of file multi_arch_shader_archive.cc.

91 {
92 auto archive = GetArchive(backend);
93 if (!archive) {
94 return nullptr;
95 }
96 auto shader_archive =
97 std::shared_ptr<ShaderArchive>(new ShaderArchive(std::move(archive)));
98 if (!shader_archive->IsValid()) {
99 return nullptr;
100 }
101 return shader_archive;
102 }

References GetArchive().

## ◆ IsValid()

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

Definition at line 77 of file multi_arch_shader_archive.cc.

77 {
78 return is_valid_;
79 }

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

- impeller/shader_archive/multi_arch_shader_archive.h
- impeller/shader_archive/multi_arch_shader_archive.cc

impeller::ToArchiveRenderingBackend
constexpr ArchiveRenderingBackend ToArchiveRenderingBackend(fb::RenderingBackend backend)
Definition: multi_arch_shader_archive.cc:11
impeller::MultiArchShaderArchive::GetArchive
std::shared_ptr< const fml::Mapping > GetArchive(ArchiveRenderingBackend backend) const
Definition: multi_arch_shader_archive.cc:81