aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGeometryProcessor.h
blob: a172904ac68aa1a55240051143c1c785247cb590 (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
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrGLGeometryProcessor_DEFINED
#define GrGLGeometryProcessor_DEFINED

#include "GrGLProcessor.h"

class GrBatchTracker;
class GrGLGPBuilder;

/**
 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
 * from this class. Since paths don't have vertices, this class is only meant to be used internally
 * by skia, for special cases.
 */
class GrGLGeometryProcessor : public GrGLProcessor {
public:
    GrGLGeometryProcessor(const GrBackendProcessorFactory& factory)
        : INHERITED(factory) {}

    struct EmitArgs {
        EmitArgs(GrGLGPBuilder* pb,
                 const GrGeometryProcessor& gp,
                 const GrBatchTracker& bt,
                 const char* outputColor,
                 const char* outputCoverage,
                 const TextureSamplerArray& samplers)
            : fPB(pb)
            , fGP(gp)
            , fBT(bt)
            , fOutputColor(outputColor)
            , fOutputCoverage(outputCoverage)
            , fSamplers(samplers) {}
        GrGLGPBuilder* fPB;
        const GrGeometryProcessor& fGP;
        const GrBatchTracker& fBT;
        const char* fOutputColor;
        const char* fOutputCoverage;
        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.
     */
    virtual void emitCode(const EmitArgs&) = 0;

    /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces
        the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any
        uniform variables required  by the shaders created in emitCode(). The GrGeometryProcessor
        parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and
        to have an identical processor key as the one that created this GrGLGeometryProcessor.  */
    virtual void setData(const GrGLProgramDataManager&,
                         const GrGeometryProcessor&,
                         const GrBatchTracker&) = 0;

private:
    typedef GrGLProcessor INHERITED;
};

#endif