OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrDashingEffect.h" | 8 #include "GrDashingEffect.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 GrColor fColor; | 262 GrColor fColor; |
263 }; | 263 }; |
264 | 264 |
265 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA
AMode aaMode, | 265 static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashA
AMode aaMode, |
266 bool fullDash) { | 266 bool fullDash) { |
267 return new DashBatch(geometry, cap, aaMode, fullDash); | 267 return new DashBatch(geometry, cap, aaMode, fullDash); |
268 } | 268 } |
269 | 269 |
270 const char* name() const override { return "DashBatch"; } | 270 const char* name() const override { return "DashBatch"; } |
271 | 271 |
272 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 272 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 273 GrInitInvariantOutput* coverage, |
| 274 GrBatchToXPOverrides* overrides) const ove
rride { |
273 // When this is called on a batch, there is only one geometry bundle | 275 // When this is called on a batch, there is only one geometry bundle |
274 out->setKnownFourComponents(fGeoData[0].fColor); | 276 color->setKnownFourComponents(fGeoData[0].fColor); |
275 } | 277 coverage->setUnknownSingleComponent(); |
276 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 278 overrides->fUsePLSDstRead = false; |
277 out->setUnknownSingleComponent(); | |
278 } | 279 } |
279 | 280 |
280 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 281 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
281 | 282 |
282 private: | 283 private: |
283 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo
l fullDash) | 284 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo
l fullDash) |
284 : INHERITED(ClassID()) { | 285 : INHERITED(ClassID()) { |
285 fGeoData.push_back(geometry); | 286 fGeoData.push_back(geometry); |
286 | 287 |
287 fBatch.fAAMode = aaMode; | 288 fBatch.fAAMode = aaMode; |
288 fBatch.fCap = cap; | 289 fBatch.fCap = cap; |
289 fBatch.fFullDash = fullDash; | 290 fBatch.fFullDash = fullDash; |
290 | 291 |
291 // compute bounds | 292 // compute bounds |
292 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; | 293 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; |
293 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; | 294 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; |
294 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); | 295 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); |
295 fBounds.outset(xBloat, halfStrokeWidth); | 296 fBounds.outset(xBloat, halfStrokeWidth); |
296 | 297 |
297 // Note, we actually create the combined matrix here, and save the work | 298 // Note, we actually create the combined matrix here, and save the work |
298 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv; | 299 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv; |
299 combinedMatrix.postConcat(geometry.fViewMatrix); | 300 combinedMatrix.postConcat(geometry.fViewMatrix); |
300 combinedMatrix.mapRect(&fBounds); | 301 combinedMatrix.mapRect(&fBounds); |
301 } | 302 } |
302 | 303 |
303 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 304 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
304 // Handle any color overrides | 305 // Handle any color overrides |
305 if (!opt.readsColor()) { | 306 if (!overrides.readsColor()) { |
306 fGeoData[0].fColor = GrColor_ILLEGAL; | 307 fGeoData[0].fColor = GrColor_ILLEGAL; |
307 } | 308 } |
308 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 309 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
309 | 310 |
310 // setup batch properties | 311 // setup batch properties |
311 fBatch.fColorIgnored = !opt.readsColor(); | 312 fBatch.fColorIgnored = !overrides.readsColor(); |
312 fBatch.fColor = fGeoData[0].fColor; | 313 fBatch.fColor = fGeoData[0].fColor; |
313 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 314 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
314 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 315 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
315 } | 316 } |
316 | 317 |
317 struct DashDraw { | 318 struct DashDraw { |
318 SkScalar fStartOffset; | 319 SkScalar fStartOffset; |
319 SkScalar fStrokeWidth; | 320 SkScalar fStrokeWidth; |
320 SkScalar fLineLength; | 321 SkScalar fLineLength; |
321 SkScalar fHalfDevStroke; | 322 SkScalar fHalfDevStroke; |
322 SkScalar fDevBloatX; | 323 SkScalar fDevBloatX; |
323 SkScalar fDevBloatY; | 324 SkScalar fDevBloatY; |
324 bool fLineDone; | 325 bool fLineDone; |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 info.fIntervals = intervals; | 1297 info.fIntervals = intervals; |
1297 info.fCount = 2; | 1298 info.fCount = 2; |
1298 info.fPhase = phase; | 1299 info.fPhase = phase; |
1299 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); | 1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); |
1300 SkASSERT(success); | 1301 SkASSERT(success); |
1301 | 1302 |
1302 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); | 1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); |
1303 } | 1304 } |
1304 | 1305 |
1305 #endif | 1306 #endif |
OLD | NEW |