GrDrawPathOp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2015 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 GrDrawPathOp_DEFINED
  8. #define GrDrawPathOp_DEFINED
  9. #include "src/gpu/GrOpFlushState.h"
  10. #include "src/gpu/GrPath.h"
  11. #include "src/gpu/GrPathProcessor.h"
  12. #include "src/gpu/GrPathRendering.h"
  13. #include "src/gpu/GrProcessorSet.h"
  14. #include "src/gpu/GrStencilSettings.h"
  15. #include "src/gpu/ops/GrDrawOp.h"
  16. class GrPaint;
  17. class GrRecordingContext;
  18. class GrDrawPathOpBase : public GrDrawOp {
  19. protected:
  20. GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrPaint&&,
  21. GrPathRendering::FillType, GrAA);
  22. FixedFunctionFlags fixedFunctionFlags() const override {
  23. return (fDoAA)
  24. ? FixedFunctionFlags::kUsesHWAA | FixedFunctionFlags::kUsesStencil
  25. : FixedFunctionFlags::kUsesStencil;
  26. }
  27. GrProcessorSet::Analysis finalize(
  28. const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
  29. GrClampType clampType) override {
  30. return this->doProcessorAnalysis(caps, clip, hasMixedSampledCoverage, clampType);
  31. }
  32. void visitProxies(const VisitProxyFunc& func) const override {
  33. fProcessorSet.visitProxies(func);
  34. }
  35. protected:
  36. const SkMatrix& viewMatrix() const { return fViewMatrix; }
  37. const SkPMColor4f& color() const { return fInputColor; }
  38. GrPathRendering::FillType fillType() const { return fFillType; }
  39. const GrProcessorSet& processors() const { return fProcessorSet; }
  40. GrProcessorSet detachProcessors() { return std::move(fProcessorSet); }
  41. inline GrPipeline::InitArgs pipelineInitArgs(const GrOpFlushState&);
  42. const GrProcessorSet::Analysis& doProcessorAnalysis(
  43. const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType);
  44. const GrProcessorSet::Analysis& processorAnalysis() const {
  45. SkASSERT(fAnalysis.isInitialized());
  46. return fAnalysis;
  47. }
  48. private:
  49. void onPrepare(GrOpFlushState*) final {}
  50. SkMatrix fViewMatrix;
  51. SkPMColor4f fInputColor;
  52. GrProcessorSet::Analysis fAnalysis;
  53. GrPathRendering::FillType fFillType;
  54. bool fDoAA;
  55. GrProcessorSet fProcessorSet;
  56. typedef GrDrawOp INHERITED;
  57. };
  58. class GrDrawPathOp final : public GrDrawPathOpBase {
  59. public:
  60. DEFINE_OP_CLASS_ID
  61. static std::unique_ptr<GrDrawOp> Make(
  62. GrRecordingContext*, const SkMatrix& viewMatrix, GrPaint&&, GrAA, GrPath*);
  63. const char* name() const override { return "DrawPath"; }
  64. #ifdef SK_DEBUG
  65. SkString dumpInfo() const override;
  66. #endif
  67. private:
  68. friend class GrOpMemoryPool; // for ctor
  69. GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa, const GrPath* path)
  70. : GrDrawPathOpBase(
  71. ClassID(), viewMatrix, std::move(paint), path->getFillType(), aa)
  72. , fPath(path) {
  73. this->setTransformedBounds(path->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
  74. }
  75. void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
  76. GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
  77. typedef GrDrawPathOpBase INHERITED;
  78. };
  79. #endif