Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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"
12#include "shaderc/shaderc.hpp"
13
14namespace impeller {
15namespace compiler {
16
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
25class 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_
void ReleaseInclude(shaderc_include_result *data) override
Definition includer.cc:113
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
Definition ref_ptr.h:256
std::unique_ptr< fml::Mapping > mapping
Definition includer.h:19
IncluderData(std::string p_file_name, std::unique_ptr< fml::Mapping > p_mapping)
Definition includer.h:21