blob: 5c9255903152a6f0bd72019aa976709791fcb57e [file] [log] [blame]
egdanielc2304142014-12-11 13:15:13 -08001/*
2 * Copyright 2014 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 GrGLXferProcessor_DEFINED
9#define GrGLXferProcessor_DEFINED
10
11#include "GrGLProcessor.h"
12
13class GrGLXPBuilder;
14
15class GrGLXferProcessor {
16public:
17 GrGLXferProcessor() {}
18 virtual ~GrGLXferProcessor() {}
19
20 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
21 struct EmitArgs {
22 EmitArgs(GrGLXPBuilder* pb,
23 const GrXferProcessor& xp,
24 const char* inputColor,
25 const char* inputCoverage,
26 const char* outputPrimary,
27 const char* outputSecondary,
28 const TextureSamplerArray& samplers)
29 : fPB(pb)
30 , fXP(xp)
31 , fInputColor(inputColor)
32 , fInputCoverage(inputCoverage)
33 , fOutputPrimary(outputPrimary)
34 , fOutputSecondary(outputSecondary)
35 , fSamplers(samplers) {}
36
37 GrGLXPBuilder* fPB;
38 const GrXferProcessor& fXP;
39 const char* fInputColor;
40 const char* fInputCoverage;
41 const char* fOutputPrimary;
42 const char* fOutputSecondary;
43 const TextureSamplerArray& fSamplers;
44 };
45 /**
46 * This is similar to emitCode() in the base class, except it takes a full shader builder.
47 * This allows the effect subclass to emit vertex code.
48 */
49 virtual void emitCode(const EmitArgs&) = 0;
50
51 /** A GrGLXferProcessor instance can be reused with any GrGLXferProcessor that produces
52 the same stage key; this function reads data from a GrGLXferProcessor and uploads any
53 uniform variables required by the shaders created in emitCode(). The GrXferProcessor
54 parameter is guaranteed to be of the same type that created this GrGLXferProcessor and
55 to have an identical processor key as the one that created this GrGLXferProcessor. */
56 virtual void setData(const GrGLProgramDataManager&,
57 const GrXferProcessor&) = 0;
58private:
59 typedef GrGLProcessor INHERITED;
60};
61#endif