Debian Codegraph @

src/gpu/graphite/precompile/PrecompileImageFilterPriv.h

raw
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_PrecompileImageFilterPriv_DEFINED
9 #define skgpu_graphite_precompile_PrecompileImageFilterPriv_DEFINED
10
11 #include "include/gpu/graphite/precompile/PrecompileImageFilter.h"
12
13 namespace skgpu::graphite {
14
15 /** Class that exposes methods in PrecompileImageFilter that are only intended for use internal to
16 Skia.
17 This class is purely a privileged window into PrecompileImageFilter. It should never have
18 additional data members or virtual methods. */
19 class PrecompileImageFilterPriv {
20 public:
21 sk_sp<PrecompileColorFilter> isColorFilterNode() const {
22 return fPrecompileImageFilter->isColorFilterNode();
23 }
24
25 const PrecompileImageFilter* getInput(int index) const {
26 return fPrecompileImageFilter->getInput(index);
27 }
28
29 private:
30 friend class PrecompileImageFilter; // to construct/copy this type.
31
32 explicit PrecompileImageFilterPriv(PrecompileImageFilter* precompileImageFilter)
33 : fPrecompileImageFilter(precompileImageFilter) {}
34
35 PrecompileImageFilterPriv& operator=(const PrecompileImageFilterPriv&) = delete;
36
37 // No taking addresses of this type.
38 const PrecompileImageFilterPriv* operator&() const;
39 PrecompileImageFilterPriv *operator&();
40
41 PrecompileImageFilter* fPrecompileImageFilter;
42 };
43
44 inline PrecompileImageFilterPriv PrecompileImageFilter::priv() {
45 return PrecompileImageFilterPriv(this);
46 }
47
48 // NOLINTNEXTLINE(readability-const-return-type)
49 inline const PrecompileImageFilterPriv PrecompileImageFilter::priv() const {
50 return PrecompileImageFilterPriv(const_cast<PrecompileImageFilter *>(this));
51 }
52
53 } // namespace skgpu::graphite
54
55 #endif // skgpu_graphite_precompile_PrecompileImageFilterPriv_DEFINED