| 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 | 9 |
| 10 #include "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
| 11 #include "effects/GrDashingEffect.h" | 11 #include "effects/GrDashingEffect.h" |
| 12 #include "effects/GrTextureDomain.h" | 12 #include "effects/GrTextureDomain.h" |
| 13 #include "effects/GrSimpleTextureEffect.h" | 13 #include "effects/GrSimpleTextureEffect.h" |
| 14 | 14 |
| 15 #include "GrContext.h" | 15 #include "GrContext.h" |
| 16 #include "GrBitmapTextContext.h" | 16 #include "GrBitmapTextContext.h" |
| 17 #include "GrDistanceFieldTextContext.h" | 17 #include "GrDistanceFieldTextContext.h" |
| 18 #include "GrLayerCache.h" | 18 #include "GrLayerCache.h" |
| 19 #include "GrPictureUtils.h" | 19 #include "GrPictureUtils.h" |
| 20 #include "GrStrokeInfo.h" |
| 20 | 21 |
| 21 #include "SkGrTexturePixelRef.h" | 22 #include "SkGrTexturePixelRef.h" |
| 22 | 23 |
| 23 #include "SkDeviceImageFilterProxy.h" | 24 #include "SkDeviceImageFilterProxy.h" |
| 24 #include "SkDrawProcs.h" | 25 #include "SkDrawProcs.h" |
| 25 #include "SkGlyphCache.h" | 26 #include "SkGlyphCache.h" |
| 26 #include "SkImageFilter.h" | 27 #include "SkImageFilter.h" |
| 27 #include "SkMaskFilter.h" | 28 #include "SkMaskFilter.h" |
| 28 #include "SkPathEffect.h" | 29 #include "SkPathEffect.h" |
| 29 #include "SkPicture.h" | 30 #include "SkPicture.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 SkScalar width = paint.getStrokeWidth(); | 431 SkScalar width = paint.getStrokeWidth(); |
| 431 | 432 |
| 432 /* | 433 /* |
| 433 We have special code for hairline strokes, miter-strokes, bevel-stroke | 434 We have special code for hairline strokes, miter-strokes, bevel-stroke |
| 434 and fills. Anything else we just call our path code. | 435 and fills. Anything else we just call our path code. |
| 435 */ | 436 */ |
| 436 bool usePath = doStroke && width > 0 && | 437 bool usePath = doStroke && width > 0 && |
| 437 (paint.getStrokeJoin() == SkPaint::kRound_Join || | 438 (paint.getStrokeJoin() == SkPaint::kRound_Join || |
| 438 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); | 439 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); |
| 439 // another two reasons we might need to call drawPath... | 440 // another two reasons we might need to call drawPath... |
| 440 if (paint.getMaskFilter() || paint.getPathEffect()) { | 441 |
| 442 if (paint.getMaskFilter()) { |
| 441 usePath = true; | 443 usePath = true; |
| 442 } | 444 } |
| 445 |
| 443 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { | 446 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { |
| 444 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 447 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 445 if (doStroke) { | 448 if (doStroke) { |
| 446 #endif | 449 #endif |
| 447 usePath = true; | 450 usePath = true; |
| 448 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 451 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 449 } else { | 452 } else { |
| 450 usePath = !fContext->getMatrix().preservesRightAngles(); | 453 usePath = !fContext->getMatrix().preservesRightAngles(); |
| 451 } | 454 } |
| 452 #endif | 455 #endif |
| 453 } | 456 } |
| 454 // until we can both stroke and fill rectangles | 457 // until we can both stroke and fill rectangles |
| 455 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { | 458 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { |
| 456 usePath = true; | 459 usePath = true; |
| 457 } | 460 } |
| 458 | 461 |
| 462 GrStrokeInfo strokeInfo(paint); |
| 463 |
| 464 const SkPathEffect* pe = paint.getPathEffect(); |
| 465 if (!usePath && NULL != pe && !strokeInfo.isDashed()) { |
| 466 usePath = true; |
| 467 } |
| 468 |
| 459 if (usePath) { | 469 if (usePath) { |
| 460 SkPath path; | 470 SkPath path; |
| 461 path.addRect(rect); | 471 path.addRect(rect); |
| 462 this->drawPath(draw, path, paint, NULL, true); | 472 this->drawPath(draw, path, paint, NULL, true); |
| 463 return; | 473 return; |
| 464 } | 474 } |
| 465 | 475 |
| 466 GrPaint grPaint; | 476 GrPaint grPaint; |
| 467 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 477 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 468 | 478 |
| 469 if (!doStroke) { | 479 fContext->drawRect(grPaint, rect, &strokeInfo); |
| 470 fContext->drawRect(grPaint, rect); | |
| 471 } else { | |
| 472 SkStrokeRec stroke(paint); | |
| 473 fContext->drawRect(grPaint, rect, &stroke); | |
| 474 } | |
| 475 } | 480 } |
| 476 | 481 |
| 477 /////////////////////////////////////////////////////////////////////////////// | 482 /////////////////////////////////////////////////////////////////////////////// |
| 478 | 483 |
| 479 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 484 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 480 const SkPaint& paint) { | 485 const SkPaint& paint) { |
| 481 CHECK_FOR_ANNOTATION(paint); | 486 CHECK_FOR_ANNOTATION(paint); |
| 482 CHECK_SHOULD_DRAW(draw, false); | 487 CHECK_SHOULD_DRAW(draw, false); |
| 483 | 488 |
| 484 GrPaint grPaint; | 489 GrPaint grPaint; |
| 485 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 490 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 486 | 491 |
| 487 SkStrokeRec stroke(paint); | 492 GrStrokeInfo strokeInfo(paint); |
| 488 if (paint.getMaskFilter()) { | 493 if (paint.getMaskFilter()) { |
| 489 // try to hit the fast path for drawing filtered round rects | 494 // try to hit the fast path for drawing filtered round rects |
| 490 | 495 |
| 491 SkRRect devRRect; | 496 SkRRect devRRect; |
| 492 if (rect.transform(fContext->getMatrix(), &devRRect)) { | 497 if (rect.transform(fContext->getMatrix(), &devRRect)) { |
| 493 if (devRRect.allCornersCircular()) { | 498 if (devRRect.allCornersCircular()) { |
| 494 SkRect maskRect; | 499 SkRect maskRect; |
| 495 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), | 500 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), |
| 496 draw.fClip->getBounds(), | 501 draw.fClip->getBounds(), |
| 497 fContext->getMatrix(), | 502 fContext->getMatrix(), |
| 498 &maskRect)) { | 503 &maskRect)) { |
| 499 SkIRect finalIRect; | 504 SkIRect finalIRect; |
| 500 maskRect.roundOut(&finalIRect); | 505 maskRect.roundOut(&finalIRect); |
| 501 if (draw.fClip->quickReject(finalIRect)) { | 506 if (draw.fClip->quickReject(finalIRect)) { |
| 502 // clipped out | 507 // clipped out |
| 503 return; | 508 return; |
| 504 } | 509 } |
| 505 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, | 510 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, |
| 506 stroke,
devRRect)) { | 511 strokeIn
fo.getStrokeRec(), |
| 512 devRRect
)) { |
| 507 return; | 513 return; |
| 508 } | 514 } |
| 509 } | 515 } |
| 510 | 516 |
| 511 } | 517 } |
| 512 } | 518 } |
| 513 | 519 |
| 514 } | 520 } |
| 515 | 521 |
| 516 if (paint.getMaskFilter() || paint.getPathEffect()) { | 522 bool usePath = false; |
| 523 |
| 524 if (paint.getMaskFilter()) { |
| 525 usePath = true; |
| 526 } else { |
| 527 const SkPathEffect* pe = paint.getPathEffect(); |
| 528 if (NULL != pe && !strokeInfo.isDashed()) { |
| 529 usePath = true; |
| 530 } |
| 531 } |
| 532 |
| 533 |
| 534 if (usePath) { |
| 517 SkPath path; | 535 SkPath path; |
| 518 path.addRRect(rect); | 536 path.addRRect(rect); |
| 519 this->drawPath(draw, path, paint, NULL, true); | 537 this->drawPath(draw, path, paint, NULL, true); |
| 520 return; | 538 return; |
| 521 } | 539 } |
| 522 | 540 |
| 523 fContext->drawRRect(grPaint, rect, stroke); | 541 fContext->drawRRect(grPaint, rect, strokeInfo); |
| 524 } | 542 } |
| 525 | 543 |
| 526 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 544 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 527 const SkRRect& inner, const SkPaint& paint) { | 545 const SkRRect& inner, const SkPaint& paint) { |
| 528 SkStrokeRec stroke(paint); | 546 SkStrokeRec stroke(paint); |
| 529 if (stroke.isFillStyle()) { | 547 if (stroke.isFillStyle()) { |
| 530 | 548 |
| 531 CHECK_FOR_ANNOTATION(paint); | 549 CHECK_FOR_ANNOTATION(paint); |
| 532 CHECK_SHOULD_DRAW(draw, false); | 550 CHECK_SHOULD_DRAW(draw, false); |
| 533 | 551 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 549 } | 567 } |
| 550 | 568 |
| 551 | 569 |
| 552 ///////////////////////////////////////////////////////////////////////////// | 570 ///////////////////////////////////////////////////////////////////////////// |
| 553 | 571 |
| 554 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, | 572 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| 555 const SkPaint& paint) { | 573 const SkPaint& paint) { |
| 556 CHECK_FOR_ANNOTATION(paint); | 574 CHECK_FOR_ANNOTATION(paint); |
| 557 CHECK_SHOULD_DRAW(draw, false); | 575 CHECK_SHOULD_DRAW(draw, false); |
| 558 | 576 |
| 577 GrStrokeInfo strokeInfo(paint); |
| 578 |
| 559 bool usePath = false; | 579 bool usePath = false; |
| 560 // some basic reasons we might need to call drawPath... | 580 // some basic reasons we might need to call drawPath... |
| 561 if (paint.getMaskFilter() || paint.getPathEffect()) { | 581 if (paint.getMaskFilter()) { |
| 562 usePath = true; | 582 usePath = true; |
| 583 } else { |
| 584 const SkPathEffect* pe = paint.getPathEffect(); |
| 585 if (NULL != pe && !strokeInfo.isDashed()) { |
| 586 usePath = true; |
| 587 } |
| 563 } | 588 } |
| 564 | 589 |
| 565 if (usePath) { | 590 if (usePath) { |
| 566 SkPath path; | 591 SkPath path; |
| 567 path.addOval(oval); | 592 path.addOval(oval); |
| 568 this->drawPath(draw, path, paint, NULL, true); | 593 this->drawPath(draw, path, paint, NULL, true); |
| 569 return; | 594 return; |
| 570 } | 595 } |
| 571 | 596 |
| 572 GrPaint grPaint; | 597 GrPaint grPaint; |
| 573 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 598 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 574 SkStrokeRec stroke(paint); | |
| 575 | 599 |
| 576 fContext->drawOval(grPaint, oval, stroke); | 600 fContext->drawOval(grPaint, oval, strokeInfo); |
| 577 } | 601 } |
| 578 | 602 |
| 579 #include "SkMaskFilter.h" | 603 #include "SkMaskFilter.h" |
| 580 | 604 |
| 581 /////////////////////////////////////////////////////////////////////////////// | 605 /////////////////////////////////////////////////////////////////////////////// |
| 582 | 606 |
| 583 // helpers for applying mask filters | 607 // helpers for applying mask filters |
| 584 namespace { | 608 namespace { |
| 585 | 609 |
| 586 // Draw a mask using the supplied paint. Since the coverage/geometry | 610 // Draw a mask using the supplied paint. Since the coverage/geometry |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 SkRect maskRect = SkRect::Make(dstM.fBounds); | 666 SkRect maskRect = SkRect::Make(dstM.fBounds); |
| 643 | 667 |
| 644 return draw_mask(context, maskRect, grp, texture); | 668 return draw_mask(context, maskRect, grp, texture); |
| 645 } | 669 } |
| 646 | 670 |
| 647 // Create a mask of 'devPath' and place the result in 'mask'. Return true on | 671 // Create a mask of 'devPath' and place the result in 'mask'. Return true on |
| 648 // success; false otherwise. | 672 // success; false otherwise. |
| 649 bool create_mask_GPU(GrContext* context, | 673 bool create_mask_GPU(GrContext* context, |
| 650 const SkRect& maskRect, | 674 const SkRect& maskRect, |
| 651 const SkPath& devPath, | 675 const SkPath& devPath, |
| 652 const SkStrokeRec& stroke, | 676 const GrStrokeInfo& strokeInfo, |
| 653 bool doAA, | 677 bool doAA, |
| 654 GrAutoScratchTexture* mask) { | 678 GrAutoScratchTexture* mask) { |
| 655 GrTextureDesc desc; | 679 GrTextureDesc desc; |
| 656 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 680 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 657 desc.fWidth = SkScalarCeilToInt(maskRect.width()); | 681 desc.fWidth = SkScalarCeilToInt(maskRect.width()); |
| 658 desc.fHeight = SkScalarCeilToInt(maskRect.height()); | 682 desc.fHeight = SkScalarCeilToInt(maskRect.height()); |
| 659 // We actually only need A8, but it often isn't supported as a | 683 // We actually only need A8, but it often isn't supported as a |
| 660 // render target so default to RGBA_8888 | 684 // render target so default to RGBA_8888 |
| 661 desc.fConfig = kRGBA_8888_GrPixelConfig; | 685 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 662 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 686 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 687 // use a zero dst coeff when dual source blending isn't available. | 711 // use a zero dst coeff when dual source blending isn't available. |
| 688 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); | 712 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); |
| 689 } | 713 } |
| 690 | 714 |
| 691 GrContext::AutoMatrix am; | 715 GrContext::AutoMatrix am; |
| 692 | 716 |
| 693 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 717 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
| 694 SkMatrix translate; | 718 SkMatrix translate; |
| 695 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 719 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
| 696 am.set(context, translate); | 720 am.set(context, translate); |
| 697 context->drawPath(tempPaint, devPath, stroke); | 721 context->drawPath(tempPaint, devPath, strokeInfo); |
| 698 return true; | 722 return true; |
| 699 } | 723 } |
| 700 | 724 |
| 701 SkBitmap wrap_texture(GrTexture* texture) { | 725 SkBitmap wrap_texture(GrTexture* texture) { |
| 702 SkBitmap result; | 726 SkBitmap result; |
| 703 result.setInfo(texture->info()); | 727 result.setInfo(texture->info()); |
| 704 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); | 728 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); |
| 705 return result; | 729 return result; |
| 706 } | 730 } |
| 707 | 731 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 731 pathIsMutable = true; | 755 pathIsMutable = true; |
| 732 } | 756 } |
| 733 // should I push prePathMatrix on our MV stack temporarily, instead | 757 // should I push prePathMatrix on our MV stack temporarily, instead |
| 734 // of applying it here? See SkDraw.cpp | 758 // of applying it here? See SkDraw.cpp |
| 735 pathPtr->transform(*prePathMatrix, result); | 759 pathPtr->transform(*prePathMatrix, result); |
| 736 pathPtr = result; | 760 pathPtr = result; |
| 737 } | 761 } |
| 738 // at this point we're done with prePathMatrix | 762 // at this point we're done with prePathMatrix |
| 739 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 763 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 740 | 764 |
| 741 SkStrokeRec stroke(paint); | 765 GrStrokeInfo strokeInfo(paint); |
| 742 SkPathEffect* pathEffect = paint.getPathEffect(); | 766 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 743 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 767 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 744 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &strok
e, | 768 SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); |
| 769 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, stroke
Ptr, |
| 745 cullRect)) { | 770 cullRect)) { |
| 746 pathPtr = effectPath.get(); | 771 pathPtr = effectPath.get(); |
| 747 pathIsMutable = true; | 772 pathIsMutable = true; |
| 773 strokeInfo.removeDash(); |
| 748 } | 774 } |
| 749 | 775 |
| 776 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
| 750 if (paint.getMaskFilter()) { | 777 if (paint.getMaskFilter()) { |
| 751 if (!stroke.isHairlineStyle()) { | 778 if (!stroke.isHairlineStyle()) { |
| 752 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); | 779 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); |
| 753 if (stroke.applyToPath(strokedPath, *pathPtr)) { | 780 if (stroke.applyToPath(strokedPath, *pathPtr)) { |
| 754 pathPtr = strokedPath; | 781 pathPtr = strokedPath; |
| 755 pathIsMutable = true; | 782 pathIsMutable = true; |
| 756 stroke.setFillStyle(); | 783 strokeInfo.setFillStyle(); |
| 757 } | 784 } |
| 758 } | 785 } |
| 759 | 786 |
| 760 // avoid possibly allocating a new path in transform if we can | 787 // avoid possibly allocating a new path in transform if we can |
| 761 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); | 788 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); |
| 762 | 789 |
| 763 // transform the path into device space | 790 // transform the path into device space |
| 764 pathPtr->transform(fContext->getMatrix(), devPathPtr); | 791 pathPtr->transform(fContext->getMatrix(), devPathPtr); |
| 765 | 792 |
| 766 SkRect maskRect; | 793 SkRect maskRect; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 781 | 808 |
| 782 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, | 809 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, |
| 783 stroke, *devPathPtr))
{ | 810 stroke, *devPathPtr))
{ |
| 784 // the mask filter was able to draw itself directly, so there's
nothing | 811 // the mask filter was able to draw itself directly, so there's
nothing |
| 785 // left to do. | 812 // left to do. |
| 786 return; | 813 return; |
| 787 } | 814 } |
| 788 | 815 |
| 789 GrAutoScratchTexture mask; | 816 GrAutoScratchTexture mask; |
| 790 | 817 |
| 791 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, | 818 if (create_mask_GPU(fContext, maskRect, *devPathPtr, strokeInfo, |
| 792 grPaint.isAntiAlias(), &mask)) { | 819 grPaint.isAntiAlias(), &mask)) { |
| 793 GrTexture* filtered; | 820 GrTexture* filtered; |
| 794 | 821 |
| 795 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), | 822 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), |
| 796 ctm, maskRect, &filtere
d, true)) { | 823 ctm, maskRect, &filtere
d, true)) { |
| 797 // filterMaskGPU gives us ownership of a ref to the result | 824 // filterMaskGPU gives us ownership of a ref to the result |
| 798 SkAutoTUnref<GrTexture> atu(filtered); | 825 SkAutoTUnref<GrTexture> atu(filtered); |
| 799 | 826 |
| 800 // If the scratch texture that we used as the filter src als
o holds the filter | 827 // If the scratch texture that we used as the filter src als
o holds the filter |
| 801 // result then we must detach so that this texture isn't rec
ycled for a later | 828 // result then we must detach so that this texture isn't rec
ycled for a later |
| 802 // draw. | 829 // draw. |
| 803 if (filtered == mask.texture()) { | 830 if (filtered == mask.texture()) { |
| 804 mask.detach(); | 831 mask.detach(); |
| 805 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. | 832 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. |
| 806 } | 833 } |
| 807 | 834 |
| 808 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { | 835 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { |
| 809 // This path is completely drawn | 836 // This path is completely drawn |
| 810 return; | 837 return; |
| 811 } | 838 } |
| 812 } | 839 } |
| 813 } | 840 } |
| 814 } | 841 } |
| 815 | 842 |
| 816 // draw the mask on the CPU - this is a fallthrough path in case the | 843 // draw the mask on the CPU - this is a fallthrough path in case the |
| 817 // GPU path fails | 844 // GPU path fails |
| 818 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: | 845 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: |
| 819 SkPaint::kFill_Style; | 846 SkPaint::kFill_Style; |
| 820 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *dra
w.fClip, &grPaint, | 847 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), |
| 821 style); | 848 *draw.fClip, &grPaint, style); |
| 822 return; | 849 return; |
| 823 } | 850 } |
| 824 | 851 |
| 825 fContext->drawPath(grPaint, *pathPtr, stroke); | 852 fContext->drawPath(grPaint, *pathPtr, strokeInfo); |
| 826 } | 853 } |
| 827 | 854 |
| 828 static const int kBmpSmallTileSize = 1 << 10; | 855 static const int kBmpSmallTileSize = 1 << 10; |
| 829 | 856 |
| 830 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 857 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
| 831 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; | 858 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; |
| 832 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; | 859 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; |
| 833 return tilesX * tilesY; | 860 return tilesX * tilesY; |
| 834 } | 861 } |
| 835 | 862 |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
| 1980 | 2007 |
| 1981 if (NULL != layer->getTexture()) { | 2008 if (NULL != layer->getTexture()) { |
| 1982 fContext->unlockScratchTexture(layer->getTexture()); | 2009 fContext->unlockScratchTexture(layer->getTexture()); |
| 1983 layer->setTexture(NULL); | 2010 layer->setTexture(NULL); |
| 1984 } | 2011 } |
| 1985 } | 2012 } |
| 1986 | 2013 |
| 1987 return true; | 2014 return true; |
| 1988 } | 2015 } |
| OLD | NEW |