blob: aa58cd3d97aa16b5a55a8f76f231f67bc09524c9 [file] [log] [blame]
commit-bot@chromium.org261dc562013-10-04 15:42:56 +00001/*
2 * Copyright 2013 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
joshualitt249af152014-09-15 11:41:13 -07008#ifndef GrGLGeometryProcessor_DEFINED
9#define GrGLGeometryProcessor_DEFINED
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000010
joshualittb0a8a372014-09-23 09:50:21 -070011#include "GrGLProcessor.h"
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000012
joshualitt87f48d92014-12-04 10:41:40 -080013class GrBatchTracker;
joshualitta5305a12014-10-10 17:47:00 -070014class GrGLGPBuilder;
15
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000016/**
17 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
18 * from this class. Since paths don't have vertices, this class is only meant to be used internally
19 * by skia, for special cases.
20 */
joshualitteb2a6762014-12-04 11:35:33 -080021class GrGLGeometryProcessor {
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000022public:
joshualitteb2a6762014-12-04 11:35:33 -080023 GrGLGeometryProcessor() {}
24 virtual ~GrGLGeometryProcessor() {}
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000025
joshualitteb2a6762014-12-04 11:35:33 -080026 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
joshualittc369e7c2014-10-22 10:56:26 -070027 struct EmitArgs {
28 EmitArgs(GrGLGPBuilder* pb,
29 const GrGeometryProcessor& gp,
joshualitt87f48d92014-12-04 10:41:40 -080030 const GrBatchTracker& bt,
joshualitt2dd1ae02014-12-03 06:24:10 -080031 const char* outputColor,
32 const char* outputCoverage,
joshualittc369e7c2014-10-22 10:56:26 -070033 const TextureSamplerArray& samplers)
joshualitt2dd1ae02014-12-03 06:24:10 -080034 : fPB(pb)
35 , fGP(gp)
joshualitt87f48d92014-12-04 10:41:40 -080036 , fBT(bt)
joshualitt2dd1ae02014-12-03 06:24:10 -080037 , fOutputColor(outputColor)
38 , fOutputCoverage(outputCoverage)
39 , fSamplers(samplers) {}
joshualittc369e7c2014-10-22 10:56:26 -070040 GrGLGPBuilder* fPB;
41 const GrGeometryProcessor& fGP;
joshualitt87f48d92014-12-04 10:41:40 -080042 const GrBatchTracker& fBT;
joshualitt2dd1ae02014-12-03 06:24:10 -080043 const char* fOutputColor;
44 const char* fOutputCoverage;
joshualittc369e7c2014-10-22 10:56:26 -070045 const TextureSamplerArray& fSamplers;
46 };
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000047 /**
48 * This is similar to emitCode() in the base class, except it takes a full shader builder.
49 * This allows the effect subclass to emit vertex code.
50 */
joshualittc369e7c2014-10-22 10:56:26 -070051 virtual void emitCode(const EmitArgs&) = 0;
joshualitt30ba4362014-08-21 20:18:45 -070052
joshualitt87f48d92014-12-04 10:41:40 -080053 /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces
54 the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any
55 uniform variables required by the shaders created in emitCode(). The GrGeometryProcessor
56 parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and
57 to have an identical processor key as the one that created this GrGLGeometryProcessor. */
58 virtual void setData(const GrGLProgramDataManager&,
59 const GrGeometryProcessor&,
60 const GrBatchTracker&) = 0;
61
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000062private:
joshualittb0a8a372014-09-23 09:50:21 -070063 typedef GrGLProcessor INHERITED;
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000064};
65
66#endif