GrCCCubicShader.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 GrCCCubicShader_DEFINED
  8. #define GrCCCubicShader_DEFINED
  9. #include "src/gpu/ccpr/GrCCCoverageProcessor.h"
  10. /**
  11. * This class renders the coverage of convex closed cubic segments 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 curve segments must be convex, monotonic with respect to the vector of their closing
  18. * edge [P3 - P0], and must not contain or be near any inflection points or loop intersections.
  19. * (Use GrCCGeometry::cubicTo().)
  20. */
  21. class GrCCCubicShader : public GrCCCoverageProcessor::Shader {
  22. public:
  23. void emitSetupCode(
  24. GrGLSLVertexGeoBuilder*, const char* pts, const char** outHull4) const override;
  25. void onEmitVaryings(
  26. GrGLSLVaryingHandler*, GrGLSLVarying::Scope, SkString* code, const char* position,
  27. const char* coverage, const char* cornerCoverage, const char* wind) override;
  28. void emitFragmentCoverageCode(
  29. GrGLSLFPFragmentBuilder*, const char* outputCoverage) const override;
  30. void emitSampleMaskCode(GrGLSLFPFragmentBuilder*) const override;
  31. private:
  32. void calcHullCoverage(SkString* code, const char* klmAndEdge, const char* gradMatrix,
  33. const char* outputCoverage) const;
  34. const GrShaderVar fKLMMatrix{"klm_matrix", kFloat3x3_GrSLType};
  35. GrGLSLVarying fKLM_fEdge;
  36. GrGLSLVarying fGradMatrix;
  37. GrGLSLVarying fCornerCoverage;
  38. };
  39. #endif