1/*
2 * Copyright 2020 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/**************************************************************************************************
9 *** This file was autogenerated from GrDeviceSpaceEffect.fp; do not modify.
10 **************************************************************************************************/
11#include "GrDeviceSpaceEffect.h"
12
13#include "src/gpu/GrTexture.h"
14#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
15#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
16#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
17#include "src/sksl/SkSLCPP.h"
18#include "src/sksl/SkSLUtil.h"
19class GrGLSLDeviceSpaceEffect : public GrGLSLFragmentProcessor {
20public:
21 GrGLSLDeviceSpaceEffect() {}
22 void emitCode(EmitArgs& args) override {
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
24 const GrDeviceSpaceEffect& _outer = args.fFp.cast<GrDeviceSpaceEffect>();
25 (void)_outer;
26 SkString _input204 = SkStringPrintf("%s", args.fInputColor);
27 SkString _sample204;
28 SkString _coords204("sk_FragCoord.xy");
29 _sample204 =
30 this->invokeChild(_outer.fp_index, _input204.c_str(), args, _coords204.c_str());
31 fragBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, _sample204.c_str());
32 }
33
34private:
35 void onSetData(const GrGLSLProgramDataManager& pdman,
36 const GrFragmentProcessor& _proc) override {}
37};
38GrGLSLFragmentProcessor* GrDeviceSpaceEffect::onCreateGLSLInstance() const {
39 return new GrGLSLDeviceSpaceEffect();
40}
41void GrDeviceSpaceEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
42 GrProcessorKeyBuilder* b) const {}
43bool GrDeviceSpaceEffect::onIsEqual(const GrFragmentProcessor& other) const {
44 const GrDeviceSpaceEffect& that = other.cast<GrDeviceSpaceEffect>();
45 (void)that;
46 return true;
47}
48GrDeviceSpaceEffect::GrDeviceSpaceEffect(const GrDeviceSpaceEffect& src)
49 : INHERITED(kGrDeviceSpaceEffect_ClassID, src.optimizationFlags()), fp_index(src.fp_index) {
50 {
51 auto clone = src.childProcessor(fp_index).clone();
52 clone->setSampledWithExplicitCoords(
53 src.childProcessor(fp_index).isSampledWithExplicitCoords());
54 this->registerChildProcessor(std::move(clone));
55 }
56}
57std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::clone() const {
58 return std::unique_ptr<GrFragmentProcessor>(new GrDeviceSpaceEffect(*this));
59}
60GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceEffect);
61#if GR_TEST_UTILS
62std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::TestCreate(GrProcessorTestData* d) {
63 std::unique_ptr<GrFragmentProcessor> fp;
64 // We have a restriction that explicit coords only work for FPs with zero or one
65 // coord transform.
66 do {
67 fp = GrProcessorUnitTest::MakeChildFP(d);
68 } while (fp->numCoordTransforms() > 1);
69 return GrDeviceSpaceEffect::Make(std::move(fp));
70}
71#endif
72