blob: 84b839d2cb8c88745dfe58042a470392385198bc [file] [log] [blame]
egdaniel16a04b82015-01-14 10:49:18 -08001/*
2 * Copyright 2015 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#ifndef SkArithmeticMode_gpu_DEFINED
9#define SkArithmeticMode_gpu_DEFINED
10
11#if SK_SUPPORT_GPU
12
13#include "GrCoordTransform.h"
14#include "GrFragmentProcessor.h"
15#include "GrTextureAccess.h"
16
17class GrInvariantOutput;
18class GrTexture;
19
20///////////////////////////////////////////////////////////////////////////////
21// Fragment Processor
22///////////////////////////////////////////////////////////////////////////////
23
24class GrGLArtithmeticFP;
25
26class GrArithmeticFP : public GrFragmentProcessor {
27public:
28 static GrFragmentProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
29 GrTexture* background) {
30 return SkNEW_ARGS(GrArithmeticFP, (k1, k2, k3, k4, enforcePMColor, background));
31 }
32
33 ~GrArithmeticFP() SK_OVERRIDE {};
34
35 const char* name() const SK_OVERRIDE { return "Arithmetic"; }
36
37 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
38
39 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
40
41 GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture(); }
42
43 float k1() const { return fK1; }
44 float k2() const { return fK2; }
45 float k3() const { return fK3; }
46 float k4() const { return fK4; }
47 bool enforcePMColor() const { return fEnforcePMColor; }
48
49private:
50 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
51
52 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
53
54 GrArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
55 GrTexture* background);
56
57 float fK1, fK2, fK3, fK4;
58 bool fEnforcePMColor;
59 GrCoordTransform fBackgroundTransform;
60 GrTextureAccess fBackgroundAccess;
61
62 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
63 typedef GrFragmentProcessor INHERITED;
64};
65
66#endif
67#endif