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_precompile_PaintOption_DEFINED 9 #define skgpu_graphite_precompile_PaintOption_DEFINED 10 11 #include "include/core/SkColorType.h" 12 #include "include/core/SkRefCnt.h" 13 #include "src/gpu/graphite/Caps.h" 14 15 namespace skgpu::graphite { 16 17 class PrecompileBlender; 18 class PrecompileColorFilter; 19 class PrecompileShader; 20 21 class KeyContext; 22 class PaintParamsKeyBuilder; 23 class PipelineDataGatherer; 24 25 class PaintOption { 26 public: PaintOption(bool opaquePaintColor,const std::pair<sk_sp<PrecompileBlender>,int> & finalBlender,const std::pair<sk_sp<PrecompileShader>,int> & shader,const std::pair<sk_sp<PrecompileColorFilter>,int> & colorFilter,bool hasPrimitiveBlender,const std::pair<sk_sp<PrecompileShader>,int> & clipShader,DstReadRequirement dstReadReq,bool dither)27 PaintOption(bool opaquePaintColor, 28 const std::pair<sk_sp<PrecompileBlender>, int>& finalBlender, 29 const std::pair<sk_sp<PrecompileShader>, int>& shader, 30 const std::pair<sk_sp<PrecompileColorFilter>, int>& colorFilter, 31 bool hasPrimitiveBlender, 32 const std::pair<sk_sp<PrecompileShader>, int>& clipShader, 33 DstReadRequirement dstReadReq, 34 bool dither) 35 : fOpaquePaintColor(opaquePaintColor) 36 , fFinalBlender(finalBlender) 37 , fShader(shader) 38 , fColorFilter(colorFilter) 39 , fHasPrimitiveBlender(hasPrimitiveBlender) 40 , fClipShader(clipShader) 41 , fDstReadReq(dstReadReq) 42 , fDither(dither) { 43 } 44 finalBlender()45 const PrecompileBlender* finalBlender() const { return fFinalBlender.first.get(); } 46 47 void toKey(const KeyContext&, PaintParamsKeyBuilder*, PipelineDataGatherer*) const; 48 49 private: 50 void addPaintColorToKey(const KeyContext&, PaintParamsKeyBuilder*, PipelineDataGatherer*) const; 51 void handlePrimitiveColor(const KeyContext&, 52 PaintParamsKeyBuilder*, 53 PipelineDataGatherer*) const; 54 void handlePaintAlpha(const KeyContext&, PaintParamsKeyBuilder*, PipelineDataGatherer*) const; 55 void handleColorFilter(const KeyContext&, PaintParamsKeyBuilder*, PipelineDataGatherer*) const; 56 bool shouldDither(SkColorType dstCT) const; 57 void handleDithering(const KeyContext&, PaintParamsKeyBuilder*, PipelineDataGatherer*) const; 58 59 bool fOpaquePaintColor; 60 std::pair<sk_sp<PrecompileBlender>, int> fFinalBlender; 61 std::pair<sk_sp<PrecompileShader>, int> fShader; 62 std::pair<sk_sp<PrecompileColorFilter>, int> fColorFilter; 63 bool fHasPrimitiveBlender; 64 std::pair<sk_sp<PrecompileShader>, int> fClipShader; 65 DstReadRequirement fDstReadReq; 66 bool fDither; 67 }; 68 69 } // namespace skgpu::graphite 70 71 #endif // skgpu_graphite_precompile_PaintOption_DEFINED 72