blob: a172904ac68aa1a55240051143c1c785247cb590 [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 */
joshualittb0a8a372014-09-23 09:50:21 -070021class GrGLGeometryProcessor : public GrGLProcessor {
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000022public:
joshualittb0a8a372014-09-23 09:50:21 -070023 GrGLGeometryProcessor(const GrBackendProcessorFactory& factory)
24 : INHERITED(factory) {}
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000025
joshualittc369e7c2014-10-22 10:56:26 -070026 struct EmitArgs {
27 EmitArgs(GrGLGPBuilder* pb,
28 const GrGeometryProcessor& gp,
joshualitt87f48d92014-12-04 10:41:40 -080029 const GrBatchTracker& bt,
joshualitt2dd1ae02014-12-03 06:24:10 -080030 const char* outputColor,
31 const char* outputCoverage,
joshualittc369e7c2014-10-22 10:56:26 -070032 const TextureSamplerArray& samplers)
joshualitt2dd1ae02014-12-03 06:24:10 -080033 : fPB(pb)
34 , fGP(gp)
joshualitt87f48d92014-12-04 10:41:40 -080035 , fBT(bt)
joshualitt2dd1ae02014-12-03 06:24:10 -080036 , fOutputColor(outputColor)
37 , fOutputCoverage(outputCoverage)
38 , fSamplers(samplers) {}
joshualittc369e7c2014-10-22 10:56:26 -070039 GrGLGPBuilder* fPB;
40 const GrGeometryProcessor& fGP;
joshualitt87f48d92014-12-04 10:41:40 -080041 const GrBatchTracker& fBT;
joshualitt2dd1ae02014-12-03 06:24:10 -080042 const char* fOutputColor;
43 const char* fOutputCoverage;
joshualittc369e7c2014-10-22 10:56:26 -070044 const TextureSamplerArray& fSamplers;
45 };
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000046 /**
47 * This is similar to emitCode() in the base class, except it takes a full shader builder.
48 * This allows the effect subclass to emit vertex code.
49 */
joshualittc369e7c2014-10-22 10:56:26 -070050 virtual void emitCode(const EmitArgs&) = 0;
joshualitt30ba4362014-08-21 20:18:45 -070051
joshualitt87f48d92014-12-04 10:41:40 -080052 /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces
53 the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any
54 uniform variables required by the shaders created in emitCode(). The GrGeometryProcessor
55 parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and
56 to have an identical processor key as the one that created this GrGLGeometryProcessor. */
57 virtual void setData(const GrGLProgramDataManager&,
58 const GrGeometryProcessor&,
59 const GrBatchTracker&) = 0;
60
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000061private:
joshualittb0a8a372014-09-23 09:50:21 -070062 typedef GrGLProcessor INHERITED;
commit-bot@chromium.org261dc562013-10-04 15:42:56 +000063};
64
65#endif