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 getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 22 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
23 this->pathProcessor()->getInvariantOutputColor(out); | 23 out->setKnownFourComponents(fColor); |
24 } | 24 } |
25 | 25 |
26 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 26 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
27 this->pathProcessor()->getInvariantOutputCoverage(out); | 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 GrPathProcessor* pathProc) : fPrimitiveProcessor(p
athProc) {} | 33 GrDrawPathBatchBase(const SkMatrix& viewMatrix, GrColor initialColor) |
| 34 : fViewMatrix(viewMatrix) |
| 35 , fColor(initialColor) {} |
34 | 36 |
35 GrBatchTracker* tracker() { return reinterpret_cast<GrBatchTracker*>(&fWhatc
hamacallit); } | |
36 const GrPathProcessor* pathProcessor() const { return fPrimitiveProcessor.ge
t(); } | |
37 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} | 37 const GrStencilSettings& stencilSettings() const { return fStencilSettings;
} |
38 const GrPipelineOptimizations& opts() const { return fOpts; } | 38 const GrPipelineOptimizations& opts() const { return fOpts; } |
| 39 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 40 GrColor color() const { return fColor; } |
| 41 |
| 42 // TODO delete |
| 43 const GrBatchTracker* tracker() const { return &fBatchTracker; } |
39 | 44 |
40 private: | 45 private: |
41 void initBatchTracker(const GrPipelineOptimizations& opts) override { | 46 void initBatchTracker(const GrPipelineOptimizations& opts) override { |
42 this->pathProcessor()->initBatchTracker(this->tracker(), opts); | 47 opts.getOverrideColorIfSet(&fColor); |
43 fOpts = opts; | 48 fOpts = opts; |
44 } | 49 } |
45 | 50 |
46 GrPendingProgramElement<const GrPathProcessor> fPrimitiveProcessor; | 51 SkMatrix fViewMatrix; |
47 PathBatchTracker fWhatchamacallit; //
TODO: delete this | 52 GrColor fColor; |
48 GrStencilSettings fStencilSettings; | 53 GrStencilSettings fStencilSettings; |
49 GrPipelineOptimizations fOpts; | 54 GrPipelineOptimizations fOpts; |
50 | 55 |
| 56 // TODO delete |
| 57 GrBatchTracker fBatchTracker; |
| 58 |
51 typedef GrDrawBatch INHERITED; | 59 typedef GrDrawBatch INHERITED; |
52 }; | 60 }; |
53 | 61 |
54 class GrDrawPathBatch final : public GrDrawPathBatchBase { | 62 class GrDrawPathBatch final : public GrDrawPathBatchBase { |
55 public: | 63 public: |
56 // This can't return a more abstract type because we install the stencil set
tings late :( | 64 // This can't return a more abstract type because we install the stencil set
tings late :( |
57 static GrDrawPathBatchBase* Create(const GrPathProcessor* primProc, const Gr
Path* path) { | 65 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color
, |
58 return new GrDrawPathBatch(primProc, path); | 66 const GrPath* path) { |
| 67 return new GrDrawPathBatch(viewMatrix, color, path); |
59 } | 68 } |
60 | 69 |
61 const char* name() const override { return "DrawPath"; } | 70 const char* name() const override { return "DrawPath"; } |
62 | 71 |
63 SkString dumpInfo() const override; | 72 SkString dumpInfo() const override; |
64 | 73 |
65 private: | 74 private: |
66 GrDrawPathBatch(const GrPathProcessor* pathProc, const GrPath* path) | 75 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* pat
h) |
67 : INHERITED(pathProc) | 76 : INHERITED(viewMatrix, color) |
68 , fPath(path) { | 77 , fPath(path) { |
69 fBounds = path->getBounds(); | 78 fBounds = path->getBounds(); |
70 this->pathProcessor()->viewMatrix().mapRect(&fBounds); | 79 viewMatrix.mapRect(&fBounds); |
71 this->initClassID<GrDrawPathBatch>(); | 80 this->initClassID<GrDrawPathBatch>(); |
72 } | 81 } |
73 | 82 |
74 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 83 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
75 | 84 |
76 void onPrepare(GrBatchFlushState*) override {} | 85 void onPrepare(GrBatchFlushState*) override {} |
77 | 86 |
78 void onDraw(GrBatchFlushState* state) override; | 87 void onDraw(GrBatchFlushState* state) override; |
79 | 88 |
80 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 89 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 friend class GrDrawPathRangeBatch; | 147 friend class GrDrawPathRangeBatch; |
139 #endif | 148 #endif |
140 | 149 |
141 typedef GrNonAtomicRef INHERITED; | 150 typedef GrNonAtomicRef INHERITED; |
142 }; | 151 }; |
143 | 152 |
144 // Template this if we decide to support index types other than 16bit | 153 // Template this if we decide to support index types other than 16bit |
145 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { | 154 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { |
146 public: | 155 public: |
147 // This can't return a more abstracet type because we install the stencil se
ttings late :( | 156 // This can't return a more abstracet type because we install the stencil se
ttings late :( |
148 static GrDrawPathBatchBase* Create(const GrPathProcessor* pathProc, | 157 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatri
x& localMatrix, |
149 GrPathRangeDraw* pathRangeDraw) { | 158 GrColor color, GrPathRangeDraw* pathRange
Draw) { |
150 return SkNEW_ARGS(GrDrawPathRangeBatch, (pathProc, pathRangeDraw)); | 159 return SkNEW_ARGS(GrDrawPathRangeBatch, (viewMatrix, localMatrix, color,
pathRangeDraw)); |
151 } | 160 } |
152 | 161 |
153 ~GrDrawPathRangeBatch() override; | 162 ~GrDrawPathRangeBatch() override; |
154 | 163 |
155 const char* name() const override { return "DrawPathRange"; } | 164 const char* name() const override { return "DrawPathRange"; } |
156 | 165 |
157 SkString dumpInfo() const override; | 166 SkString dumpInfo() const override; |
158 | 167 |
159 private: | 168 private: |
160 inline bool isWinding() const; | 169 inline bool isWinding() const; |
161 | 170 |
162 GrDrawPathRangeBatch(const GrPathProcessor* pathProc, GrPathRangeDraw* pathR
angeDraw); | 171 GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix
, GrColor color, |
| 172 GrPathRangeDraw* pathRangeDraw); |
163 | 173 |
164 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; | 174 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; |
165 | 175 |
166 void onPrepare(GrBatchFlushState*) override {} | 176 void onPrepare(GrBatchFlushState*) override {} |
167 | 177 |
168 void onDraw(GrBatchFlushState* state) override; | 178 void onDraw(GrBatchFlushState* state) override; |
169 | 179 |
170 typedef SkTLList<GrPathRangeDraw*> DrawList; | 180 typedef SkTLList<GrPathRangeDraw*> DrawList; |
171 DrawList fDraws; | 181 DrawList fDraws; |
172 int fTotalPathCount; | 182 int fTotalPathCount; |
| 183 SkMatrix fLocalMatrix; |
173 | 184 |
174 typedef GrDrawPathBatchBase INHERITED; | 185 typedef GrDrawPathBatchBase INHERITED; |
175 }; | 186 }; |
176 | 187 |
177 #endif | 188 #endif |
OLD | NEW |