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