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