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