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 "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 void emitSetupCode(GrGLSLVertexGeoBuilder*, const char* pts, const char* wind, 26 const char** outHull4) const override; 27 28 void onEmitVaryings(GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, 29 const char* position, const char* coverage, 30 const char* cornerCoverage) override; 31 32 void onEmitFragmentCode(GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override; 33 34 private: 35 void calcHullCoverage(SkString* code, const char* klm, const char* grad, 36 const char* outputCoverage) const; 37 38 const GrShaderVar fKLMMatrix{"klm_matrix", kFloat3x3_GrSLType}; 39 const GrShaderVar fControlPoint{"control_point", kFloat2_GrSLType}; 40 GrGLSLVarying fKLM_fWind; 41 GrGLSLVarying fGrad_fCorner; 42 }; 43 44 #endif 45