1 /* 2 * Copyright 2023 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 GrColorTableEffect_DEFINED 9 #define GrColorTableEffect_DEFINED 10 11 #include "src/gpu/ganesh/GrFragmentProcessor.h" 12 #include "src/gpu/ganesh/GrProcessorUnitTest.h" 13 14 #include <memory> 15 16 class GrRecordingContext; 17 class GrSurfaceProxyView; 18 class SkBitmap; 19 struct GrShaderCaps; 20 21 namespace skgpu { 22 class KeyBuilder; 23 } 24 25 class ColorTableEffect : public GrFragmentProcessor { 26 public: 27 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> inputFP, 28 GrRecordingContext* context, 29 const SkBitmap& bitmap); 30 ~ColorTableEffect()31 ~ColorTableEffect() override {} 32 name()33 const char* name() const override { return "ColorTableEffect"; } 34 clone()35 std::unique_ptr<GrFragmentProcessor> clone() const override { 36 return std::unique_ptr<GrFragmentProcessor>(new ColorTableEffect(*this)); 37 } 38 39 inline static constexpr int kTexEffectFPIndex = 0; 40 inline static constexpr int kInputFPIndex = 1; 41 42 private: 43 std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override; 44 onAddToKey(const GrShaderCaps &,skgpu::KeyBuilder *)45 void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override {} 46 onIsEqual(const GrFragmentProcessor &)47 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 48 49 ColorTableEffect(std::unique_ptr<GrFragmentProcessor> inputFP, GrSurfaceProxyView view); 50 51 explicit ColorTableEffect(const ColorTableEffect& that); 52 53 GR_DECLARE_FRAGMENT_PROCESSOR_TEST 54 }; 55 56 #endif 57