| Flutter Impeller |

includer.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_INCLUDER_H_
6 #define FLUTTER_IMPELLER_COMPILER_INCLUDER_H_
7
8 #include <string>
9
10 #include "flutter/fml/mapping.h"
11 #include "impeller/compiler/include_dir.h"
12 #include "shaderc/shaderc.hpp"
13
14 namespace impeller {
15 namespace compiler {
16
17 struct IncluderData {
18 std::string file_name;
19 std::unique_ptr<fml::Mapping> mapping;
20
21 IncluderData(std::string p_file_name, std::unique_ptr<fml::Mapping> p_mapping)
22 : file_name(std::move(p_file_name)), mapping(std::move(p_mapping)) {}
23 };
24
25 class Includer final : public shaderc::CompileOptions::IncluderInterface {
26 public:
27 Includer(std::shared_ptr<fml::UniqueFD> working_directory,
28 std::vector<IncludeDir> include_dirs,
29 std::function<void(std::string)> on_file_included);
30
31 // |shaderc::CompileOptions::IncluderInterface|
32 ~Includer() override;
33
34 // |shaderc::CompileOptions::IncluderInterface|
35 shaderc_include_result* GetInclude(const char* requested_source,
36 shaderc_include_type type,
37 const char* requesting_source,
38 size_t include_depth) override;
39
40 // |shaderc::CompileOptions::IncluderInterface|
41 void ReleaseInclude(shaderc_include_result* data) override;
42
43 private:
44 std::shared_ptr<fml::UniqueFD> working_directory_;
45 std::vector<IncludeDir> include_dirs_;
46 std::function<void(std::string)> on_file_included_;
47
48 std::unique_ptr<fml::FileMapping> TryOpenMapping(
49 const IncludeDir& dir,
50 const char* requested_source);
51
52 std::unique_ptr<fml::FileMapping> FindFirstMapping(
53 const char* requested_source);
54
55 Includer(const Includer&) = delete;
56
57 Includer& operator=(const Includer&) = delete;
58 };
59
60 } // namespace compiler
61 } // namespace impeller
62
63 #endif // FLUTTER_IMPELLER_COMPILER_INCLUDER_H_
type
GLenum type
Definition: blit_command_gles.cc:153
impeller::compiler::Includer
Definition: includer.h:25
impeller::compiler::Includer::~Includer
~Includer() override
impeller::compiler::Includer::Includer
Includer(std::shared_ptr< fml::UniqueFD > working_directory, std::vector< IncludeDir > include_dirs, std::function< void(std::string)> on_file_included)
Definition: includer.cc:14
impeller::compiler::Includer::ReleaseInclude
void ReleaseInclude(shaderc_include_result *data) override
Definition: includer.cc:113
impeller::compiler::Includer::GetInclude
shaderc_include_result * GetInclude(const char *requested_source, shaderc_include_type type, const char *requesting_source, size_t include_depth) override
Definition: includer.cc:71
include_dir.h
impeller
Definition: allocation.cc:12
std
Definition: comparable.h:95
impeller::compiler::IncludeDir
Definition: include_dir.h:16
impeller::compiler::IncluderData
Definition: includer.h:17
impeller::compiler::IncluderData::mapping
std::unique_ptr< fml::Mapping > mapping
Definition: includer.h:19
impeller::compiler::IncluderData::IncluderData
IncluderData(std::string p_file_name, std::unique_ptr< fml::Mapping > p_mapping)
Definition: includer.h:21
impeller::compiler::IncluderData::file_name
std::string file_name
Definition: includer.h:18
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69