| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 drawState, | 357 drawState, |
| 358 &primType, | 358 &primType, |
| 359 &vertexCnt, | 359 &vertexCnt, |
| 360 &indexCnt, | 360 &indexCnt, |
| 361 &arg, | 361 &arg, |
| 362 path, | 362 path, |
| 363 *stroke, | 363 *stroke, |
| 364 tol)) { | 364 tol)) { |
| 365 return false; | 365 return false; |
| 366 } | 366 } |
| 367 | 367 // Save the current xp on the draw state so we can reset it if needed |
| 368 bool colorWritesWereDisabled = drawState->isColorWriteDisabled(); | 368 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkRef(drawState->getXPFactor
y())); |
| 369 // face culling doesn't make sense here | 369 // face culling doesn't make sense here |
| 370 SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace()); | 370 SkASSERT(GrDrawState::kBoth_DrawFace == drawState->getDrawFace()); |
| 371 | 371 |
| 372 int passCount = 0; | 372 int passCount = 0; |
| 373 const GrStencilSettings* passes[3]; | 373 const GrStencilSettings* passes[3]; |
| 374 GrDrawState::DrawFace drawFace[3]; | 374 GrDrawState::DrawFace drawFace[3]; |
| 375 bool reverse = false; | 375 bool reverse = false; |
| 376 bool lastPassIsBounds; | 376 bool lastPassIsBounds; |
| 377 | 377 |
| 378 if (stroke->isHairlineStyle()) { | 378 if (stroke->isHairlineStyle()) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 SkRect devBounds; | 464 SkRect devBounds; |
| 465 GetPathDevBounds(path, drawState->getRenderTarget(), viewM, &devBounds); | 465 GetPathDevBounds(path, drawState->getRenderTarget(), viewM, &devBounds); |
| 466 | 466 |
| 467 for (int p = 0; p < passCount; ++p) { | 467 for (int p = 0; p < passCount; ++p) { |
| 468 drawState->setDrawFace(drawFace[p]); | 468 drawState->setDrawFace(drawFace[p]); |
| 469 if (passes[p]) { | 469 if (passes[p]) { |
| 470 *drawState->stencil() = *passes[p]; | 470 *drawState->stencil() = *passes[p]; |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (lastPassIsBounds && (p == passCount-1)) { | 473 if (lastPassIsBounds && (p == passCount-1)) { |
| 474 if (!colorWritesWereDisabled) { | 474 // Reset the XP Factory on drawState |
| 475 drawState->disableState(GrDrawState::kNoColorWrites_StateBit); | 475 drawState->setXPFactory(backupXPFactory); |
| 476 } | |
| 477 SkRect bounds; | 476 SkRect bounds; |
| 478 GrDrawState::AutoViewMatrixRestore avmr; | 477 GrDrawState::AutoViewMatrixRestore avmr; |
| 479 if (reverse) { | 478 if (reverse) { |
| 480 SkASSERT(drawState->getRenderTarget()); | 479 SkASSERT(drawState->getRenderTarget()); |
| 481 // draw over the dev bounds (which will be the whole dst surface
for inv fill). | 480 // draw over the dev bounds (which will be the whole dst surface
for inv fill). |
| 482 bounds = devBounds; | 481 bounds = devBounds; |
| 483 SkMatrix vmi; | 482 SkMatrix vmi; |
| 484 // mapRect through persp matrix may not be correct | 483 // mapRect through persp matrix may not be correct |
| 485 if (!drawState->getViewMatrix().hasPerspective() && | 484 if (!drawState->getViewMatrix().hasPerspective() && |
| 486 drawState->getViewInverse(&vmi)) { | 485 drawState->getViewInverse(&vmi)) { |
| 487 vmi.mapRect(&bounds); | 486 vmi.mapRect(&bounds); |
| 488 } else { | 487 } else { |
| 489 avmr.setIdentity(drawState); | 488 avmr.setIdentity(drawState); |
| 490 } | 489 } |
| 491 } else { | 490 } else { |
| 492 bounds = path.getBounds(); | 491 bounds = path.getBounds(); |
| 493 } | 492 } |
| 494 GrDrawTarget::AutoGeometryPush agp(target); | 493 GrDrawTarget::AutoGeometryPush agp(target); |
| 495 target->drawSimpleRect(drawState, color, bounds); | 494 target->drawSimpleRect(drawState, color, bounds); |
| 496 } else { | 495 } else { |
| 497 if (passCount > 1) { | 496 if (passCount > 1) { |
| 498 drawState->enableState(GrDrawState::kNoColorWrites_StateBit); | 497 drawState->setDisableColorXPFactory(); |
| 499 } | 498 } |
| 500 GrDrawState::AutoRestoreEffects are(drawState); | 499 GrDrawState::AutoRestoreEffects are(drawState); |
| 501 SkAutoTUnref<const GrGeometryProcessor> gp( | 500 SkAutoTUnref<const GrGeometryProcessor> gp( |
| 502 GrDefaultGeoProcFactory::Create(color, | 501 GrDefaultGeoProcFactory::Create(color, |
| 503 GrDefaultGeoProcFactory::kPo
sition_GPType, | 502 GrDefaultGeoProcFactory::kPo
sition_GPType, |
| 504 false, | 503 false, |
| 505 newCoverage)); | 504 newCoverage)); |
| 506 if (indexCnt) { | 505 if (indexCnt) { |
| 507 target->drawIndexed(drawState, | 506 target->drawIndexed(drawState, |
| 508 gp, | 507 gp, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } | 546 } |
| 548 | 547 |
| 549 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, | 548 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
| 550 GrDrawState* drawState, | 549 GrDrawState* drawState, |
| 551 const SkPath& path, | 550 const SkPath& path, |
| 552 const SkStrokeRec& stroke) { | 551 const SkStrokeRec& stroke) { |
| 553 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); | 552 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
| 554 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); | 553 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
| 555 this->internalDrawPath(target, drawState, GrColor_WHITE, path, stroke, true)
; | 554 this->internalDrawPath(target, drawState, GrColor_WHITE, path, stroke, true)
; |
| 556 } | 555 } |
| OLD | NEW |