| 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 |
| 11 #include "GrBatchFlushState.h" | 11 #include "GrBatchFlushState.h" |
| 12 #include "GrDrawBatch.h" | 12 #include "GrDrawBatch.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrPath.h" | 14 #include "GrPath.h" |
| 15 #include "GrPathRendering.h" | 15 #include "GrPathRendering.h" |
| 16 #include "GrPathProcessor.h" | 16 #include "GrPathProcessor.h" |
| 17 | 17 |
| 18 #include "SkTLList.h" | 18 #include "SkTLList.h" |
| 19 | 19 |
| 20 class GrDrawPathBatchBase : public GrDrawBatch { | 20 class GrDrawPathBatchBase : public GrDrawBatch { |
| 21 public: | 21 public: |
| 22 void computePipelineOptimizations(GrInitInvariantOutput* color, | 22 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 23 GrInitInvariantOutput* coverage, | 23 GrInitInvariantOutput* coverage, |
| 24 GrBatchToXPOverrides* overrides) const ove
rride { | 24 GrBatchToXPOverrides* overrides) const ove
rride { |
| 25 color->setKnownFourComponents(fColor); | 25 color->setKnownFourComponents(fColor); |
| 26 coverage->setKnownSingleComponent(0xff); | 26 coverage->setKnownSingleComponent(0xff); |
| 27 overrides->fUsePLSDstRead = false; | 27 overrides->fUsePLSDstRead = false; |
| 28 } | 28 } |
| 29 | 29 |
| 30 GrPathRendering::FillType fillType() const { return fFillType; } |
| 31 |
| 30 void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings
= stencil; } | 32 void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings
= stencil; } |
| 31 | 33 |
| 32 protected: | 34 protected: |
| 33 GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor in
itialColor) | 35 GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor in
itialColor, |
| 36 GrPathRendering::FillType fill) |
| 34 : INHERITED(classID) | 37 : INHERITED(classID) |
| 35 , fViewMatrix(viewMatrix) | 38 , fViewMatrix(viewMatrix) |
| 36 , fColor(initialColor) {} | 39 , fColor(initialColor) |
| 40 , fFillType(fill) {} |
| 37 | 41 |
| 38 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} | 42 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} |
| 39 const GrXPOverridesForBatch& overrides() const { return fOverrides; } | 43 const GrXPOverridesForBatch& overrides() const { return fOverrides; } |
| 40 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 44 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 41 GrColor color() const { return fColor; } | 45 GrColor color() const { return fColor; } |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 48 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 45 overrides.getOverrideColorIfSet(&fColor); | 49 overrides.getOverrideColorIfSet(&fColor); |
| 46 fOverrides = overrides; | 50 fOverrides = overrides; |
| 47 } | 51 } |
| 48 | 52 |
| 49 SkMatrix fViewMatrix; | 53 SkMatrix fViewMatrix; |
| 50 GrColor fColor; | 54 GrColor fColor; |
| 55 GrPathRendering::FillType fFillType; |
| 51 GrStencilSettings fStencilSettings; | 56 GrStencilSettings fStencilSettings; |
| 52 GrXPOverridesForBatch fOverrides; | 57 GrXPOverridesForBatch fOverrides; |
| 53 | 58 |
| 54 typedef GrDrawBatch INHERITED; | 59 typedef GrDrawBatch INHERITED; |
| 55 }; | 60 }; |
| 56 | 61 |
| 57 class GrDrawPathBatch final : public GrDrawPathBatchBase { | 62 class GrDrawPathBatch final : public GrDrawPathBatchBase { |
| 58 public: | 63 public: |
| 59 DEFINE_BATCH_CLASS_ID | 64 DEFINE_BATCH_CLASS_ID |
| 60 | 65 |
| 61 // This can't return a more abstract type because we install the stencil set
tings late :( | 66 // 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
, | 67 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color
, |
| 63 const GrPath* path) { | 68 GrPathRendering::FillType fill, const GrP
ath* path) { |
| 64 return new GrDrawPathBatch(viewMatrix, color, path); | 69 return new GrDrawPathBatch(viewMatrix, color, fill, path); |
| 65 } | 70 } |
| 66 | 71 |
| 67 const char* name() const override { return "DrawPath"; } | 72 const char* name() const override { return "DrawPath"; } |
| 68 | 73 |
| 69 SkString dumpInfo() const override; | 74 SkString dumpInfo() const override; |
| 70 | 75 |
| 71 private: | 76 private: |
| 72 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* pat
h) | 77 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering::
FillType fill, |
| 73 : INHERITED(ClassID(), viewMatrix, color) | 78 const GrPath* path) |
| 79 : INHERITED(ClassID(), viewMatrix, color, fill) |
| 74 , fPath(path) { | 80 , fPath(path) { |
| 75 fBounds = path->getBounds(); | 81 fBounds = path->getBounds(); |
| 76 viewMatrix.mapRect(&fBounds); | 82 viewMatrix.mapRect(&fBounds); |
| 77 } | 83 } |
| 78 | 84 |
| 79 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 85 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 80 | 86 |
| 81 void onPrepare(GrBatchFlushState*) override {} | 87 void onPrepare(GrBatchFlushState*) override {} |
| 82 | 88 |
| 83 void onDraw(GrBatchFlushState* state) override; | 89 void onDraw(GrBatchFlushState* state) override; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 typedef GrNonAtomicRef INHERITED; | 147 typedef GrNonAtomicRef INHERITED; |
| 142 }; | 148 }; |
| 143 | 149 |
| 144 // Template this if we decide to support index types other than 16bit | 150 // Template this if we decide to support index types other than 16bit |
| 145 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { | 151 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { |
| 146 public: | 152 public: |
| 147 DEFINE_BATCH_CLASS_ID | 153 DEFINE_BATCH_CLASS_ID |
| 148 | 154 |
| 149 // This can't return a more abstract type because we install the stencil set
tings late :( | 155 // This can't return a more abstract type because we install the stencil set
tings late :( |
| 150 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatri
x& localMatrix, | 156 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatri
x& localMatrix, |
| 151 GrColor color, GrPathRange* range, GrPath
RangeDraw* draw, | 157 GrColor color, GrPathRendering::FillType
fill, |
| 158 GrPathRange* range, GrPathRangeDraw* draw
, |
| 152 const SkRect& bounds) { | 159 const SkRect& bounds) { |
| 153 return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, range, d
raw, bounds); | 160 return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, fill, ra
nge, draw, |
| 161 bounds); |
| 154 } | 162 } |
| 155 | 163 |
| 156 ~GrDrawPathRangeBatch() override; | 164 ~GrDrawPathRangeBatch() override; |
| 157 | 165 |
| 158 const char* name() const override { return "DrawPathRange"; } | 166 const char* name() const override { return "DrawPathRange"; } |
| 159 | 167 |
| 160 SkString dumpInfo() const override; | 168 SkString dumpInfo() const override; |
| 161 | 169 |
| 162 private: | 170 private: |
| 163 inline bool isWinding() const; | |
| 164 | |
| 165 GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix
, GrColor color, | 171 GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix
, GrColor color, |
| 166 GrPathRange* range, GrPathRangeDraw* draw, const SkRect
& bounds); | 172 GrPathRendering::FillType fill, GrPathRange* range, |
| 173 GrPathRangeDraw* draw, const SkRect& bounds); |
| 167 | 174 |
| 168 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; | 175 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; |
| 169 | 176 |
| 170 void onPrepare(GrBatchFlushState*) override {} | 177 void onPrepare(GrBatchFlushState*) override {} |
| 171 | 178 |
| 172 void onDraw(GrBatchFlushState* state) override; | 179 void onDraw(GrBatchFlushState* state) override; |
| 173 | 180 |
| 174 typedef GrPendingIOResource<const GrPathRange, kRead_GrIOType> PendingPathRa
nge; | 181 typedef GrPendingIOResource<const GrPathRange, kRead_GrIOType> PendingPathRa
nge; |
| 175 typedef SkTLList<GrPathRangeDraw*, 4> DrawList; | 182 typedef SkTLList<GrPathRangeDraw*, 4> DrawList; |
| 176 PendingPathRange fPathRange; | 183 PendingPathRange fPathRange; |
| 177 DrawList fDraws; | 184 DrawList fDraws; |
| 178 int fTotalPathCount; | 185 int fTotalPathCount; |
| 179 SkMatrix fLocalMatrix; | 186 SkMatrix fLocalMatrix; |
| 180 | 187 |
| 181 typedef GrDrawPathBatchBase INHERITED; | 188 typedef GrDrawPathBatchBase INHERITED; |
| 182 }; | 189 }; |
| 183 | 190 |
| 184 #endif | 191 #endif |
| OLD | NEW |