| Flutter Impeller |

shader_key.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_RENDERER_SHADER_KEY_H_
6 #define FLUTTER_IMPELLER_RENDERER_SHADER_KEY_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11
12 #include "flutter/fml/hash_combine.h"
13 #include "flutter/fml/macros.h"
14 #include "impeller/core/shader_types.h"
15
16 namespace impeller {
17
18 struct ShaderKey {
19 std::string name;
20 ShaderStage stage = ShaderStage::kUnknown;
21
22 ShaderKey(std::string_view p_name, ShaderStage p_stage)
23 : name({p_name.data(), p_name.size()}), stage(p_stage) {}
24
25 struct Hash {
26 size_t operator()(const ShaderKey& key) const {
27 return fml::HashCombine(key.name, key.stage);
28 }
29 };
30
31 struct Equal {
32 constexpr bool operator()(const ShaderKey& k1, const ShaderKey& k2) const {
33 return k1.stage == k2.stage && k1.name == k2.name;
34 }
35 };
36 };
37
38 class ShaderFunction;
39
40 using ShaderFunctionMap =
41 std::unordered_map<ShaderKey,
42 std::shared_ptr<const ShaderFunction>,
43 ShaderKey::Hash,
44 ShaderKey::Equal>;
45
46 } // namespace impeller
47
48 #endif // FLUTTER_IMPELLER_RENDERER_SHADER_KEY_H_
impeller::ShaderKey::Hash
Definition: shader_key.h:25
impeller::ShaderKey::Hash::operator()
size_t operator()(const ShaderKey &key) const
Definition: shader_key.h:26
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::ShaderKey::Equal::operator()
constexpr bool operator()(const ShaderKey &k1, const ShaderKey &k2) const
Definition: shader_key.h:32
impeller::ShaderFunctionMap
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:44
impeller::ShaderKey::ShaderKey
ShaderKey(std::string_view p_name, ShaderStage p_stage)
Definition: shader_key.h:22
impeller::ShaderKey::name
std::string name
Definition: shader_key.h:19
impeller::ShaderKey
Definition: shader_key.h:18
impeller::ShaderKey::Equal
Definition: shader_key.h:31
impeller::ShaderKey::stage
ShaderStage stage
Definition: shader_key.h:20
shader_types.h
impeller
Definition: aiks_context.cc:10