Flutter Engine
The Flutter Engine
RuntimeEffectDictionary.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_RuntimeEffectDictionary_DEFINED
9#define skgpu_graphite_RuntimeEffectDictionary_DEFINED
10
13#include "src/core/SkTHash.h"
14
15class SkRuntimeEffect;
16
17namespace skgpu::graphite {
18
19// We keep track of all SkRuntimeEffects that are used by a recording, along with their code
20// snippet ID. This ensures that we have a live reference to every effect that we're going to
21// paint, and gives us a way to retrieve their shader text when we see their code-snippet ID.
23public:
24 const SkRuntimeEffect* find(int codeSnippetID) const {
25 sk_sp<const SkRuntimeEffect>* effect = fDict.find(codeSnippetID);
26 return effect ? effect->get() : nullptr;
27 }
28
29 void set(int codeSnippetID, sk_sp<const SkRuntimeEffect> effect);
30
31 void reset() { fDict.reset(); }
32
33private:
35};
36
37} // namespace skgpu::graphite
38
39#endif // skgpu_graphite_RuntimeEffectDictionary_DEFINED
void set(int codeSnippetID, sk_sp< const SkRuntimeEffect > effect)
const SkRuntimeEffect * find(int codeSnippetID) const
V * find(const K &key) const
Definition: SkTHash.h:494