| 1 | /* | 
|---|
| 2 | * Copyright 2018 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 |  | 
|---|
| 8 | #ifndef GrCCConicShader_DEFINED | 
|---|
| 9 | #define GrCCConicShader_DEFINED | 
|---|
| 10 |  | 
|---|
| 11 | #include "src/gpu/ccpr/GrCCCoverageProcessor.h" | 
|---|
| 12 |  | 
|---|
| 13 | /** | 
|---|
| 14 | * This class renders the coverage of closed conic 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]. | 
|---|
| 21 | * (Use GrCCGeometry::conicTo().) | 
|---|
| 22 | */ | 
|---|
| 23 | class GrCCConicShader : public GrCCCoverageProcessor::Shader { | 
|---|
| 24 | public: | 
|---|
| 25 | bool calculatesOwnEdgeCoverage() const override { return true; } | 
|---|
| 26 |  | 
|---|
| 27 | void emitSetupCode( | 
|---|
| 28 | GrGLSLVertexGeoBuilder*, const char* pts, const char** outHull4) const override; | 
|---|
| 29 |  | 
|---|
| 30 | void onEmitVaryings( | 
|---|
| 31 | GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, const char* position, | 
|---|
| 32 | const char* coverage, const char* cornerCoverage, const char* wind) override; | 
|---|
| 33 |  | 
|---|
| 34 | void emitFragmentCoverageCode( | 
|---|
| 35 | GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override; | 
|---|
| 36 |  | 
|---|
| 37 | void emitSampleMaskCode(GrGLSLFPFragmentBuilder*) const override; | 
|---|
| 38 |  | 
|---|
| 39 | private: | 
|---|
| 40 | void calcHullCoverage(SkString* code, const char* klm, const char* grad, | 
|---|
| 41 | const char* outputCoverage) const; | 
|---|
| 42 |  | 
|---|
| 43 | const GrShaderVar fKLMMatrix{ "klm_matrix", kFloat3x3_GrSLType}; | 
|---|
| 44 | const GrShaderVar fControlPoint{ "control_point", kFloat2_GrSLType}; | 
|---|
| 45 | GrGLSLVarying fKLM_fWind; | 
|---|
| 46 | GrGLSLVarying fGrad_fCorner; | 
|---|
| 47 | }; | 
|---|
| 48 |  | 
|---|
| 49 | #endif | 
|---|
| 50 |  | 
|---|