Debian Codegraph @

src/gpu/graphite/precompile/PaintOptionsPriv.h

raw
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_PaintOptionsPriv_DEFINED
9 #define skgpu_graphite_PaintOptionsPriv_DEFINED
10
11 #include "include/gpu/graphite/precompile/PaintOptions.h"
12
13 namespace skgpu::graphite {
14
15 class ShaderCodeDictionary;
16
17 /** Class that exposes methods in PaintOptions that are only intended for use internal to Skia.
18 This class is purely a privileged window into PaintOptions. It should never have additional
19 data members or virtual methods. */
20 class PaintOptionsPriv {
21 public:
22 using ProcessCombination = PaintOptions::ProcessCombination;
23
24 void addColorFilter(sk_sp<PrecompileColorFilter> cf);
25
26 void setClipShaders(SkSpan<const sk_sp<PrecompileShader>> clipShaders) {
27 fPaintOptions->setClipShaders(std::move(clipShaders));
28 }
29
30 void setPrimitiveBlendMode(SkBlendMode primitiveBlendMode) {
31 fPaintOptions->setPrimitiveBlendMode(primitiveBlendMode);
32 }
33
34 void setSkipColorXform(bool skipColorXform) {
35 fPaintOptions->setSkipColorXform(skipColorXform);
36 }
37
38 int numCombinations() const {
39 return fPaintOptions->numCombinations();
40 }
41
42 void buildCombinations(
43 const KeyContext& keyContext,
44 DrawTypeFlags drawTypes,
45 bool withPrimitiveBlender,
46 Coverage coverage,
47 const RenderPassDesc& renderPassDesc,
48 const ProcessCombination& processCombination) const {
49 fPaintOptions->buildCombinations(keyContext, drawTypes, withPrimitiveBlender, coverage,
50 renderPassDesc, processCombination);
51 }
52
53 private:
54 friend class PaintOptions; // to construct/copy this type.
55
56 explicit PaintOptionsPriv(PaintOptions* paintOptions) : fPaintOptions(paintOptions) {}
57
58 PaintOptionsPriv& operator=(const PaintOptionsPriv&) = delete;
59
60 // No taking addresses of this type.
61 const PaintOptionsPriv* operator&() const;
62 PaintOptionsPriv *operator&();
63
64 PaintOptions* fPaintOptions;
65 };
66
67 inline PaintOptionsPriv PaintOptions::priv() { return PaintOptionsPriv(this); }
68
69 // NOLINTNEXTLINE(readability-const-return-type)
70 inline const PaintOptionsPriv PaintOptions::priv() const {
71 return PaintOptionsPriv(const_cast<PaintOptions *>(this));
72 }
73
74 } // namespace skgpu::graphite
75
76 #endif // skgpu_graphite_PaintOptionsPriv_DEFINED