blob: 2bc4e74f833eef555a9449dcc97fbf3dedf62e87 [file] [log] [blame]
Michael Ludwig4f94ef62018-09-12 15:22:16 -04001/*
2 * Copyright 2018 Google Inc.
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 GrTiledGradientEffect.fp; do not modify.
10 **************************************************************************************************/
11#include "GrTiledGradientEffect.h"
12#include "glsl/GrGLSLFragmentProcessor.h"
13#include "glsl/GrGLSLFragmentShaderBuilder.h"
14#include "glsl/GrGLSLProgramBuilder.h"
15#include "GrTexture.h"
16#include "SkSLCPP.h"
17#include "SkSLUtil.h"
18class GrGLSLTiledGradientEffect : public GrGLSLFragmentProcessor {
19public:
20 GrGLSLTiledGradientEffect() {}
21 void emitCode(EmitArgs& args) override {
22 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
23 const GrTiledGradientEffect& _outer = args.fFp.cast<GrTiledGradientEffect>();
24 (void)_outer;
25 auto mirror = _outer.mirror();
26 (void)mirror;
27 SkString _child1("_child1");
28 this->emitChild(1, &_child1, args);
29 fragBuilder->codeAppendf(
30 "half4 t = %s;\n@if (%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = "
31 "(float(t_1) - 2.0 * floor(float(float(t_1) * 0.5))) - 1.0;\n if "
32 "(sk_Caps.mustDoOpBetweenFloorAndAbs) {\n tiled_t = "
33 "half(clamp(float(tiled_t), -1.0, 1.0));\n }\n t.x = "
34 "half(abs(float(tiled_t)));\n} else {\n t.x = half(fract(float(t.x)));\n}",
35 _child1.c_str(), (_outer.mirror() ? "true" : "false"));
36 SkString _input0("t");
37 SkString _child0("_child0");
38 this->emitChild(0, _input0.c_str(), &_child0, args);
39 fragBuilder->codeAppendf("\n%s = %s;\n", args.fOutputColor, _child0.c_str());
40 }
41
42private:
43 void onSetData(const GrGLSLProgramDataManager& pdman,
44 const GrFragmentProcessor& _proc) override {}
45};
46GrGLSLFragmentProcessor* GrTiledGradientEffect::onCreateGLSLInstance() const {
47 return new GrGLSLTiledGradientEffect();
48}
49void GrTiledGradientEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
50 GrProcessorKeyBuilder* b) const {
51 b->add32((int32_t)fMirror);
52}
53bool GrTiledGradientEffect::onIsEqual(const GrFragmentProcessor& other) const {
54 const GrTiledGradientEffect& that = other.cast<GrTiledGradientEffect>();
55 (void)that;
56 if (fMirror != that.fMirror) return false;
57 return true;
58}
59GrTiledGradientEffect::GrTiledGradientEffect(const GrTiledGradientEffect& src)
60 : INHERITED(kGrTiledGradientEffect_ClassID, src.optimizationFlags()), fMirror(src.fMirror) {
61 this->registerChildProcessor(src.childProcessor(0).clone());
62 this->registerChildProcessor(src.childProcessor(1).clone());
63}
64std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
65 return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
66}