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_PrecompileBasePriv_DEFINED 9 #define skgpu_graphite_PrecompileBasePriv_DEFINED 10 11 #include "src/gpu/graphite/Precompile.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: isALocalMatrixShader()20 bool isALocalMatrixShader() const { 21 return fPrecompileBase->isALocalMatrixShader(); 22 } 23 addToKey(const KeyContext & keyContext,int desiredCombination,PaintParamsKeyBuilder * builder)24 void addToKey(const KeyContext& keyContext, 25 int desiredCombination, 26 PaintParamsKeyBuilder* builder) const { 27 fPrecompileBase->addToKey(keyContext, desiredCombination, builder); 28 } 29 30 private: 31 friend class PrecompileBase; // to construct/copy this type. 32 PrecompileBasePriv(PrecompileBase * precompileBase)33 explicit PrecompileBasePriv(PrecompileBase* precompileBase) 34 : fPrecompileBase(precompileBase) { 35 } 36 37 PrecompileBasePriv& operator=(const PrecompileBasePriv&) = delete; 38 39 // No taking addresses of this type. 40 const PrecompileBasePriv* operator&() const; 41 PrecompileBasePriv *operator&(); 42 43 PrecompileBase* fPrecompileBase; 44 }; 45 priv()46inline PrecompileBasePriv PrecompileBase::priv() { return PrecompileBasePriv(this); } 47 48 // NOLINTNEXTLINE(readability-const-return-type) priv()49inline const PrecompileBasePriv PrecompileBase::priv() const { 50 return PrecompileBasePriv(const_cast<PrecompileBase *>(this)); 51 } 52 53 } // namespace skgpu::graphite 54 55 #endif // skgpu_graphite_PrecompileBasePriv_DEFINED 56