Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 8 | #ifndef GrCCQuadraticShader_DEFINED |
| 9 | #define GrCCQuadraticShader_DEFINED |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 10 | |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 11 | #include "ccpr/GrCCCoverageProcessor.h" |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * This class renders the coverage of closed quadratic curves using the techniques outlined in |
| 15 | * "Resolution Independent Curve Rendering using Programmable Graphics Hardware" by Charles Loop and |
| 16 | * Jim Blinn: |
| 17 | * |
| 18 | * https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf |
| 19 | * |
| 20 | * The provided curves must be monotonic with respect to the vector of their closing edge [P2 - P0]. |
Chris Dalton | 21ba551 | 2018-03-21 17:20:21 -0600 | [diff] [blame^] | 21 | * (Use GrCCGeometry::quadraticTo().) |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 22 | */ |
Chris Dalton | 383a2ef | 2018-01-08 17:21:41 -0500 | [diff] [blame] | 23 | class GrCCQuadraticShader : public GrCCCoverageProcessor::Shader { |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 24 | protected: |
Chris Dalton | 21ba551 | 2018-03-21 17:20:21 -0600 | [diff] [blame^] | 25 | void emitSetupCode(GrGLSLVertexGeoBuilder*, const char* pts, const char* wind, |
| 26 | const char** tighterHull) const override; |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 27 | |
Chris Dalton | fe462ef | 2018-03-08 15:54:01 +0000 | [diff] [blame] | 28 | void onEmitVaryings(GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, |
Chris Dalton | 21ba551 | 2018-03-21 17:20:21 -0600 | [diff] [blame^] | 29 | const char* position, const char* coverage, |
| 30 | const char* attenuatedCoverage) override; |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 31 | |
Chris Dalton | 21ba551 | 2018-03-21 17:20:21 -0600 | [diff] [blame^] | 32 | void onEmitFragmentCode(GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override; |
Chris Dalton | f510e26 | 2018-01-30 16:42:37 -0700 | [diff] [blame] | 33 | |
Chris Dalton | 52076d1 | 2018-03-21 12:14:10 -0600 | [diff] [blame] | 34 | const GrShaderVar fQCoordMatrix{"qcoord_matrix", kFloat2x2_GrSLType}; |
| 35 | const GrShaderVar fQCoord0{"qcoord0", kFloat2_GrSLType}; |
Chris Dalton | baf3e78 | 2018-03-08 15:55:58 +0000 | [diff] [blame] | 36 | const GrShaderVar fEdgeDistanceEquation{"edge_distance_equation", kFloat3_GrSLType}; |
Chris Dalton | 21ba551 | 2018-03-21 17:20:21 -0600 | [diff] [blame^] | 37 | GrGLSLVarying fCoord; |
| 38 | GrGLSLVarying fCoverages; |
Chris Dalton | 6a3dbee | 2017-10-16 10:44:41 -0600 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | #endif |