| Flutter Impeller |

Public Member Functions | List of all members
impeller::compiler::Includer Class Referencefinal

`#include <includer.h>`

Inheritance diagram for impeller::compiler::Includer:

## Public Member Functions
| Includer (std::shared_ptr< fml::UniqueFD > working_directory, std::vector< IncludeDir > include_dirs, std::function< void(std::string)> on_file_included)
| ~Includer () override
shaderc_include_result * | GetInclude (const char *requested_source, shaderc_include_type type, const char *requesting_source, size_t include_depth) override
void | ReleaseInclude (shaderc_include_result *data) override

## Detailed Description

Definition at line 25 of file includer.h.

## Constructor & Destructor Documentation

## ◆ Includer()

impeller::compiler::Includer::Includer | ( | std::shared_ptr< fml::UniqueFD > | working_directory,
|  | std::vector< IncludeDir > | include_dirs,
|  | std::function< void(std::string)> | on_file_included
| ) |  |

Definition at line 14 of file includer.cc.

17 : working_directory_(std::move(working_directory)),
18 include_dirs_(std::move(include_dirs)),
19 on_file_included_(std::move(on_file_included)) {}

## ◆ ~Includer()

impeller::compiler::Includer::~Includer | ( |  | ) |
| override default

## Member Function Documentation

## ◆ GetInclude()

shaderc_include_result * impeller::compiler::Includer::GetInclude | ( | const char * | requested_source,
|  | shaderc_include_type | type,
|  | const char * | requesting_source,
|  | size_t | include_depth
| ) |  |
| override

Definition at line 71 of file includer.cc.

74 {
75 auto result = std::make_unique<shaderc_include_result>();
76
77 // Default initialize to failed inclusion.
78 result->source_name = "";
79 result->source_name_length = 0;
80
81 constexpr const char* kFileNotFoundMessage = "Included file not found.";
82 result->content = kFileNotFoundMessage;
83 result->content_length = ::strlen(kFileNotFoundMessage);
84 result->user_data = nullptr;
85
86 if (!working_directory_ || !working_directory_->is_valid()) {
87 return result.release();
88 }
89
90 if (requested_source == nullptr) {
91 return result.release();
92 }
93
94 auto file = FindFirstMapping(requested_source);
95
96 if (!file || file->GetMapping() == nullptr) {
97 return result.release();
98 }
99
100 auto includer_data =
101 std::make_unique<IncluderData>(requested_source, std::move(file));
102
103 result->source_name = includer_data->file_name.c_str();
104 result->source_name_length = includer_data->file_name.length();
105 result->content = reinterpret_cast<decltype(result->content)>(
106 includer_data->mapping->GetMapping());
107 result->content_length = includer_data->mapping->GetSize();
108 result->user_data = includer_data.release();
109
110 return result.release();
111 }

## ◆ ReleaseInclude()

void impeller::compiler::Includer::ReleaseInclude | ( | shaderc_include_result * | data | ) |
| override

Definition at line 113 of file includer.cc.

113 {
114 delete reinterpret_cast<IncluderData*>(data->user_data);
115 delete data;
116 }
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:64

References data.

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

- impeller/compiler/includer.h
- impeller/compiler/includer.cc