Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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"
15
16namespace impeller {
17
18struct ShaderKey {
19 std::string name;
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
38class ShaderFunction;
39
41 std::unordered_map<ShaderKey,
42 std::shared_ptr<const ShaderFunction>,
45
46} // namespace impeller
47
48#endif // FLUTTER_IMPELLER_RENDERER_SHADER_KEY_H_
constexpr std::size_t HashCombine()
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition shader_key.h:44
constexpr bool operator()(const ShaderKey &k1, const ShaderKey &k2) const
Definition shader_key.h:32
size_t operator()(const ShaderKey &key) const
Definition shader_key.h:26
ShaderKey(std::string_view p_name, ShaderStage p_stage)
Definition shader_key.h:22
ShaderStage stage
Definition shader_key.h:20
std::string name
Definition shader_key.h:19