OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAADistanceFieldPathRenderer.h" | 9 #include "GrAADistanceFieldPathRenderer.h" |
10 | 10 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 PathCache* pathCache, PathDataList* pathList) { | 305 PathCache* pathCache, PathDataList* pathList) { |
306 this->initClassID<AADistanceFieldPathBatch>(); | 306 this->initClassID<AADistanceFieldPathBatch>(); |
307 fBatch.fColor = color; | 307 fBatch.fColor = color; |
308 fBatch.fViewMatrix = viewMatrix; | 308 fBatch.fViewMatrix = viewMatrix; |
309 fGeoData.push_back(geometry); | 309 fGeoData.push_back(geometry); |
310 fGeoData.back().fPathData = NULL; | 310 fGeoData.back().fPathData = NULL; |
311 | 311 |
312 fAtlas = atlas; | 312 fAtlas = atlas; |
313 fPathCache = pathCache; | 313 fPathCache = pathCache; |
314 fPathList = pathList; | 314 fPathList = pathList; |
| 315 |
| 316 // Compute bounds |
| 317 *this->getBounds() = geometry.fPath.getBounds(); |
| 318 viewMatrix.mapRect(this->getBounds()); |
315 } | 319 } |
316 | 320 |
317 bool addPathToAtlas(GrBatchTarget* batchTarget, | 321 bool addPathToAtlas(GrBatchTarget* batchTarget, |
318 const GrGeometryProcessor* dfProcessor, | 322 const GrGeometryProcessor* dfProcessor, |
319 const GrPipeline* pipeline, | 323 const GrPipeline* pipeline, |
320 GrDrawTarget::DrawInfo* drawInfo, | 324 GrDrawTarget::DrawInfo* drawInfo, |
321 int* instancesToFlush, | 325 int* instancesToFlush, |
322 int maxInstancesPerDraw, | 326 int maxInstancesPerDraw, |
323 GrBatchAtlas* atlas, | 327 GrBatchAtlas* atlas, |
324 PathData* pathData, | 328 PathData* pathData, |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // maybe upload color via attribute | 545 // maybe upload color via attribute |
542 if (this->color() != that->color()) { | 546 if (this->color() != that->color()) { |
543 return false; | 547 return false; |
544 } | 548 } |
545 | 549 |
546 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 550 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
547 return false; | 551 return false; |
548 } | 552 } |
549 | 553 |
550 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 554 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 555 this->joinBounds(that->bounds()); |
551 return true; | 556 return true; |
552 } | 557 } |
553 | 558 |
554 struct BatchTracker { | 559 struct BatchTracker { |
555 GrColor fColor; | 560 GrColor fColor; |
556 SkMatrix fViewMatrix; | 561 SkMatrix fViewMatrix; |
557 bool fUsesLocalCoords; | 562 bool fUsesLocalCoords; |
558 bool fColorIgnored; | 563 bool fColorIgnored; |
559 bool fCoverageIgnored; | 564 bool fCoverageIgnored; |
560 }; | 565 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 fAtlas->registerEvictionCallback(&GrAADistanceFieldPathRenderer::HandleE
viction, | 605 fAtlas->registerEvictionCallback(&GrAADistanceFieldPathRenderer::HandleE
viction, |
601 (void*)this); | 606 (void*)this); |
602 } | 607 } |
603 | 608 |
604 AADistanceFieldPathBatch::Geometry geometry(stroke.getStrokeRec()); | 609 AADistanceFieldPathBatch::Geometry geometry(stroke.getStrokeRec()); |
605 geometry.fPath = path; | 610 geometry.fPath = path; |
606 geometry.fAntiAlias = antiAlias; | 611 geometry.fAntiAlias = antiAlias; |
607 | 612 |
608 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, | 613 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, |
609 fAtlas, &fPathC
ache, &fPathList)); | 614 fAtlas, &fPathC
ache, &fPathList)); |
610 | 615 target->drawBatch(pipelineBuilder, batch); |
611 SkRect bounds = path.getBounds(); | |
612 viewMatrix.mapRect(&bounds); | |
613 target->drawBatch(pipelineBuilder, batch, &bounds); | |
614 | 616 |
615 return true; | 617 return true; |
616 } | 618 } |
617 | 619 |
OLD | NEW |