| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 : INHERITED(ClassID()) { | 275 : INHERITED(ClassID()) { |
| 276 fGeoData.push_back(geometry); | 276 fGeoData.push_back(geometry); |
| 277 | 277 |
| 278 fBatch.fAAMode = aaMode; | 278 fBatch.fAAMode = aaMode; |
| 279 fBatch.fCap = cap; | 279 fBatch.fCap = cap; |
| 280 fBatch.fFullDash = fullDash; | 280 fBatch.fFullDash = fullDash; |
| 281 | 281 |
| 282 // compute bounds | 282 // compute bounds |
| 283 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; | 283 SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth; |
| 284 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; | 284 SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth; |
| 285 fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); | 285 SkRect bounds; |
| 286 fBounds.outset(xBloat, halfStrokeWidth); | 286 bounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]); |
| 287 bounds.outset(xBloat, halfStrokeWidth); |
| 287 | 288 |
| 288 // Note, we actually create the combined matrix here, and save the work | 289 // Note, we actually create the combined matrix here, and save the work |
| 289 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv; | 290 SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv; |
| 290 combinedMatrix.postConcat(geometry.fViewMatrix); | 291 combinedMatrix.postConcat(geometry.fViewMatrix); |
| 291 combinedMatrix.mapRect(&fBounds); | 292 |
| 293 IsZeroArea zeroArea = geometry.fSrcStrokeWidth ? IsZeroArea::kNo : IsZer
oArea::kYes; |
| 294 HasAABloat aaBloat = (aaMode == AAMode::kNone) ? HasAABloat ::kNo : HasA
ABloat::kYes; |
| 295 this->setTransformedBounds(bounds, combinedMatrix, aaBloat, zeroArea); |
| 292 } | 296 } |
| 293 | 297 |
| 294 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 298 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 295 // Handle any color overrides | 299 // Handle any color overrides |
| 296 if (!overrides.readsColor()) { | 300 if (!overrides.readsColor()) { |
| 297 fGeoData[0].fColor = GrColor_ILLEGAL; | 301 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 298 } | 302 } |
| 299 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 303 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 300 | 304 |
| 301 // setup batch properties | 305 // setup batch properties |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 if (this->color() != that->color()) { | 652 if (this->color() != that->color()) { |
| 649 return false; | 653 return false; |
| 650 } | 654 } |
| 651 | 655 |
| 652 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 656 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
| 653 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 657 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
| 654 return false; | 658 return false; |
| 655 } | 659 } |
| 656 | 660 |
| 657 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 661 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 658 this->joinBounds(that->bounds()); | 662 this->joinBounds(*that); |
| 659 return true; | 663 return true; |
| 660 } | 664 } |
| 661 | 665 |
| 662 GrColor color() const { return fBatch.fColor; } | 666 GrColor color() const { return fBatch.fColor; } |
| 663 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 667 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 664 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 668 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 665 AAMode aaMode() const { return fBatch.fAAMode; } | 669 AAMode aaMode() const { return fBatch.fAAMode; } |
| 666 bool fullDash() const { return fBatch.fFullDash; } | 670 bool fullDash() const { return fBatch.fFullDash; } |
| 667 SkPaint::Cap cap() const { return fBatch.fCap; } | 671 SkPaint::Cap cap() const { return fBatch.fCap; } |
| 668 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 672 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 p.setStrokeWidth(SkIntToScalar(1)); | 1284 p.setStrokeWidth(SkIntToScalar(1)); |
| 1281 p.setStrokeCap(cap); | 1285 p.setStrokeCap(cap); |
| 1282 p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase)); | 1286 p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase)); |
| 1283 | 1287 |
| 1284 GrStyle style(p); | 1288 GrStyle style(p); |
| 1285 | 1289 |
| 1286 return GrDashingEffect::CreateDashLineBatch(color, viewMatrix, pts, aaMode,
style); | 1290 return GrDashingEffect::CreateDashLineBatch(color, viewMatrix, pts, aaMode,
style); |
| 1287 } | 1291 } |
| 1288 | 1292 |
| 1289 #endif | 1293 #endif |
| OLD | NEW |