Flutter Engine
The Flutter Engine
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"
14
15namespace impeller {
16
17struct ShaderKey {
18 std::string name;
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
37class ShaderFunction;
38
40 std::unordered_map<ShaderKey,
41 std::shared_ptr<const ShaderFunction>,
44
45} // namespace impeller
46
47#endif // FLUTTER_IMPELLER_RENDERER_SHADER_KEY_H_
static uint32_t Hash(uint32_t key)
Definition: hashmap_test.cc:65
constexpr std::size_t HashCombine()
Definition: hash_combine.h:25
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
constexpr bool operator()(const ShaderKey &k1, const ShaderKey &k2) const
Definition: shader_key.h:31
size_t operator()(const ShaderKey &key) const
Definition: shader_key.h:25
ShaderKey(std::string_view p_name, ShaderStage p_stage)
Definition: shader_key.h:21
ShaderStage stage
Definition: shader_key.h:19
std::string name
Definition: shader_key.h:18