| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 SkScalar fStrokeWidth; | 291 SkScalar fStrokeWidth; |
| 292 SkScalar fLineLength; | 292 SkScalar fLineLength; |
| 293 SkScalar fHalfDevStroke; | 293 SkScalar fHalfDevStroke; |
| 294 SkScalar fDevBloatX; | 294 SkScalar fDevBloatX; |
| 295 SkScalar fDevBloatY; | 295 SkScalar fDevBloatY; |
| 296 bool fLineDone; | 296 bool fLineDone; |
| 297 bool fHasStartRect; | 297 bool fHasStartRect; |
| 298 bool fHasEndRect; | 298 bool fHasEndRect; |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 301 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 302 int instanceCount = fGeoData.count(); | 302 int instanceCount = fGeoData.count(); |
| 303 SkPaint::Cap cap = this->cap(); | 303 SkPaint::Cap cap = this->cap(); |
| 304 bool isRoundCap = SkPaint::kRound_Cap == cap; | 304 bool isRoundCap = SkPaint::kRound_Cap == cap; |
| 305 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap; | 305 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap; |
| 306 | 306 |
| 307 SkAutoTUnref<const GrGeometryProcessor> gp; | 307 SkAutoTUnref<const GrGeometryProcessor> gp; |
| 308 if (this->fullDash()) { | 308 if (this->fullDash()) { |
| 309 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this
->viewMatrix(), | 309 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this
->viewMatrix(), |
| 310 this->usesLocalCoords())); | 310 this->usesLocalCoords())); |
| 311 } else { | 311 } else { |
| 312 // Set up the vertex data for the line and start/end dashes | 312 // Set up the vertex data for the line and start/end dashes |
| 313 using namespace GrDefaultGeoProcFactory; | 313 using namespace GrDefaultGeoProcFactory; |
| 314 Color color(this->color()); | 314 Color color(this->color()); |
| 315 Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : | 315 Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : |
| 316 Coverage::kSolid_Type); | 316 Coverage::kSolid_Type); |
| 317 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : | 317 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : |
| 318 LocalCoords::kUnus
ed_Type); | 318 LocalCoords::kUnus
ed_Type); |
| 319 gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->vi
ewMatrix())); | 319 gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->vi
ewMatrix())); |
| 320 } | 320 } |
| 321 | 321 |
| 322 if (!gp) { | 322 if (!gp) { |
| 323 SkDebugf("Could not create GrGeometryProcessor\n"); | 323 SkDebugf("Could not create GrGeometryProcessor\n"); |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 | 326 |
| 327 batchTarget->initDraw(gp, pipeline); | 327 batchTarget->initDraw(gp, this->pipeline()); |
| 328 | 328 |
| 329 // useAA here means Edge AA or MSAA | 329 // useAA here means Edge AA or MSAA |
| 330 bool useAA = this->aaMode() != kBW_DashAAMode; | 330 bool useAA = this->aaMode() != kBW_DashAAMode; |
| 331 bool fullDash = this->fullDash(); | 331 bool fullDash = this->fullDash(); |
| 332 | 332 |
| 333 // We do two passes over all of the dashes. First we setup the start, e
nd, and bounds, | 333 // We do two passes over all of the dashes. First we setup the start, e
nd, and bounds, |
| 334 // rectangles. We preserve all of this work in the rects / draws arrays
below. Then we | 334 // rectangles. We preserve all of this work in the rects / draws arrays
below. Then we |
| 335 // iterate again over these decomposed dashes to generate vertices | 335 // iterate again over these decomposed dashes to generate vertices |
| 336 SkSTArray<128, SkRect, true> rects; | 336 SkSTArray<128, SkRect, true> rects; |
| 337 SkSTArray<128, DashDraw, true> draws; | 337 SkSTArray<128, DashDraw, true> draws; |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 info.fIntervals = intervals; | 1297 info.fIntervals = intervals; |
| 1298 info.fCount = 2; | 1298 info.fCount = 2; |
| 1299 info.fPhase = phase; | 1299 info.fPhase = phase; |
| 1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); | 1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); |
| 1301 SkASSERT(success); | 1301 SkASSERT(success); |
| 1302 | 1302 |
| 1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); | 1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 #endif | 1306 #endif |
| OLD | NEW |