commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 8 | #ifndef GrGLGeometryProcessor_DEFINED |
| 9 | #define GrGLGeometryProcessor_DEFINED |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 10 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 11 | #include "GrGLProcessor.h" |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 12 | |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 13 | class GrBatchTracker; |
joshualitt | a5305a1 | 2014-10-10 17:47:00 -0700 | [diff] [blame] | 14 | class GrGLGPBuilder; |
| 15 | |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 16 | /** |
| 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 | */ |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame^] | 21 | class GrGLGeometryProcessor { |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 22 | public: |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame^] | 23 | GrGLGeometryProcessor() {} |
| 24 | virtual ~GrGLGeometryProcessor() {} |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 25 | |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame^] | 26 | typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; |
joshualitt | c369e7c | 2014-10-22 10:56:26 -0700 | [diff] [blame] | 27 | struct EmitArgs { |
| 28 | EmitArgs(GrGLGPBuilder* pb, |
| 29 | const GrGeometryProcessor& gp, |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 30 | const GrBatchTracker& bt, |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 31 | const char* outputColor, |
| 32 | const char* outputCoverage, |
joshualitt | c369e7c | 2014-10-22 10:56:26 -0700 | [diff] [blame] | 33 | const TextureSamplerArray& samplers) |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 34 | : fPB(pb) |
| 35 | , fGP(gp) |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 36 | , fBT(bt) |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 37 | , fOutputColor(outputColor) |
| 38 | , fOutputCoverage(outputCoverage) |
| 39 | , fSamplers(samplers) {} |
joshualitt | c369e7c | 2014-10-22 10:56:26 -0700 | [diff] [blame] | 40 | GrGLGPBuilder* fPB; |
| 41 | const GrGeometryProcessor& fGP; |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 42 | const GrBatchTracker& fBT; |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 43 | const char* fOutputColor; |
| 44 | const char* fOutputCoverage; |
joshualitt | c369e7c | 2014-10-22 10:56:26 -0700 | [diff] [blame] | 45 | const TextureSamplerArray& fSamplers; |
| 46 | }; |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 47 | /** |
| 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 | */ |
joshualitt | c369e7c | 2014-10-22 10:56:26 -0700 | [diff] [blame] | 51 | virtual void emitCode(const EmitArgs&) = 0; |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 52 | |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 53 | /** 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.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 62 | private: |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 63 | typedef GrGLProcessor INHERITED; |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #endif |