GrCCQuadraticShader.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef GrCCQuadraticShader_DEFINED
  8. #define GrCCQuadraticShader_DEFINED
  9. #include "src/gpu/ccpr/GrCCCoverageProcessor.h"
  10. /**
  11. * This class renders the coverage of closed quadratic curves using the techniques outlined in
  12. * "Resolution Independent Curve Rendering using Programmable Graphics Hardware" by Charles Loop and
  13. * Jim Blinn:
  14. *
  15. * https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf
  16. *
  17. * The provided curves must be monotonic with respect to the vector of their closing edge [P2 - P0].
  18. * (Use GrCCGeometry::quadraticTo().)
  19. */
  20. class GrCCQuadraticShader : public GrCCCoverageProcessor::Shader {
  21. public:
  22. void emitSetupCode(
  23. GrGLSLVertexGeoBuilder*, const char* pts, const char** outHull4) const override;
  24. void onEmitVaryings(
  25. GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, const char* position,
  26. const char* coverage, const char* cornerCoverage, const char* wind) override;
  27. void emitFragmentCoverageCode(
  28. GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override;
  29. void emitSampleMaskCode(GrGLSLFPFragmentBuilder*) const override;
  30. private:
  31. void calcHullCoverage(SkString* code, const char* coordAndGrad, const char* d,
  32. const char* outputCoverage) const;
  33. const GrShaderVar fQCoordMatrix{"qcoord_matrix", kFloat2x2_GrSLType};
  34. const GrShaderVar fQCoord0{"qcoord0", kFloat2_GrSLType};
  35. GrGLSLVarying fCoord_fGrad;
  36. GrGLSLVarying fEdge_fWind_fCorner;
  37. };
  38. #endif