Flutter Impeller
compiler.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_COMPILER_COMPILER_H_
6 #define FLUTTER_IMPELLER_COMPILER_COMPILER_H_
7 
8 #include <initializer_list>
9 #include <sstream>
10 #include <string>
11 
12 #include "flutter/fml/mapping.h"
18 #include "spirv_msl.hpp"
19 #include "spirv_parser.hpp"
20 #include "third_party/abseil-cpp/absl/status/status.h"
21 
22 namespace impeller {
23 namespace compiler {
24 
25 class Compiler {
26  public:
27  Compiler(const std::shared_ptr<const fml::Mapping>& source_mapping,
28  const SourceOptions& options,
29  Reflector::Options reflector_options);
30 
32 
33  bool IsValid() const;
34 
35  std::shared_ptr<fml::Mapping> GetSPIRVAssembly() const;
36 
37  std::shared_ptr<fml::Mapping> GetSLShaderSource() const;
38 
39  std::string GetErrorMessages() const;
40 
41  /// Gets verbose error messages if available.
42  ///
43  /// This is only populated when GetErrorMessages() returns a truncated error
44  /// message. If GetErrorMessages() did not have to be truncated, this will
45  /// return an empty string.
46  std::string GetVerboseErrorMessages() const;
47 
48  const std::vector<std::string>& GetIncludedFileNames() const;
49 
50  std::unique_ptr<fml::Mapping> CreateDepfileContents(
51  std::initializer_list<std::string> targets) const;
52 
53  const Reflector* GetReflector() const;
54 
55  private:
56  SourceOptions options_;
57  std::shared_ptr<fml::Mapping> spirv_assembly_;
58  std::shared_ptr<fml::Mapping> sl_mapping_;
59  std::stringstream error_stream_;
60  std::stringstream verbose_error_stream_;
61  std::unique_ptr<Reflector> reflector_;
62  std::vector<std::string> included_file_names_;
63  bool is_valid_ = false;
64 
65  std::string GetSourcePrefix() const;
66 
67  std::string GetDependencyNames(const std::string& separator) const;
68 
69  absl::Status ValidateSkSLResult(const std::string& sksl);
70 
71  Compiler(const Compiler&) = delete;
72 
73  Compiler& operator=(const Compiler&) = delete;
74 };
75 
76 } // namespace compiler
77 } // namespace impeller
78 
79 #endif // FLUTTER_IMPELLER_COMPILER_COMPILER_H_
std::string GetVerboseErrorMessages() const
Definition: compiler.cc:572
std::shared_ptr< fml::Mapping > GetSPIRVAssembly() const
Definition: compiler.cc:550
const Reflector * GetReflector() const
Definition: compiler.cc:615
Compiler(const std::shared_ptr< const fml::Mapping > &source_mapping, const SourceOptions &options, Reflector::Options reflector_options)
Definition: compiler.cc:285
const std::vector< std::string > & GetIncludedFileNames() const
Definition: compiler.cc:576
std::unique_ptr< fml::Mapping > CreateDepfileContents(std::initializer_list< std::string > targets) const
Definition: compiler.cc:600
std::shared_ptr< fml::Mapping > GetSLShaderSource() const
Definition: compiler.cc:554
std::string GetErrorMessages() const
Definition: compiler.cc:568