| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBatchTest.h" | 8 #include "GrBatchTest.h" |
| 9 #include "GrColor.h" | 9 #include "GrColor.h" |
| 10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
| 11 #include "GrDrawContextPriv.h" | 11 #include "GrDrawContextPriv.h" |
| 12 #include "GrDrawingManager.h" | 12 #include "GrDrawingManager.h" |
| 13 #include "GrOvalRenderer.h" | 13 #include "GrOvalRenderer.h" |
| 14 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 17 #include "GrResourceProvider.h" | 17 #include "GrResourceProvider.h" |
| 18 #include "GrInstancedRendering.h" |
| 18 #include "SkSurfacePriv.h" | 19 #include "SkSurfacePriv.h" |
| 19 | 20 |
| 20 #include "batches/GrBatch.h" | 21 #include "batches/GrBatch.h" |
| 21 #include "batches/GrDrawAtlasBatch.h" | 22 #include "batches/GrDrawAtlasBatch.h" |
| 22 #include "batches/GrDrawVerticesBatch.h" | 23 #include "batches/GrDrawVerticesBatch.h" |
| 23 #include "batches/GrRectBatchFactory.h" | 24 #include "batches/GrRectBatchFactory.h" |
| 24 #include "batches/GrNinePatch.h" // TODO Factory | 25 #include "batches/GrNinePatch.h" // TODO Factory |
| 25 | 26 |
| 26 #include "effects/GrRRectEffect.h" | 27 #include "effects/GrRRectEffect.h" |
| 27 | 28 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 : fDrawingManager(drawingMgr) | 65 : fDrawingManager(drawingMgr) |
| 65 , fRenderTarget(rt) | 66 , fRenderTarget(rt) |
| 66 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) | 67 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) |
| 67 , fContext(context) | 68 , fContext(context) |
| 68 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) | 69 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) |
| 69 , fAuditTrail(auditTrail) | 70 , fAuditTrail(auditTrail) |
| 70 #ifdef SK_DEBUG | 71 #ifdef SK_DEBUG |
| 71 , fSingleOwner(singleOwner) | 72 , fSingleOwner(singleOwner) |
| 72 #endif | 73 #endif |
| 73 { | 74 { |
| 75 fInstancedRenderingFlags = GrInstancedRendering::kColorWrite_Flag; |
| 76 if (fRenderTarget->isStencilBufferMultisampled()) { |
| 77 fInstancedRenderingFlags |= GrInstancedRendering::kStencilBufferMSAA_Fla
g; |
| 78 } |
| 79 if (fRenderTarget->isUnifiedMultisampled()) { |
| 80 fInstancedRenderingFlags |= GrInstancedRendering::kColorBufferMSAA_Flag; |
| 81 } |
| 74 SkDEBUGCODE(this->validate();) | 82 SkDEBUGCODE(this->validate();) |
| 75 } | 83 } |
| 76 | 84 |
| 77 #ifdef SK_DEBUG | 85 #ifdef SK_DEBUG |
| 78 void GrDrawContext::validate() const { | 86 void GrDrawContext::validate() const { |
| 79 SkASSERT(fRenderTarget); | 87 SkASSERT(fRenderTarget); |
| 80 ASSERT_OWNED_RESOURCE(fRenderTarget); | 88 ASSERT_OWNED_RESOURCE(fRenderTarget); |
| 81 | 89 |
| 82 if (fDrawTarget && !fDrawTarget->isClosed()) { | 90 if (fDrawTarget && !fDrawTarget->isClosed()) { |
| 83 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); | 91 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { | 256 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
| 249 return viewMatrix.preservesRightAngles(); | 257 return viewMatrix.preservesRightAngles(); |
| 250 } | 258 } |
| 251 | 259 |
| 252 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { | 260 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { |
| 253 return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); | 261 return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); |
| 254 } | 262 } |
| 255 | 263 |
| 256 GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, | 264 GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, |
| 257 const SkMatrix& viewMatrix, | 265 const SkMatrix& viewMatrix, |
| 258 const SkRect& rect) { | 266 const SkRect& rect, |
| 259 | 267 uint32_t extraInstRenderFlags, |
| 260 GrDrawBatch* batch = nullptr; | 268 bool* requireHWAA) { |
| 269 if (GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering())
{ |
| 270 if (GrDrawBatch* batch = ir->recordRect(rect, viewMatrix, paint.getColor
(), |
| 271 paint.isAntiAlias(), |
| 272 fInstancedRenderingFlags | extra
InstRenderFlags, |
| 273 requireHWAA)) { |
| 274 return batch; |
| 275 } |
| 276 } |
| 261 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 277 if (should_apply_coverage_aa(paint, fRenderTarget)) { |
| 262 // The fill path can handle rotation but not skew. | 278 // The fill path can handle rotation but not skew. |
| 263 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 279 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 264 SkRect devBoundRect; | 280 SkRect devBoundRect; |
| 265 viewMatrix.mapRect(&devBoundRect, rect); | 281 viewMatrix.mapRect(&devBoundRect, rect); |
| 266 batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatri
x, | 282 return GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix
, rect, |
| 267 rect, devBoundRect); | 283 devBoundRect); |
| 268 } | 284 } |
| 269 } else { | 285 } else { |
| 270 // filled BW rect | 286 // filled BW rect |
| 271 batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix
, rect, | 287 return GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix,
rect, nullptr, |
| 272 nullptr, nullptr); | 288 nullptr); |
| 273 } | 289 } |
| 274 | 290 |
| 275 return batch; | 291 return nullptr; |
| 276 } | 292 } |
| 277 | 293 |
| 278 void GrDrawContext::drawRect(const GrClip& clip, | 294 void GrDrawContext::drawRect(const GrClip& clip, |
| 279 const GrPaint& paint, | 295 const GrPaint& paint, |
| 280 const SkMatrix& viewMatrix, | 296 const SkMatrix& viewMatrix, |
| 281 const SkRect& rect, | 297 const SkRect& rect, |
| 282 const GrStrokeInfo* strokeInfo) { | 298 const GrStrokeInfo* strokeInfo) { |
| 283 ASSERT_SINGLE_OWNER | 299 ASSERT_SINGLE_OWNER |
| 284 RETURN_IF_ABANDONED | 300 RETURN_IF_ABANDONED |
| 285 SkDEBUGCODE(this->validate();) | 301 SkDEBUGCODE(this->validate();) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 GrColor clearColor; | 336 GrColor clearColor; |
| 321 if (paint.isConstantBlendedColor(&clearColor)) { | 337 if (paint.isConstantBlendedColor(&clearColor)) { |
| 322 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); | 338 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); |
| 323 return; | 339 return; |
| 324 } | 340 } |
| 325 } | 341 } |
| 326 } | 342 } |
| 327 } | 343 } |
| 328 | 344 |
| 329 bool snapToPixelCenters = false; | 345 bool snapToPixelCenters = false; |
| 346 bool requireHWAA = false; |
| 330 SkAutoTUnref<GrDrawBatch> batch; | 347 SkAutoTUnref<GrDrawBatch> batch; |
| 331 if (width < 0) { | 348 if (width < 0) { |
| 332 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect)); | 349 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, 0, &requireH
WAA)); |
| 333 } else { | 350 } else { |
| 334 GrColor color = paint.getColor(); | 351 GrColor color = paint.getColor(); |
| 335 | 352 |
| 336 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 353 if (should_apply_coverage_aa(paint, fRenderTarget)) { |
| 337 // The stroke path needs the rect to remain axis aligned (no rotatio
n or skew). | 354 // The stroke path needs the rect to remain axis aligned (no rotatio
n or skew). |
| 338 if (viewMatrix.rectStaysRect()) { | 355 if (viewMatrix.rectStaysRect()) { |
| 339 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix
, rect, | 356 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix
, rect, |
| 340 *strokeInfo)); | 357 *strokeInfo)); |
| 341 } | 358 } |
| 342 } else { | 359 } else { |
| 343 // Non-AA hairlines are snapped to pixel centers to make which pixel
s are hit | 360 // Non-AA hairlines are snapped to pixel centers to make which pixel
s are hit |
| 344 // deterministic | 361 // deterministic |
| 345 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa
mpled()); | 362 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa
mpled()); |
| 346 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, | 363 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, |
| 347 width, snapToPixel
Centers)); | 364 width, snapToPixel
Centers)); |
| 348 | 365 |
| 349 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of | 366 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of |
| 350 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not | 367 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not |
| 351 // when MSAA is enabled because it can cause ugly artifacts. | 368 // when MSAA is enabled because it can cause ugly artifacts. |
| 352 } | 369 } |
| 353 } | 370 } |
| 354 | 371 |
| 355 if (batch) { | 372 if (batch) { |
| 356 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 373 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip, requireHWA
A); |
| 357 | 374 |
| 358 if (snapToPixelCenters) { | 375 if (snapToPixelCenters) { |
| 359 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, | 376 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, |
| 360 snapToPixelCenters); | 377 snapToPixelCenters); |
| 361 } | 378 } |
| 362 | 379 |
| 363 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 380 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 364 return; | 381 return; |
| 365 } | 382 } |
| 366 | 383 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 382 RETURN_FALSE_IF_ABANDONED_PRIV | 399 RETURN_FALSE_IF_ABANDONED_PRIV |
| 383 SkDEBUGCODE(fDrawContext->validate();) | 400 SkDEBUGCODE(fDrawContext->validate();) |
| 384 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); | 401 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); |
| 385 | 402 |
| 386 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 403 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 387 | 404 |
| 388 GrPaint paint; | 405 GrPaint paint; |
| 389 paint.setAntiAlias(doAA); | 406 paint.setAntiAlias(doAA); |
| 390 paint.setCoverageSetOpXPFactory(op, invert); | 407 paint.setCoverageSetOpXPFactory(op, invert); |
| 391 | 408 |
| 392 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); | 409 bool requireHWAA = false; |
| 410 SkAutoTUnref<GrDrawBatch> batch( |
| 411 fDrawContext->getFillRectBatch(paint, viewMatrix, rect, |
| 412 GrInstancedRendering::kStencilWrite_Flag,
&requireHWAA)); |
| 393 if (batch) { | 413 if (batch) { |
| 394 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->fRenderTarget, Gr
Clip::WideOpen()); | 414 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->fRenderTarget, Gr
Clip::WideOpen(), |
| 415 requireHWAA); |
| 395 pipelineBuilder.setStencil(ss); | 416 pipelineBuilder.setStencil(ss); |
| 396 | 417 |
| 397 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, batch, scissor
Rect); | 418 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, batch, scissor
Rect); |
| 398 return true; | 419 return true; |
| 399 } | 420 } |
| 400 | 421 |
| 401 SkPath path; | 422 SkPath path; |
| 402 path.setIsVolatile(true); | 423 path.setIsVolatile(true); |
| 403 path.addRect(rect); | 424 path.addRect(rect); |
| 404 return this->drawAndStencilPath(scissorRect, ss, op, invert, doAA, viewMatri
x, path); | 425 return this->drawAndStencilPath(scissorRect, ss, op, invert, doAA, viewMatri
x, path); |
| 405 } | 426 } |
| 406 | 427 |
| 407 void GrDrawContext::fillRectToRect(const GrClip& clip, | 428 void GrDrawContext::fillRectToRect(const GrClip& clip, |
| 408 const GrPaint& paint, | 429 const GrPaint& paint, |
| 409 const SkMatrix& viewMatrix, | 430 const SkMatrix& viewMatrix, |
| 410 const SkRect& rectToDraw, | 431 const SkRect& rectToDraw, |
| 411 const SkRect& localRect) { | 432 const SkRect& localRect) { |
| 412 ASSERT_SINGLE_OWNER | 433 ASSERT_SINGLE_OWNER |
| 413 RETURN_IF_ABANDONED | 434 RETURN_IF_ABANDONED |
| 414 SkDEBUGCODE(this->validate();) | 435 SkDEBUGCODE(this->validate();) |
| 415 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); | 436 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); |
| 416 | 437 |
| 417 AutoCheckFlush acf(fDrawingManager); | 438 AutoCheckFlush acf(fDrawingManager); |
| 418 | 439 |
| 419 SkAutoTUnref<GrDrawBatch> batch; | 440 SkAutoTUnref<GrDrawBatch> batch; |
| 441 if (GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering())
{ |
| 442 bool requireHWAA = false; |
| 443 batch.reset(ir->recordRect(rectToDraw, viewMatrix, paint.getColor(), loc
alRect, |
| 444 paint.isAntiAlias(), fInstancedRenderingFlags
, &requireHWAA)); |
| 445 if (batch) { |
| 446 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip, requir
eHWAA); |
| 447 this->drawBatch(&pipelineBuilder, batch); |
| 448 return; |
| 449 } |
| 450 } |
| 451 |
| 420 if (should_apply_coverage_aa(paint, fRenderTarget) && | 452 if (should_apply_coverage_aa(paint, fRenderTarget) && |
| 421 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 453 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 422 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, | 454 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, |
| 423 localRect)); | 455 localRect)); |
| 424 } else { | 456 } else { |
| 425 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 457 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 426 &localRect, nullptr)); | 458 &localRect, nullptr)); |
| 427 } | 459 } |
| 428 | 460 |
| 429 if (batch) { | 461 if (batch) { |
| 430 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 462 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 431 this->drawBatch(&pipelineBuilder, batch); | 463 this->drawBatch(&pipelineBuilder, batch); |
| 432 } | 464 } |
| 433 } | 465 } |
| 434 | 466 |
| 435 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 467 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| 436 const GrPaint& paint, | 468 const GrPaint& paint, |
| 437 const SkMatrix& viewMatrix, | 469 const SkMatrix& viewMatrix, |
| 438 const SkRect& rectToDraw, | 470 const SkRect& rectToDraw, |
| 439 const SkMatrix& localMatrix) { | 471 const SkMatrix& localMatrix) { |
| 440 ASSERT_SINGLE_OWNER | 472 ASSERT_SINGLE_OWNER |
| 441 RETURN_IF_ABANDONED | 473 RETURN_IF_ABANDONED |
| 442 SkDEBUGCODE(this->validate();) | 474 SkDEBUGCODE(this->validate();) |
| 443 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); | 475 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); |
| 444 | 476 |
| 445 AutoCheckFlush acf(fDrawingManager); | 477 AutoCheckFlush acf(fDrawingManager); |
| 446 | 478 |
| 447 SkAutoTUnref<GrDrawBatch> batch; | 479 SkAutoTUnref<GrDrawBatch> batch; |
| 480 if (GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering())
{ |
| 481 bool requireHWAA = false; |
| 482 batch.reset(ir->recordRect(rectToDraw, viewMatrix, paint.getColor(), loc
alMatrix, |
| 483 paint.isAntiAlias(), fInstancedRenderingFlags
, &requireHWAA)); |
| 484 if (batch) { |
| 485 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip, requir
eHWAA); |
| 486 this->drawBatch(&pipelineBuilder, batch); |
| 487 return; |
| 488 } |
| 489 } |
| 490 |
| 448 if (should_apply_coverage_aa(paint, fRenderTarget) && | 491 if (should_apply_coverage_aa(paint, fRenderTarget) && |
| 449 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 492 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 450 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, | 493 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, |
| 451 rectToDraw)); | 494 rectToDraw)); |
| 452 } else { | 495 } else { |
| 453 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 496 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 454 nullptr, &localMatrix)); | 497 nullptr, &localMatrix)); |
| 455 } | 498 } |
| 456 | 499 |
| 457 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 500 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); | 584 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); |
| 542 | 585 |
| 543 if (rrect.isEmpty()) { | 586 if (rrect.isEmpty()) { |
| 544 return; | 587 return; |
| 545 } | 588 } |
| 546 | 589 |
| 547 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice | 590 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice |
| 548 | 591 |
| 549 AutoCheckFlush acf(fDrawingManager); | 592 AutoCheckFlush acf(fDrawingManager); |
| 550 | 593 |
| 594 if (this->getDrawTarget()->instancedRendering() && strokeInfo.isFillStyle())
{ |
| 595 GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering(); |
| 596 bool requireHWAA = false; |
| 597 SkAutoTUnref<GrDrawBatch> batch(ir->recordRRect(rrect, viewMatrix, paint
.getColor(), |
| 598 paint.isAntiAlias(), |
| 599 fInstancedRenderingFlags
, &requireHWAA)); |
| 600 if (batch) { |
| 601 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip, requir
eHWAA); |
| 602 this->drawBatch(&pipelineBuilder, batch); |
| 603 return; |
| 604 } |
| 605 } |
| 606 |
| 551 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 607 if (should_apply_coverage_aa(paint, fRenderTarget)) { |
| 552 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 608 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 553 | 609 |
| 554 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), | 610 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), |
| 555 viewMat
rix, | 611 viewMat
rix, |
| 556 rrect, | 612 rrect, |
| 557 strokeI
nfo, | 613 strokeI
nfo, |
| 558 shaderC
aps)); | 614 shaderC
aps)); |
| 559 if (batch) { | 615 if (batch) { |
| 560 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 616 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 561 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 617 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 562 return; | 618 return; |
| 563 } | 619 } |
| 564 } | 620 } |
| 565 | 621 |
| 566 SkPath path; | 622 SkPath path; |
| 567 path.setIsVolatile(true); | 623 path.setIsVolatile(true); |
| 568 path.addRRect(rrect); | 624 path.addRRect(rrect); |
| 569 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); | 625 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); |
| 570 } | 626 } |
| 571 | 627 |
| 572 bool GrDrawContext::drawFilledDRRect(const GrClip& clip, | 628 bool GrDrawContext::drawFilledDRRect(const GrClip& clip, |
| 573 const GrPaint& paintIn, | 629 const GrPaint& paintIn, |
| 574 const SkMatrix& viewMatrix, | 630 const SkMatrix& viewMatrix, |
| 575 const SkRRect& origOuter, | 631 const SkRRect& origOuter, |
| 576 const SkRRect& origInner) { | 632 const SkRRect& origInner) { |
| 577 SkASSERT(!origInner.isEmpty()); | 633 SkASSERT(!origInner.isEmpty()); |
| 578 SkASSERT(!origOuter.isEmpty()); | 634 SkASSERT(!origOuter.isEmpty()); |
| 579 | 635 |
| 636 if (GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering())
{ |
| 637 bool requireHWAA = false; |
| 638 SkAutoTUnref<GrDrawBatch> batch(ir->recordDRRect(origOuter, origInner, v
iewMatrix, |
| 639 paintIn.getColor(), pai
ntIn.isAntiAlias(), |
| 640 fInstancedRenderingFlag
s, &requireHWAA)); |
| 641 if (batch) { |
| 642 GrPipelineBuilder pipelineBuilder(paintIn, fRenderTarget, clip, requ
ireHWAA); |
| 643 this->drawBatch(&pipelineBuilder, batch); |
| 644 return true; |
| 645 } |
| 646 } |
| 647 |
| 580 bool applyAA = paintIn.isAntiAlias() && !fRenderTarget->isUnifiedMultisample
d(); | 648 bool applyAA = paintIn.isAntiAlias() && !fRenderTarget->isUnifiedMultisample
d(); |
| 581 | 649 |
| 582 GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdge
Type : | 650 GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdge
Type : |
| 583 kInverseFillBW_GrProcessorEdge
Type; | 651 kInverseFillBW_GrProcessorEdge
Type; |
| 584 GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType : | 652 GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
| 585 kFillBW_GrProcessorEdgeType; | 653 kFillBW_GrProcessorEdgeType; |
| 586 | 654 |
| 587 SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter); | 655 SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter); |
| 588 SkMatrix inverseVM; | 656 SkMatrix inverseVM; |
| 589 if (!viewMatrix.isIdentity()) { | 657 if (!viewMatrix.isIdentity()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); | 736 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); |
| 669 | 737 |
| 670 if (oval.isEmpty()) { | 738 if (oval.isEmpty()) { |
| 671 return; | 739 return; |
| 672 } | 740 } |
| 673 | 741 |
| 674 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice | 742 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice |
| 675 | 743 |
| 676 AutoCheckFlush acf(fDrawingManager); | 744 AutoCheckFlush acf(fDrawingManager); |
| 677 | 745 |
| 746 if (this->getDrawTarget()->instancedRendering() && strokeInfo.isFillStyle())
{ |
| 747 GrInstancedRendering* ir = this->getDrawTarget()->instancedRendering(); |
| 748 bool requireHWAA = false; |
| 749 SkAutoTUnref<GrDrawBatch> batch(ir->recordOval(oval, viewMatrix, paint.g
etColor(), |
| 750 paint.isAntiAlias(), |
| 751 fInstancedRenderingFlags,
&requireHWAA)); |
| 752 if (batch) { |
| 753 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip, requir
eHWAA); |
| 754 this->drawBatch(&pipelineBuilder, batch); |
| 755 return; |
| 756 } |
| 757 } |
| 758 |
| 678 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 759 if (should_apply_coverage_aa(paint, fRenderTarget)) { |
| 679 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 760 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 680 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), | 761 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), |
| 681 viewMatr
ix, | 762 viewMatr
ix, |
| 682 oval, | 763 oval, |
| 683 strokeIn
fo, | 764 strokeIn
fo, |
| 684 shaderCa
ps)); | 765 shaderCa
ps)); |
| 685 if (batch) { | 766 if (batch) { |
| 686 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 767 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 687 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 768 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 } | 1112 } |
| 1032 | 1113 |
| 1033 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 1114 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
| 1034 ASSERT_SINGLE_OWNER | 1115 ASSERT_SINGLE_OWNER |
| 1035 RETURN_IF_ABANDONED | 1116 RETURN_IF_ABANDONED |
| 1036 SkDEBUGCODE(this->validate();) | 1117 SkDEBUGCODE(this->validate();) |
| 1037 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1118 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 1038 | 1119 |
| 1039 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 1120 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
| 1040 } | 1121 } |
| OLD | NEW |