| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 pipeline, | 286 pipeline, |
| 287 dfProcessor, | 287 dfProcessor, |
| 288 positions, | 288 positions, |
| 289 vertexStride, | 289 vertexStride, |
| 290 this->viewMatrix(), | 290 this->viewMatrix(), |
| 291 args.fPath, | 291 args.fPath, |
| 292 args.fPathData); | 292 args.fPathData); |
| 293 instancesToFlush++; | 293 instancesToFlush++; |
| 294 } | 294 } |
| 295 | 295 |
| 296 this->flush(batchTarget, &drawInfo, instancesToFlush, maxInstancesPerDra
w); | 296 this->flush(batchTarget, dfProcessor, pipeline, &drawInfo, instancesToFl
ush, |
| 297 maxInstancesPerDraw); |
| 297 } | 298 } |
| 298 | 299 |
| 299 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 300 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 300 | 301 |
| 301 private: | 302 private: |
| 302 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, | 303 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, |
| 303 GrBatchAtlas* atlas, | 304 GrBatchAtlas* atlas, |
| 304 PathCache* pathCache, PathDataList* pathList) { | 305 PathCache* pathCache, PathDataList* pathList) { |
| 305 this->initClassID<AADistanceFieldPathBatch>(); | 306 this->initClassID<AADistanceFieldPathBatch>(); |
| 306 fBatch.fColor = color; | 307 fBatch.fColor = color; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 (const unsigned char*)bmp.getPixe
ls(), | 414 (const unsigned char*)bmp.getPixe
ls(), |
| 414 bmp.width(), bmp.height(), bmp.ro
wBytes()); | 415 bmp.width(), bmp.height(), bmp.ro
wBytes()); |
| 415 } | 416 } |
| 416 | 417 |
| 417 // add to atlas | 418 // add to atlas |
| 418 SkIPoint16 atlasLocation; | 419 SkIPoint16 atlasLocation; |
| 419 GrBatchAtlas::AtlasID id; | 420 GrBatchAtlas::AtlasID id; |
| 420 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor
age.get(), | 421 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor
age.get(), |
| 421 &atlasLocation); | 422 &atlasLocation); |
| 422 if (!success) { | 423 if (!success) { |
| 423 this->flush(batchTarget, drawInfo, *instancesToFlush, maxInstancesPe
rDraw); | 424 this->flush(batchTarget, dfProcessor, pipeline, drawInfo, *instances
ToFlush, |
| 425 maxInstancesPerDraw); |
| 424 this->initDraw(batchTarget, dfProcessor, pipeline); | 426 this->initDraw(batchTarget, dfProcessor, pipeline); |
| 425 *instancesToFlush = 0; | 427 *instancesToFlush = 0; |
| 426 | 428 |
| 427 SkDEBUGCODE(success =) atlas->addToAtlas(&id, batchTarget, width, he
ight, | 429 SkDEBUGCODE(success =) atlas->addToAtlas(&id, batchTarget, width, he
ight, |
| 428 dfStorage.get(), &atlasLoca
tion); | 430 dfStorage.get(), &atlasLoca
tion); |
| 429 SkASSERT(success); | 431 SkASSERT(success); |
| 430 | 432 |
| 431 } | 433 } |
| 432 | 434 |
| 433 // add to cache | 435 // add to cache |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // TODO remove this when batch is everywhere | 509 // TODO remove this when batch is everywhere |
| 508 GrPipelineInfo init; | 510 GrPipelineInfo init; |
| 509 init.fColorIgnored = fBatch.fColorIgnored; | 511 init.fColorIgnored = fBatch.fColorIgnored; |
| 510 init.fOverrideColor = GrColor_ILLEGAL; | 512 init.fOverrideColor = GrColor_ILLEGAL; |
| 511 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 513 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 512 init.fUsesLocalCoords = this->usesLocalCoords(); | 514 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 513 dfProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init); | 515 dfProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 514 } | 516 } |
| 515 | 517 |
| 516 void flush(GrBatchTarget* batchTarget, | 518 void flush(GrBatchTarget* batchTarget, |
| 519 const GrGeometryProcessor* dfProcessor, |
| 520 const GrPipeline* pipeline, |
| 517 GrDrawTarget::DrawInfo* drawInfo, | 521 GrDrawTarget::DrawInfo* drawInfo, |
| 518 int instanceCount, | 522 int instanceCount, |
| 519 int maxInstancesPerDraw) { | 523 int maxInstancesPerDraw) { |
| 520 while (instanceCount) { | 524 while (instanceCount) { |
| 521 drawInfo->setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw
)); | 525 drawInfo->setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw
)); |
| 522 drawInfo->setVertexCount(drawInfo->instanceCount() * drawInfo->verti
cesPerInstance()); | 526 drawInfo->setVertexCount(drawInfo->instanceCount() * drawInfo->verti
cesPerInstance()); |
| 523 drawInfo->setIndexCount(drawInfo->instanceCount() * drawInfo->indice
sPerInstance()); | 527 drawInfo->setIndexCount(drawInfo->instanceCount() * drawInfo->indice
sPerInstance()); |
| 524 | 528 |
| 525 batchTarget->draw(*drawInfo); | 529 batchTarget->draw(*drawInfo); |
| 526 | 530 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, | 611 SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color
, viewMatrix, |
| 608 fAtlas, &fPathC
ache, &fPathList)); | 612 fAtlas, &fPathC
ache, &fPathList)); |
| 609 | 613 |
| 610 SkRect bounds = path.getBounds(); | 614 SkRect bounds = path.getBounds(); |
| 611 viewMatrix.mapRect(&bounds); | 615 viewMatrix.mapRect(&bounds); |
| 612 target->drawBatch(pipelineBuilder, batch, &bounds); | 616 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 613 | 617 |
| 614 return true; | 618 return true; |
| 615 } | 619 } |
| 616 | 620 |
| OLD | NEW |