GrGSCoverageProcessor.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2019 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 GrGSCoverageProcessor_DEFINED
  8. #define GrGSCoverageProcessor_DEFINED
  9. #include "src/gpu/ccpr/GrCCCoverageProcessor.h"
  10. /**
  11. * This class implements GrCCCoverageProcessor with analytic coverage using geometry shaders.
  12. */
  13. class GrGSCoverageProcessor : public GrCCCoverageProcessor {
  14. public:
  15. GrGSCoverageProcessor() : GrCCCoverageProcessor(kGrGSCoverageProcessor_ClassID) {
  16. this->setWillUseGeoShader();
  17. }
  18. private:
  19. void reset(PrimitiveType, GrResourceProvider*) override;
  20. void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
  21. SkDEBUGCODE(this->getDebugBloatKey(b));
  22. b->add32(((int)fPrimitiveType << 16) | (int)fSubpass);
  23. }
  24. void appendMesh(sk_sp<const GrGpuBuffer> instanceBuffer, int instanceCount, int baseInstance,
  25. SkTArray<GrMesh>* out) const override;
  26. void draw(GrOpFlushState*, const GrPipeline&, const SkIRect scissorRects[], const GrMesh[],
  27. int meshCount, const SkRect& drawBounds) const override;
  28. GrGLSLPrimitiveProcessor* onCreateGLSLInstance(std::unique_ptr<Shader>) const override;
  29. // The geometry shader impl draws primitives in two subpasses. The first pass fills the interior
  30. // and does edge AA. The second pass does touch up on corner pixels.
  31. enum class Subpass : bool {
  32. kHulls,
  33. kCorners
  34. };
  35. Attribute fInputXOrYValues;
  36. mutable Subpass fSubpass = Subpass::kHulls;
  37. class Impl;
  38. class TriangleHullImpl;
  39. class CurveHullImpl;
  40. class CornerImpl;
  41. };
  42. #endif