aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLXferProcessor.h
blob: 7f60f32fe578a6a5591f14a47cf00de8752eb6f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrGLXferProcessor_DEFINED
#define GrGLXferProcessor_DEFINED

#include "GrGLProcessor.h"

class GrGLXPBuilder;
class GrXferProcessor;

class GrGLXferProcessor {
public:
    GrGLXferProcessor() {}
    virtual ~GrGLXferProcessor() {}

    typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
    struct EmitArgs {
        EmitArgs(GrGLXPBuilder* pb,
                 const GrXferProcessor& xp,
                 const char* inputColor,
                 const char* inputCoverage,
                 const char* outputPrimary,
                 const char* outputSecondary,
                 const TextureSamplerArray& samplers)
            : fPB(pb)
            , fXP(xp)
            , fInputColor(inputColor)
            , fInputCoverage(inputCoverage)
            , fOutputPrimary(outputPrimary)
            , fOutputSecondary(outputSecondary)
            , fSamplers(samplers) {}

        GrGLXPBuilder* fPB;
        const GrXferProcessor& fXP;
        const char* fInputColor;
        const char* fInputCoverage;
        const char* fOutputPrimary;
        const char* fOutputSecondary;
        const TextureSamplerArray& fSamplers;
    };
    /**
     * This is similar to emitCode() in the base class, except it takes a full shader builder.
     * This allows the effect subclass to emit vertex code.
     */
    void emitCode(const EmitArgs&);

    /** A GrGLXferProcessor instance can be reused with any GrGLXferProcessor that produces
        the same stage key; this function reads data from a GrGLXferProcessor and uploads any
        uniform variables required  by the shaders created in emitCode(). The GrXferProcessor
        parameter is guaranteed to be of the same type that created this GrGLXferProcessor and
        to have an identical processor key as the one that created this GrGLXferProcessor. This
        function calls onSetData on the subclass of GrGLXferProcessor
     */
    void setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp);

private:
    virtual void onEmitCode(const EmitArgs&) = 0;

    virtual void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) = 0;

    GrGLProgramDataManager::UniformHandle fDstCopyTopLeftUni;
    GrGLProgramDataManager::UniformHandle fDstCopyScaleUni;

    typedef GrGLProcessor INHERITED;
};
#endif