| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrDrawPathBatch_DEFINED | 8 #ifndef GrDrawPathBatch_DEFINED |
| 9 #define GrDrawPathBatch_DEFINED | 9 #define GrDrawPathBatch_DEFINED |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 out->setKnownFourComponents(fColor); | 23 out->setKnownFourComponents(fColor); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 26 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 27 out->setKnownSingleComponent(0xff); | 27 out->setKnownSingleComponent(0xff); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings
= stencil; } | 30 void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings
= stencil; } |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 GrDrawPathBatchBase(const SkMatrix& viewMatrix, GrColor initialColor) | 33 GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor in
itialColor) |
| 34 : fViewMatrix(viewMatrix) | 34 : INHERITED(classID) |
| 35 , fViewMatrix(viewMatrix) |
| 35 , fColor(initialColor) {} | 36 , fColor(initialColor) {} |
| 36 | 37 |
| 37 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} | 38 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} |
| 38 const GrPipelineOptimizations& opts() const { return fOpts; } | 39 const GrPipelineOptimizations& opts() const { return fOpts; } |
| 39 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 40 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 40 GrColor color() const { return fColor; } | 41 GrColor color() const { return fColor; } |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 void initBatchTracker(const GrPipelineOptimizations& opts) override { | 44 void initBatchTracker(const GrPipelineOptimizations& opts) override { |
| 44 opts.getOverrideColorIfSet(&fColor); | 45 opts.getOverrideColorIfSet(&fColor); |
| 45 fOpts = opts; | 46 fOpts = opts; |
| 46 } | 47 } |
| 47 | 48 |
| 48 SkMatrix fViewMatrix; | 49 SkMatrix fViewMatrix; |
| 49 GrColor fColor; | 50 GrColor fColor; |
| 50 GrStencilSettings fStencilSettings; | 51 GrStencilSettings fStencilSettings; |
| 51 GrPipelineOptimizations fOpts; | 52 GrPipelineOptimizations fOpts; |
| 52 | 53 |
| 53 typedef GrDrawBatch INHERITED; | 54 typedef GrDrawBatch INHERITED; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 class GrDrawPathBatch final : public GrDrawPathBatchBase { | 57 class GrDrawPathBatch final : public GrDrawPathBatchBase { |
| 57 public: | 58 public: |
| 59 DEFINE_BATCH_CLASS_ID |
| 60 |
| 58 // This can't return a more abstract type because we install the stencil set
tings late :( | 61 // This can't return a more abstract type because we install the stencil set
tings late :( |
| 59 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color
, | 62 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color
, |
| 60 const GrPath* path) { | 63 const GrPath* path) { |
| 61 return new GrDrawPathBatch(viewMatrix, color, path); | 64 return new GrDrawPathBatch(viewMatrix, color, path); |
| 62 } | 65 } |
| 63 | 66 |
| 64 const char* name() const override { return "DrawPath"; } | 67 const char* name() const override { return "DrawPath"; } |
| 65 | 68 |
| 66 SkString dumpInfo() const override; | 69 SkString dumpInfo() const override; |
| 67 | 70 |
| 68 private: | 71 private: |
| 69 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* pat
h) | 72 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* pat
h) |
| 70 : INHERITED(viewMatrix, color) | 73 : INHERITED(ClassID(), viewMatrix, color) |
| 71 , fPath(path) { | 74 , fPath(path) { |
| 72 fBounds = path->getBounds(); | 75 fBounds = path->getBounds(); |
| 73 viewMatrix.mapRect(&fBounds); | 76 viewMatrix.mapRect(&fBounds); |
| 74 this->initClassID<GrDrawPathBatch>(); | |
| 75 } | 77 } |
| 76 | 78 |
| 77 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 79 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 78 | 80 |
| 79 void onPrepare(GrBatchFlushState*) override {} | 81 void onPrepare(GrBatchFlushState*) override {} |
| 80 | 82 |
| 81 void onDraw(GrBatchFlushState* state) override; | 83 void onDraw(GrBatchFlushState* state) override; |
| 82 | 84 |
| 83 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 85 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 84 | 86 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 bool fUsedInBatch; | 142 bool fUsedInBatch; |
| 141 friend class GrDrawPathRangeBatch; | 143 friend class GrDrawPathRangeBatch; |
| 142 #endif | 144 #endif |
| 143 | 145 |
| 144 typedef GrNonAtomicRef INHERITED; | 146 typedef GrNonAtomicRef INHERITED; |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 // Template this if we decide to support index types other than 16bit | 149 // Template this if we decide to support index types other than 16bit |
| 148 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { | 150 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { |
| 149 public: | 151 public: |
| 150 // This can't return a more abstracet type because we install the stencil se
ttings late :( | 152 DEFINE_BATCH_CLASS_ID |
| 153 |
| 154 // This can't return a more abstract type because we install the stencil set
tings late :( |
| 151 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatri
x& localMatrix, | 155 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatri
x& localMatrix, |
| 152 GrColor color, GrPathRangeDraw* pathRange
Draw) { | 156 GrColor color, GrPathRangeDraw* pathRange
Draw) { |
| 153 return SkNEW_ARGS(GrDrawPathRangeBatch, (viewMatrix, localMatrix, color,
pathRangeDraw)); | 157 return SkNEW_ARGS(GrDrawPathRangeBatch, (viewMatrix, localMatrix, color,
pathRangeDraw)); |
| 154 } | 158 } |
| 155 | 159 |
| 156 ~GrDrawPathRangeBatch() override; | 160 ~GrDrawPathRangeBatch() override; |
| 157 | 161 |
| 158 const char* name() const override { return "DrawPathRange"; } | 162 const char* name() const override { return "DrawPathRange"; } |
| 159 | 163 |
| 160 SkString dumpInfo() const override; | 164 SkString dumpInfo() const override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 173 | 177 |
| 174 typedef SkTLList<GrPathRangeDraw*> DrawList; | 178 typedef SkTLList<GrPathRangeDraw*> DrawList; |
| 175 DrawList fDraws; | 179 DrawList fDraws; |
| 176 int fTotalPathCount; | 180 int fTotalPathCount; |
| 177 SkMatrix fLocalMatrix; | 181 SkMatrix fLocalMatrix; |
| 178 | 182 |
| 179 typedef GrDrawPathBatchBase INHERITED; | 183 typedef GrDrawPathBatchBase INHERITED; |
| 180 }; | 184 }; |
| 181 | 185 |
| 182 #endif | 186 #endif |
| OLD | NEW |