Flutter Engine
The Flutter Engine
shader_archive.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_SHADER_ARCHIVE_SHADER_ARCHIVE_H_
6#define FLUTTER_IMPELLER_SHADER_ARCHIVE_SHADER_ARCHIVE_H_
7
8#include <memory>
9#include <type_traits>
10#include <unordered_map>
11
12#include "flutter/fml/hash_combine.h"
13#include "flutter/fml/mapping.h"
15
16namespace impeller {
17
19 public:
20 explicit ShaderArchive(std::shared_ptr<fml::Mapping> payload);
21
23
25
26 bool IsValid() const;
27
28 size_t GetShaderCount() const;
29
30 std::shared_ptr<fml::Mapping> GetMapping(ArchiveShaderType type,
31 std::string name) const;
32
33 size_t IterateAllShaders(
35 const std::string& name,
36 const std::shared_ptr<fml::Mapping>& mapping)>&)
37 const;
38
39 private:
40 struct ShaderKey {
42 std::string name;
43
44 struct Hash {
45 size_t operator()(const ShaderKey& key) const {
46 return fml::HashCombine(
47 static_cast<std::underlying_type_t<decltype(key.type)>>(key.type),
48 key.name);
49 }
50 };
51
52 struct Equal {
53 bool operator()(const ShaderKey& lhs, const ShaderKey& rhs) const {
54 return lhs.type == rhs.type && lhs.name == rhs.name;
55 }
56 };
57 };
58
59 using Shaders = std::unordered_map<ShaderKey,
60 std::shared_ptr<fml::Mapping>,
63
64 std::shared_ptr<fml::Mapping> payload_;
65 Shaders shaders_;
66 bool is_valid_ = false;
67
68 ShaderArchive(const ShaderArchive&) = delete;
69
70 ShaderArchive& operator=(const ShaderArchive&) = delete;
71};
72
73} // namespace impeller
74
75#endif // FLUTTER_IMPELLER_SHADER_ARCHIVE_SHADER_ARCHIVE_H_
GLenum type
ShaderArchive(ShaderArchive &&)
size_t IterateAllShaders(const std::function< bool(ArchiveShaderType type, const std::string &name, const std::shared_ptr< fml::Mapping > &mapping)> &) const
ShaderArchive(std::shared_ptr< fml::Mapping > payload)
size_t GetShaderCount() const
std::shared_ptr< fml::Mapping > GetMapping(ArchiveShaderType type, std::string name) const
Dart_NativeFunction function
Definition: fuchsia.cc:51
static uint32_t Hash(uint32_t key)
Definition: hashmap_test.cc:65
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
constexpr std::size_t HashCombine()
Definition: hash_combine.h:25
bool operator()(const ShaderKey &lhs, const ShaderKey &rhs) const
size_t operator()(const ShaderKey &key) const