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 8 #ifndef GrCCQuadraticShader_DEFINED 9 #define GrCCQuadraticShader_DEFINED 10 11 #include "src/gpu/ccpr/GrCCCoverageProcessor.h" 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]. 21 * (Use GrCCGeometry::quadraticTo().) 22 */ 23 class GrCCQuadraticShader : public GrCCCoverageProcessor::Shader { 24 public: 25 void emitSetupCode( 26 GrGLSLVertexGeoBuilder*, const char* pts, const char** outHull4) const override; 27 28 void onEmitVaryings( 29 GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, const char* position, 30 const char* coverage, const char* cornerCoverage, const char* wind) override; 31 32 void emitFragmentCoverageCode( 33 GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override; 34 35 void emitSampleMaskCode(GrGLSLFPFragmentBuilder*) const override; 36 37 private: 38 void calcHullCoverage(SkString* code, const char* coordAndGrad, const char* d, 39 const char* outputCoverage) const; 40 41 const GrShaderVar fQCoordMatrix{"qcoord_matrix", kFloat2x2_GrSLType}; 42 const GrShaderVar fQCoord0{"qcoord0", kFloat2_GrSLType}; 43 GrGLSLVarying fCoord_fGrad; 44 GrGLSLVarying fEdge_fWind_fCorner; 45 }; 46 47 #endif 48