| 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 "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 struct Geometry { | 249 struct Geometry { |
| 250 GrColor fColor; | 250 GrColor fColor; |
| 251 SkMatrix fViewMatrix; | 251 SkMatrix fViewMatrix; |
| 252 SkMatrix fSrcRotInv; | 252 SkMatrix fSrcRotInv; |
| 253 SkPoint fPtsRot[2]; | 253 SkPoint fPtsRot[2]; |
| 254 SkScalar fSrcStrokeWidth; | 254 SkScalar fSrcStrokeWidth; |
| 255 SkScalar fPhase; | 255 SkScalar fPhase; |
| 256 SkScalar fIntervals[2]; | 256 SkScalar fIntervals[2]; |
| 257 SkScalar fParallelScale; | 257 SkScalar fParallelScale; |
| 258 SkScalar fPerpendicularScale; | 258 SkScalar fPerpendicularScale; |
| 259 SkDEBUGCODE(SkRect fDevBounds;) | |
| 260 }; | 259 }; |
| 261 | 260 |
| 262 static GrBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMod
e aaMode, | 261 static GrBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMod
e aaMode, |
| 263 bool fullDash) { | 262 bool fullDash) { |
| 264 return SkNEW_ARGS(DashBatch, (geometry, cap, aaMode, fullDash)); | 263 return SkNEW_ARGS(DashBatch, (geometry, cap, aaMode, fullDash)); |
| 265 } | 264 } |
| 266 | 265 |
| 267 const char* name() const override { return "DashBatch"; } | 266 const char* name() const override { return "DashBatch"; } |
| 268 | 267 |
| 269 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 268 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 638 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 640 | 639 |
| 641 private: | 640 private: |
| 642 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo
l fullDash) { | 641 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo
l fullDash) { |
| 643 this->initClassID<DashBatch>(); | 642 this->initClassID<DashBatch>(); |
| 644 fGeoData.push_back(geometry); | 643 fGeoData.push_back(geometry); |
| 645 | 644 |
| 646 fBatch.fAAMode = aaMode; | 645 fBatch.fAAMode = aaMode; |
| 647 fBatch.fCap = cap; | 646 fBatch.fCap = cap; |
| 648 fBatch.fFullDash = fullDash; | 647 fBatch.fFullDash = fullDash; |
| 648 |
| 649 // TODO more accurate bounds |
| 650 this->setBoundsLargest(); |
| 649 } | 651 } |
| 650 | 652 |
| 651 bool onCombineIfPossible(GrBatch* t) override { | 653 bool onCombineIfPossible(GrBatch* t) override { |
| 652 DashBatch* that = t->cast<DashBatch>(); | 654 DashBatch* that = t->cast<DashBatch>(); |
| 653 | 655 |
| 654 if (this->aaMode() != that->aaMode()) { | 656 if (this->aaMode() != that->aaMode()) { |
| 655 return false; | 657 return false; |
| 656 } | 658 } |
| 657 | 659 |
| 658 if (this->fullDash() != that->fullDash()) { | 660 if (this->fullDash() != that->fullDash()) { |
| 659 return false; | 661 return false; |
| 660 } | 662 } |
| 661 | 663 |
| 662 if (this->cap() != that->cap()) { | 664 if (this->cap() != that->cap()) { |
| 663 return false; | 665 return false; |
| 664 } | 666 } |
| 665 | 667 |
| 666 // TODO vertex color | 668 // TODO vertex color |
| 667 if (this->color() != that->color()) { | 669 if (this->color() != that->color()) { |
| 668 return false; | 670 return false; |
| 669 } | 671 } |
| 670 | 672 |
| 671 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 673 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
| 672 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 674 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
| 673 return false; | 675 return false; |
| 674 } | 676 } |
| 675 | 677 |
| 676 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 678 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 679 this->joinBounds(that->bounds()); |
| 677 return true; | 680 return true; |
| 678 } | 681 } |
| 679 | 682 |
| 680 GrColor color() const { return fBatch.fColor; } | 683 GrColor color() const { return fBatch.fColor; } |
| 681 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 684 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 682 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 685 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 683 DashAAMode aaMode() const { return fBatch.fAAMode; } | 686 DashAAMode aaMode() const { return fBatch.fAAMode; } |
| 684 bool fullDash() const { return fBatch.fFullDash; } | 687 bool fullDash() const { return fBatch.fFullDash; } |
| 685 SkPaint::Cap cap() const { return fBatch.fCap; } | 688 SkPaint::Cap cap() const { return fBatch.fCap; } |
| 686 | 689 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 info.fIntervals = intervals; | 1367 info.fIntervals = intervals; |
| 1365 info.fCount = 2; | 1368 info.fCount = 2; |
| 1366 info.fPhase = phase; | 1369 info.fPhase = phase; |
| 1367 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); | 1370 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); |
| 1368 SkASSERT(success); | 1371 SkASSERT(success); |
| 1369 | 1372 |
| 1370 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); | 1373 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); |
| 1371 } | 1374 } |
| 1372 | 1375 |
| 1373 #endif | 1376 #endif |
| OLD | NEW |