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; |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame^] | 19 | class 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: |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 51 | struct AtlasBatch { |
| 52 | const GrCCAtlas* fAtlas; |
| 53 | int fEndInstanceIdx; |
| 54 | }; |
| 55 | |
| 56 | void addAtlasBatch(const GrCCAtlas* atlas, int endInstanceIdx) { |
| 57 | SkASSERT(endInstanceIdx > fBaseInstance); |
| 58 | SkASSERT(fAtlasBatches.empty() || |
| 59 | endInstanceIdx > fAtlasBatches.back().fEndInstanceIdx); |
| 60 | fAtlasBatches.push_back() = {atlas, endInstanceIdx}; |
| 61 | } |
| 62 | |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 63 | const uint32_t fSRGBFlags; |
Chris Dalton | 1c54894 | 2018-05-22 13:09:48 -0600 | [diff] [blame] | 64 | const SkMatrix fViewMatrixIfUsingLocalCoords; |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 65 | |
| 66 | struct SingleDraw { |
| 67 | SkIRect fClipIBounds; |
| 68 | SkMatrix fMatrix; |
| 69 | SkPath fPath; |
| 70 | GrColor fColor; |
| 71 | SingleDraw* fNext; |
| 72 | }; |
| 73 | |
| 74 | GrCCSTLList<SingleDraw> fDraws; |
| 75 | SkDEBUGCODE(int fNumDraws = 1); |
| 76 | |
| 77 | GrProcessorSet fProcessors; |
Chris Dalton | d7e2227 | 2018-05-23 10:17:17 -0600 | [diff] [blame] | 78 | GrCCPerOpListPaths* fOwningPerOpListPaths = nullptr; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 79 | |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 80 | int fBaseInstance; |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 81 | SkSTArray<1, AtlasBatch, true> fAtlasBatches; |
Chris Dalton | 4bfb50b | 2018-05-21 09:10:53 -0600 | [diff] [blame] | 82 | SkDEBUGCODE(int fNumSkippedInstances = 0); |
Chris Dalton | 5ba36ba | 2018-05-09 01:08:38 -0600 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | #endif |