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