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 144 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 63 of file reflector.cc.

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

◆ ~Reflector()

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

Member Function Documentation

◆ GetReflectionCC()

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

Definition at line 126 of file reflector.cc.

126  {
127  return reflection_cc_;
128 }

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

◆ GetReflectionHeader()

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

Definition at line 122 of file reflector.cc.

122  {
123  return reflection_header_;
124 }

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

◆ GetReflectionJSON()

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

Definition at line 109 of file reflector.cc.

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

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

◆ GetRuntimeStageShaderData()

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

Definition at line 130 of file reflector.cc.

131  {
132  return runtime_stage_shader_;
133 }

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

◆ GetShaderBundleData()

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

Definition at line 135 of file reflector.cc.

135  {
136  return shader_bundle_data_;
137 }

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

◆ IsValid()

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

Definition at line 105 of file reflector.cc.

105  {
106  return is_valid_;
107 }

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