Flutter Impeller
impeller::compiler::Reflector Class Reference

#include <reflector.h>

Classes

struct  Options
 

Public Member Functions

 Reflector (Options options, const std::shared_ptr< const spirv_cross::ParsedIR > &ir, const std::shared_ptr< fml::Mapping > &shader_data, const CompilerBackend &compiler)
 
 ~Reflector ()
 
bool IsValid () const
 
std::shared_ptr< fml::Mapping > GetReflectionJSON () const
 
std::shared_ptr< fml::Mapping > GetReflectionHeader () const
 
std::shared_ptr< fml::Mapping > GetReflectionCC () const
 
std::shared_ptr< RuntimeStageData::ShaderGetRuntimeStageShaderData () const
 
std::shared_ptr< ShaderBundleDataGetShaderBundleData () const
 

Detailed Description

Definition at line 160 of file reflector.h.

Constructor & Destructor Documentation

◆ Reflector()

impeller::compiler::Reflector::Reflector ( Options  options,
const std::shared_ptr< const spirv_cross::ParsedIR > &  ir,
const std::shared_ptr< fml::Mapping > &  shader_data,
const CompilerBackend compiler 
)

Definition at line 64 of file reflector.cc.

68  : options_(std::move(options)),
69  ir_(ir),
70  shader_data_(shader_data),
71  compiler_(compiler) {
72  if (!ir_ || !compiler_) {
73  return;
74  }
75 
76  if (auto template_arguments = GenerateTemplateArguments();
77  template_arguments.has_value()) {
78  template_arguments_ =
79  std::make_unique<nlohmann::json>(std::move(template_arguments.value()));
80  } else {
81  return;
82  }
83 
84  reflection_header_ = GenerateReflectionHeader();
85  if (!reflection_header_) {
86  return;
87  }
88 
89  reflection_cc_ = GenerateReflectionCC();
90  if (!reflection_cc_) {
91  return;
92  }
93 
94  runtime_stage_shader_ = GenerateRuntimeStageData();
95 
96  shader_bundle_data_ = GenerateShaderBundleData();
97  if (!shader_bundle_data_) {
98  return;
99  }
100 
101  is_valid_ = true;
102 }

◆ ~Reflector()

impeller::compiler::Reflector::~Reflector ( )
default

Member Function Documentation

◆ GetReflectionCC()

std::shared_ptr< fml::Mapping > impeller::compiler::Reflector::GetReflectionCC ( ) const

Definition at line 127 of file reflector.cc.

127  {
128  return reflection_cc_;
129 }

Referenced by impeller::compiler::OutputReflectionData().

◆ GetReflectionHeader()

std::shared_ptr< fml::Mapping > impeller::compiler::Reflector::GetReflectionHeader ( ) const

Definition at line 123 of file reflector.cc.

123  {
124  return reflection_header_;
125 }

Referenced by impeller::compiler::OutputReflectionData().

◆ GetReflectionJSON()

std::shared_ptr< fml::Mapping > impeller::compiler::Reflector::GetReflectionJSON ( ) const

Definition at line 110 of file reflector.cc.

110  {
111  if (!is_valid_) {
112  return nullptr;
113  }
114 
115  auto json_string =
116  std::make_shared<std::string>(template_arguments_->dump(2u));
117 
118  return std::make_shared<fml::NonOwnedMapping>(
119  reinterpret_cast<const uint8_t*>(json_string->data()),
120  json_string->size(), [json_string](auto, auto) {});
121 }

Referenced by impeller::compiler::OutputReflectionData().

◆ GetRuntimeStageShaderData()

std::shared_ptr< RuntimeStageData::Shader > impeller::compiler::Reflector::GetRuntimeStageShaderData ( ) const

Definition at line 131 of file reflector.cc.

132  {
133  return runtime_stage_shader_;
134 }

Referenced by impeller::compiler::CompileSkSL(), and impeller::compiler::OutputIPLR().

◆ GetShaderBundleData()

std::shared_ptr< ShaderBundleData > impeller::compiler::Reflector::GetShaderBundleData ( ) const

Definition at line 136 of file reflector.cc.

136  {
137  return shader_bundle_data_;
138 }

Referenced by impeller::compiler::GenerateShaderBackendFB().

◆ IsValid()

bool impeller::compiler::Reflector::IsValid ( ) const

Definition at line 106 of file reflector.cc.

106  {
107  return is_valid_;
108 }

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