| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil
erp_FilterMode); | 191 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil
erp_FilterMode); |
| 192 | 192 |
| 193 // Setup GrGeometryProcessor | 193 // Setup GrGeometryProcessor |
| 194 GrBatchAtlas* atlas = fAtlas; | 194 GrBatchAtlas* atlas = fAtlas; |
| 195 SkAutoTUnref<GrGeometryProcessor> dfProcessor( | 195 SkAutoTUnref<GrGeometryProcessor> dfProcessor( |
| 196 GrDistanceFieldPathGeoProc::Create(this->color(), | 196 GrDistanceFieldPathGeoProc::Create(this->color(), |
| 197 this->viewMatrix(), | 197 this->viewMatrix(), |
| 198 atlas->getTexture(), | 198 atlas->getTexture(), |
| 199 params, | 199 params, |
| 200 flags)); | 200 flags, |
| 201 this->usesLocalCoords())); |
| 201 | 202 |
| 202 this->initDraw(batchTarget, dfProcessor, pipeline); | 203 batchTarget->initDraw(dfProcessor, pipeline); |
| 203 | 204 |
| 204 FlushInfo flushInfo; | 205 FlushInfo flushInfo; |
| 205 | 206 |
| 206 // allocate vertices | 207 // allocate vertices |
| 207 size_t vertexStride = dfProcessor->getVertexStride(); | 208 size_t vertexStride = dfProcessor->getVertexStride(); |
| 208 SkASSERT(vertexStride == 2 * sizeof(SkPoint)); | 209 SkASSERT(vertexStride == 2 * sizeof(SkPoint)); |
| 209 | 210 |
| 210 const GrVertexBuffer* vertexBuffer; | 211 const GrVertexBuffer* vertexBuffer; |
| 211 void* vertices = batchTarget->makeVertSpace(vertexStride, | 212 void* vertices = batchTarget->makeVertSpace(vertexStride, |
| 212 kVerticesPerQuad * instanceC
ount, | 213 kVerticesPerQuad * instanceC
ount, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 bmp.width(), bmp.height(), bmp.ro
wBytes()); | 408 bmp.width(), bmp.height(), bmp.ro
wBytes()); |
| 408 } | 409 } |
| 409 | 410 |
| 410 // add to atlas | 411 // add to atlas |
| 411 SkIPoint16 atlasLocation; | 412 SkIPoint16 atlasLocation; |
| 412 GrBatchAtlas::AtlasID id; | 413 GrBatchAtlas::AtlasID id; |
| 413 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor
age.get(), | 414 bool success = atlas->addToAtlas(&id, batchTarget, width, height, dfStor
age.get(), |
| 414 &atlasLocation); | 415 &atlasLocation); |
| 415 if (!success) { | 416 if (!success) { |
| 416 this->flush(batchTarget, flushInfo); | 417 this->flush(batchTarget, flushInfo); |
| 417 this->initDraw(batchTarget, dfProcessor, pipeline); | 418 batchTarget->initDraw(dfProcessor, pipeline); |
| 418 | 419 |
| 419 SkDEBUGCODE(success =) atlas->addToAtlas(&id, batchTarget, width, he
ight, | 420 SkDEBUGCODE(success =) atlas->addToAtlas(&id, batchTarget, width, he
ight, |
| 420 dfStorage.get(), &atlasLoca
tion); | 421 dfStorage.get(), &atlasLoca
tion); |
| 421 SkASSERT(success); | 422 SkASSERT(success); |
| 422 | 423 |
| 423 } | 424 } |
| 424 | 425 |
| 425 // add to cache | 426 // add to cache |
| 426 pathData->fKey.fGenID = path.getGenerationID(); | 427 pathData->fKey.fGenID = path.getGenerationID(); |
| 427 pathData->fKey.fDimension = dimension; | 428 pathData->fKey.fDimension = dimension; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 485 |
| 485 // vertex texture coords | 486 // vertex texture coords |
| 486 SkPoint* textureCoords = positions + 1; | 487 SkPoint* textureCoords = positions + 1; |
| 487 textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normaliz
eFixedX(tx)), | 488 textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normaliz
eFixedX(tx)), |
| 488 SkFixedToFloat(texture->texturePriv().normaliz
eFixedY(ty)), | 489 SkFixedToFloat(texture->texturePriv().normaliz
eFixedY(ty)), |
| 489 SkFixedToFloat(texture->texturePriv().normaliz
eFixedX(tx + tw)), | 490 SkFixedToFloat(texture->texturePriv().normaliz
eFixedX(tx + tw)), |
| 490 SkFixedToFloat(texture->texturePriv().normaliz
eFixedY(ty + th)), | 491 SkFixedToFloat(texture->texturePriv().normaliz
eFixedY(ty + th)), |
| 491 vertexStride); | 492 vertexStride); |
| 492 } | 493 } |
| 493 | 494 |
| 494 void initDraw(GrBatchTarget* batchTarget, | |
| 495 const GrGeometryProcessor* dfProcessor, | |
| 496 const GrPipeline* pipeline) { | |
| 497 batchTarget->initDraw(dfProcessor, pipeline); | |
| 498 | |
| 499 // TODO remove this when batch is everywhere | |
| 500 GrPipelineInfo init; | |
| 501 init.fColorIgnored = fBatch.fColorIgnored; | |
| 502 init.fOverrideColor = GrColor_ILLEGAL; | |
| 503 init.fCoverageIgnored = fBatch.fCoverageIgnored; | |
| 504 init.fUsesLocalCoords = this->usesLocalCoords(); | |
| 505 dfProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init); | |
| 506 } | |
| 507 | |
| 508 void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) { | 495 void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) { |
| 509 GrVertices vertices; | 496 GrVertices vertices; |
| 510 int maxInstancesPerDraw = flushInfo->fIndexBuffer->maxQuads(); | 497 int maxInstancesPerDraw = flushInfo->fIndexBuffer->maxQuads(); |
| 511 vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuf
fer, | 498 vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuf
fer, |
| 512 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad, | 499 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad, |
| 513 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw); | 500 kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw); |
| 514 batchTarget->draw(vertices); | 501 batchTarget->draw(vertices); |
| 515 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl
ush; | 502 flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFl
ush; |
| 516 flushInfo->fInstancesToFlush = 0; | 503 flushInfo->fInstancesToFlush = 0; |
| 517 } | 504 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 geometry.fPath = GrTest::TestPath(random); | 658 geometry.fPath = GrTest::TestPath(random); |
| 672 geometry.fAntiAlias = random->nextBool(); | 659 geometry.fAntiAlias = random->nextBool(); |
| 673 | 660 |
| 674 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, | 661 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, |
| 675 gTestStruct.fAtlas, | 662 gTestStruct.fAtlas, |
| 676 &gTestStruct.fPathCache, | 663 &gTestStruct.fPathCache, |
| 677 &gTestStruct.fPathList); | 664 &gTestStruct.fPathList); |
| 678 } | 665 } |
| 679 | 666 |
| 680 #endif | 667 #endif |
| OLD | NEW |