Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 GrCCDrawPathsOp_DEFINED |
| 9 | #define GrCCDrawPathsOp_DEFINED |
| 10 | |
| 11 | #include "SkTInternalLList.h" |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 12 | #include "ccpr/GrCCPathParser.h" |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 13 | #include "ccpr/GrCCPathProcessor.h" |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 14 | #include "ccpr/GrCCSTLList.h" |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 15 | #include "ops/GrDrawOp.h" |
| 16 | |
| 17 | class GrCCAtlas; |
| 18 | class GrCCPerFlushResources; |
Chris Dalton | d7e2227 | 2018-05-23 10:17:17 -0600 | [diff] [blame^] | 19 | struct GrCCPerOpListPaths; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * This is the Op that draws paths to the actual canvas, using atlases generated by CCPR. |
| 23 | */ |
| 24 | class GrCCDrawPathsOp : public GrDrawOp { |
| 25 | public: |
| 26 | DEFINE_OP_CLASS_ID |
| 27 | SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrCCDrawPathsOp); |
| 28 | |
Chris Dalton | d7e2227 | 2018-05-23 10:17:17 -0600 | [diff] [blame^] | 29 | GrCCDrawPathsOp(GrPaint&&, const SkIRect& clipIBounds, const SkMatrix&, const SkPath&, |
| 30 | const SkRect& devBounds); |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 31 | ~GrCCDrawPathsOp() override; |
| 32 | |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 33 | const char* name() const override { return "GrCCDrawOp"; } |
| 34 | FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; } |
| 35 | RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*, |
| 36 | GrPixelConfigIsClamped) override; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 37 | bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override; |
| 38 | void visitProxies(const VisitProxyFunc& func) const override { |
| 39 | fProcessors.visitProxies(func); |
| 40 | } |
| 41 | void onPrepare(GrOpFlushState*) override {} |
| 42 | |
Chris Dalton | d7e2227 | 2018-05-23 10:17:17 -0600 | [diff] [blame^] | 43 | void wasRecorded(GrCCPerOpListPaths* owningPerOpListPaths); |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 44 | int countPaths(GrCCPathParser::PathStats*) const; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 45 | void setupResources(GrCCPerFlushResources*, GrOnFlushResourceProvider*); |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 46 | SkDEBUGCODE(int numSkippedInstances_debugOnly() const { return fNumSkippedInstances; }) |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 47 | |
| 48 | void onExecute(GrOpFlushState*) override; |
| 49 | |
| 50 | private: |
| 51 | SkPath::FillType getFillType() const { |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 52 | SkASSERT(fNumDraws >= 1); |
| 53 | return fDraws.head().fPath.getFillType(); |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | struct AtlasBatch { |
| 57 | const GrCCAtlas* fAtlas; |
| 58 | int fEndInstanceIdx; |
| 59 | }; |
| 60 | |
| 61 | void addAtlasBatch(const GrCCAtlas* atlas, int endInstanceIdx) { |
| 62 | SkASSERT(endInstanceIdx > fBaseInstance); |
| 63 | SkASSERT(fAtlasBatches.empty() || |
| 64 | endInstanceIdx > fAtlasBatches.back().fEndInstanceIdx); |
| 65 | fAtlasBatches.push_back() = {atlas, endInstanceIdx}; |
| 66 | } |
| 67 | |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 68 | const uint32_t fSRGBFlags; |
Chris Dalton | 1c54894 | 2018-05-22 13:09:48 -0600 | [diff] [blame] | 69 | const SkMatrix fViewMatrixIfUsingLocalCoords; |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 70 | |
| 71 | struct SingleDraw { |
| 72 | SkIRect fClipIBounds; |
| 73 | SkMatrix fMatrix; |
| 74 | SkPath fPath; |
| 75 | GrColor fColor; |
| 76 | SingleDraw* fNext; |
| 77 | }; |
| 78 | |
| 79 | GrCCSTLList<SingleDraw> fDraws; |
| 80 | SkDEBUGCODE(int fNumDraws = 1); |
| 81 | |
| 82 | GrProcessorSet fProcessors; |
Chris Dalton | d7e2227 | 2018-05-23 10:17:17 -0600 | [diff] [blame^] | 83 | GrCCPerOpListPaths* fOwningPerOpListPaths = nullptr; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 84 | |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 85 | int fBaseInstance; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 86 | SkSTArray<1, AtlasBatch, true> fAtlasBatches; |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 87 | SkDEBUGCODE(int fNumSkippedInstances = 0); |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | #endif |