Flutter Engine
The Flutter Engine
PrecompileBase.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 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_precompile_PrecompileBase_DEFINED
9#define skgpu_graphite_precompile_PrecompileBase_DEFINED
10
12#include "include/core/SkSpan.h"
13
14namespace skgpu::graphite {
15
16class KeyContext;
17class PaintParamsKeyBuilder;
18class PipelineDataGatherer;
19class PrecompileBasePriv;
20
21/** \class PrecompileBase
22 This is the base class for all the objects that can be attached to PaintOptions.
23*/
25public:
26 enum class Type {
27 kBlender,
28 kColorFilter,
29 kImageFilter,
30 kMaskFilter,
31 kShader,
32 };
33
34 Type type() const { return fType; }
35
36 // Provides access to functions that aren't part of the public API.
38 const PrecompileBasePriv priv() const; // NOLINT(readability-const-return-type)
39
40protected:
42
43 virtual int numIntrinsicCombinations() const { return 1; }
44 virtual int numChildCombinations() const { return 1; }
45
46 /** This call returns the number of combinations generated from this object and its childen.
47
48 @return number of precompilation combinations generated by this object
49 */
50 int numCombinations() const {
51 return this->numIntrinsicCombinations() * this->numChildCombinations();
52 }
53
54 virtual void addToKey(const KeyContext&,
57 int desiredCombination) const = 0;
58
59 // This returns the desired option along with the child options.
60 template<typename T>
61 static std::pair<sk_sp<T>, int> SelectOption(SkSpan<const sk_sp<T>> options,
62 int desiredOption);
63
64 // In general, derived classes should use AddToKey to select the desired child option from
65 // a span and then have it added to the key with its reduced/nested child option.
66 template<typename T>
67 static void AddToKey(const KeyContext&,
70 SkSpan<const sk_sp<T>> options,
71 int desiredOption);
72
73private:
74 friend class PaintOptions; // for access to SelectOption
75 friend class PrecompileBasePriv;
76
77 Type fType;
78};
79
80} // namespace skgpu::graphite
81
82#endif // skgpu_graphite_precompile_PrecompileBase_DEFINED
const char * options
#define SK_API
Definition: SkAPI.h:35
GLenum type
virtual int numChildCombinations() const
virtual int numIntrinsicCombinations() const
virtual void addToKey(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, int desiredCombination) const =0
FlPixelBufferTexturePrivate * priv
void AddToKey(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlender *blender)