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