| 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_precompile_PrecompileBasePriv_DEFINED |
| 9 |
#define skgpu_graphite_precompile_PrecompileBasePriv_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/graphite/PrecompileInternal.h" |
| 12 |
|
| 13 |
namespace skgpu::graphite { |
| 14 |
|
| 15 |
/** Class that exposes methods to PrecompileBase that are only intended for use internal to Skia. |
| 16 |
This class is purely a privileged window into PrecompileBase. It should never have additional |
| 17 |
data members or virtual methods. */ |
| 18 |
class PrecompileBasePriv { |
| 19 |
public: |
| 20 |
int numChildCombinations() const { |
| 21 |
return fPrecompileBase->numChildCombinations(); |
| 22 |
} |
| 23 |
|
| 24 |
int numCombinations() const { |
| 25 |
return fPrecompileBase->numCombinations(); |
| 26 |
} |
| 27 |
|
| 28 |
void addToKey(const KeyContext& keyContext, int desiredCombination) const { |
| 29 |
fPrecompileBase->addToKey(keyContext, desiredCombination); |
| 30 |
} |
| 31 |
|
| 32 |
private: |
| 33 |
friend class PrecompileBase; // to construct/copy this type. |
| 34 |
|
| 35 |
explicit PrecompileBasePriv(PrecompileBase* precompileBase) |
| 36 |
: fPrecompileBase(precompileBase) { |
| 37 |
} |
| 38 |
|
| 39 |
PrecompileBasePriv& operator=(const PrecompileBasePriv&) = delete; |
| 40 |
|
| 41 |
// No taking addresses of this type. |
| 42 |
const PrecompileBasePriv* operator&() const; |
| 43 |
PrecompileBasePriv *operator&(); |
| 44 |
|
| 45 |
PrecompileBase* fPrecompileBase; |
| 46 |
}; |
| 47 |
|
| 48 |
inline PrecompileBasePriv PrecompileBase::priv() { return PrecompileBasePriv(this); } |
| 49 |
|
| 50 |
// NOLINTNEXTLINE(readability-const-return-type) |
| 51 |
inline const PrecompileBasePriv PrecompileBase::priv() const { |
| 52 |
return PrecompileBasePriv(const_cast<PrecompileBase *>(this)); |
| 53 |
} |
| 54 |
|
| 55 |
} // namespace skgpu::graphite |
| 56 |
|
| 57 |
#endif // skgpu_graphite_precompile_PrecompileBasePriv_DEFINED |