| 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 "GrPaintStyle.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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 0); | 449 0); |
| 449 } | 450 } |
| 450 | 451 |
| 451 /////////////////////////////////////////////////////////////////////////////// | 452 /////////////////////////////////////////////////////////////////////////////// |
| 452 | 453 |
| 453 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, | 454 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
| 454 const SkPaint& paint) { | 455 const SkPaint& paint) { |
| 455 CHECK_FOR_ANNOTATION(paint); | 456 CHECK_FOR_ANNOTATION(paint); |
| 456 CHECK_SHOULD_DRAW(draw, false); | 457 CHECK_SHOULD_DRAW(draw, false); |
| 457 | 458 |
| 459 GrPaintStyle style; |
| 460 |
| 458 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; | 461 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |
| 459 SkScalar width = paint.getStrokeWidth(); | 462 SkScalar width = paint.getStrokeWidth(); |
| 460 | 463 |
| 461 /* | 464 /* |
| 462 We have special code for hairline strokes, miter-strokes, bevel-stroke | 465 We have special code for hairline strokes, miter-strokes, bevel-stroke |
| 463 and fills. Anything else we just call our path code. | 466 and fills. Anything else we just call our path code. |
| 464 */ | 467 */ |
| 465 bool usePath = doStroke && width > 0 && | 468 bool usePath = doStroke && width > 0 && |
| 466 (paint.getStrokeJoin() == SkPaint::kRound_Join || | 469 (paint.getStrokeJoin() == SkPaint::kRound_Join || |
| 467 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); | 470 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); |
| 468 // another two reasons we might need to call drawPath... | 471 // another two reasons we might need to call drawPath... |
| 469 if (paint.getMaskFilter() || paint.getPathEffect()) { | 472 |
| 473 if (paint.getMaskFilter()) { |
| 470 usePath = true; | 474 usePath = true; |
| 471 } | 475 } |
| 476 |
| 477 SkPathEffect* pe = paint.getPathEffect(); |
| 478 SkPathEffect::DashInfo info; |
| 479 if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
| 480 usePath = true; |
| 481 } |
| 482 |
| 472 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { | 483 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { |
| 473 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 484 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 474 if (doStroke) { | 485 if (doStroke) { |
| 475 #endif | 486 #endif |
| 476 usePath = true; | 487 usePath = true; |
| 477 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 488 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 478 } else { | 489 } else { |
| 479 usePath = !fContext->getMatrix().preservesRightAngles(); | 490 usePath = !fContext->getMatrix().preservesRightAngles(); |
| 480 } | 491 } |
| 481 #endif | 492 #endif |
| 482 } | 493 } |
| 483 // until we can both stroke and fill rectangles | 494 // until we can both stroke and fill rectangles |
| 484 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { | 495 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { |
| 485 usePath = true; | 496 usePath = true; |
| 486 } | 497 } |
| 487 | 498 |
| 488 if (usePath) { | 499 if (usePath) { |
| 489 SkPath path; | 500 SkPath path; |
| 490 path.addRect(rect); | 501 path.addRect(rect); |
| 491 this->drawPath(draw, path, paint, NULL, true); | 502 this->drawPath(draw, path, paint, NULL, true); |
| 492 return; | 503 return; |
| 493 } | 504 } |
| 494 | 505 |
| 495 GrPaint grPaint; | 506 GrPaint grPaint; |
| 496 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 507 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 508 |
| 509 SkStrokeRec stroke(paint); |
| 510 style.setStrokeRec(&stroke); |
| 497 | 511 |
| 512 SkAutoTArray<SkScalar> intervals(info.fCount); |
| 513 if (pe) { |
| 514 info.fIntervals = intervals.get(); |
| 515 pe->asADash(&info); |
| 516 style.setDashInfo(&info); |
| 517 } |
| 518 |
| 519 fContext->drawRect(grPaint, rect, &style); |
| 520 /* |
| 498 if (!doStroke) { | 521 if (!doStroke) { |
| 499 fContext->drawRect(grPaint, rect); | 522 fContext->drawRect(grPaint, rect); |
| 500 } else { | 523 } else { |
| 501 SkStrokeRec stroke(paint); | 524 SkStrokeRec stroke(paint); |
| 502 fContext->drawRect(grPaint, rect, &stroke); | 525 style.setStrokeRec(&stroke); |
| 526 fContext->drawRect(grPaint, rect, &style); |
| 503 } | 527 } |
| 528 */ |
| 504 } | 529 } |
| 505 | 530 |
| 506 /////////////////////////////////////////////////////////////////////////////// | 531 /////////////////////////////////////////////////////////////////////////////// |
| 507 | 532 |
| 508 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 533 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 509 const SkPaint& paint) { | 534 const SkPaint& paint) { |
| 510 CHECK_FOR_ANNOTATION(paint); | 535 CHECK_FOR_ANNOTATION(paint); |
| 511 CHECK_SHOULD_DRAW(draw, false); | 536 CHECK_SHOULD_DRAW(draw, false); |
| 512 | 537 |
| 513 GrPaint grPaint; | 538 GrPaint grPaint; |
| 514 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 539 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 515 | 540 |
| 541 GrPaintStyle style; |
| 516 SkStrokeRec stroke(paint); | 542 SkStrokeRec stroke(paint); |
| 543 style.setStrokeRec(&stroke); |
| 517 if (paint.getMaskFilter()) { | 544 if (paint.getMaskFilter()) { |
| 518 // try to hit the fast path for drawing filtered round rects | 545 // try to hit the fast path for drawing filtered round rects |
| 519 | 546 |
| 520 SkRRect devRRect; | 547 SkRRect devRRect; |
| 521 if (rect.transform(fContext->getMatrix(), &devRRect)) { | 548 if (rect.transform(fContext->getMatrix(), &devRRect)) { |
| 522 if (devRRect.allCornersCircular()) { | 549 if (devRRect.allCornersCircular()) { |
| 523 SkRect maskRect; | 550 SkRect maskRect; |
| 524 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), | 551 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), |
| 525 draw.fClip->getBounds(), | 552 draw.fClip->getBounds(), |
| 526 fContext->getMatrix(), | 553 fContext->getMatrix(), |
| 527 &maskRect)) { | 554 &maskRect)) { |
| 528 SkIRect finalIRect; | 555 SkIRect finalIRect; |
| 529 maskRect.roundOut(&finalIRect); | 556 maskRect.roundOut(&finalIRect); |
| 530 if (draw.fClip->quickReject(finalIRect)) { | 557 if (draw.fClip->quickReject(finalIRect)) { |
| 531 // clipped out | 558 // clipped out |
| 532 return; | 559 return; |
| 533 } | 560 } |
| 534 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, | 561 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, |
| 535 stroke,
devRRect)) { | 562 stroke,
devRRect)) { |
| 536 return; | 563 return; |
| 537 } | 564 } |
| 538 } | 565 } |
| 539 | 566 |
| 540 } | 567 } |
| 541 } | 568 } |
| 542 | 569 |
| 543 } | 570 } |
| 544 | 571 |
| 545 if (paint.getMaskFilter() || paint.getPathEffect()) { | 572 bool usePath = false; |
| 573 |
| 574 if (paint.getMaskFilter()) { |
| 575 usePath = true; |
| 576 } |
| 577 |
| 578 SkPathEffect* pe = paint.getPathEffect(); |
| 579 SkPathEffect::DashInfo info; |
| 580 if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
| 581 usePath = true; |
| 582 } |
| 583 |
| 584 if (usePath) { |
| 546 SkPath path; | 585 SkPath path; |
| 547 path.addRRect(rect); | 586 path.addRRect(rect); |
| 548 this->drawPath(draw, path, paint, NULL, true); | 587 this->drawPath(draw, path, paint, NULL, true); |
| 549 return; | 588 return; |
| 550 } | 589 } |
| 590 |
| 591 SkAutoTArray<SkScalar> intervals(info.fCount); |
| 592 if (pe) { |
| 593 info.fIntervals = intervals.get(); |
| 594 pe->asADash(&info); |
| 595 style.setDashInfo(&info); |
| 596 } |
| 551 | 597 |
| 552 fContext->drawRRect(grPaint, rect, stroke); | 598 |
| 599 fContext->drawRRect(grPaint, rect, style); |
| 553 } | 600 } |
| 554 | 601 |
| 555 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 602 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 556 const SkRRect& inner, const SkPaint& paint) { | 603 const SkRRect& inner, const SkPaint& paint) { |
| 557 SkStrokeRec stroke(paint); | 604 SkStrokeRec stroke(paint); |
| 558 if (stroke.isFillStyle()) { | 605 if (stroke.isFillStyle()) { |
| 559 | 606 |
| 560 CHECK_FOR_ANNOTATION(paint); | 607 CHECK_FOR_ANNOTATION(paint); |
| 561 CHECK_SHOULD_DRAW(draw, false); | 608 CHECK_SHOULD_DRAW(draw, false); |
| 562 | 609 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 583 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, | 630 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| 584 const SkPaint& paint) { | 631 const SkPaint& paint) { |
| 585 CHECK_FOR_ANNOTATION(paint); | 632 CHECK_FOR_ANNOTATION(paint); |
| 586 CHECK_SHOULD_DRAW(draw, false); | 633 CHECK_SHOULD_DRAW(draw, false); |
| 587 | 634 |
| 588 bool usePath = false; | 635 bool usePath = false; |
| 589 // some basic reasons we might need to call drawPath... | 636 // some basic reasons we might need to call drawPath... |
| 590 if (paint.getMaskFilter() || paint.getPathEffect()) { | 637 if (paint.getMaskFilter() || paint.getPathEffect()) { |
| 591 usePath = true; | 638 usePath = true; |
| 592 } | 639 } |
| 640 |
| 641 SkPathEffect* pe = paint.getPathEffect(); |
| 642 SkPathEffect::DashInfo info; |
| 643 if (pe && SkPathEffect::kDash_DashType != pe->asADash(&info)) { |
| 644 usePath = true; |
| 645 } |
| 593 | 646 |
| 594 if (usePath) { | 647 if (usePath) { |
| 595 SkPath path; | 648 SkPath path; |
| 596 path.addOval(oval); | 649 path.addOval(oval); |
| 597 this->drawPath(draw, path, paint, NULL, true); | 650 this->drawPath(draw, path, paint, NULL, true); |
| 598 return; | 651 return; |
| 599 } | 652 } |
| 600 | 653 |
| 601 GrPaint grPaint; | 654 GrPaint grPaint; |
| 602 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 655 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 656 |
| 657 GrPaintStyle style; |
| 658 SkAutoTArray<SkScalar> intervals(info.fCount); |
| 659 if (pe) { |
| 660 info.fIntervals = intervals.get(); |
| 661 pe->asADash(&info); |
| 662 style.setDashInfo(&info); |
| 663 } |
| 664 |
| 603 SkStrokeRec stroke(paint); | 665 SkStrokeRec stroke(paint); |
| 666 style.setStrokeRec(&stroke); |
| 604 | 667 |
| 605 fContext->drawOval(grPaint, oval, stroke); | 668 fContext->drawOval(grPaint, oval, style); |
| 606 } | 669 } |
| 607 | 670 |
| 608 #include "SkMaskFilter.h" | 671 #include "SkMaskFilter.h" |
| 609 | 672 |
| 610 /////////////////////////////////////////////////////////////////////////////// | 673 /////////////////////////////////////////////////////////////////////////////// |
| 611 | 674 |
| 612 // helpers for applying mask filters | 675 // helpers for applying mask filters |
| 613 namespace { | 676 namespace { |
| 614 | 677 |
| 615 // Draw a mask using the supplied paint. Since the coverage/geometry | 678 // Draw a mask using the supplied paint. Since the coverage/geometry |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 SkRect maskRect = SkRect::Make(dstM.fBounds); | 734 SkRect maskRect = SkRect::Make(dstM.fBounds); |
| 672 | 735 |
| 673 return draw_mask(context, maskRect, grp, texture); | 736 return draw_mask(context, maskRect, grp, texture); |
| 674 } | 737 } |
| 675 | 738 |
| 676 // Create a mask of 'devPath' and place the result in 'mask'. Return true on | 739 // Create a mask of 'devPath' and place the result in 'mask'. Return true on |
| 677 // success; false otherwise. | 740 // success; false otherwise. |
| 678 bool create_mask_GPU(GrContext* context, | 741 bool create_mask_GPU(GrContext* context, |
| 679 const SkRect& maskRect, | 742 const SkRect& maskRect, |
| 680 const SkPath& devPath, | 743 const SkPath& devPath, |
| 681 const SkStrokeRec& stroke, | 744 const GrPaintStyle& style, |
| 682 bool doAA, | 745 bool doAA, |
| 683 GrAutoScratchTexture* mask) { | 746 GrAutoScratchTexture* mask) { |
| 684 GrTextureDesc desc; | 747 GrTextureDesc desc; |
| 685 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 748 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 686 desc.fWidth = SkScalarCeilToInt(maskRect.width()); | 749 desc.fWidth = SkScalarCeilToInt(maskRect.width()); |
| 687 desc.fHeight = SkScalarCeilToInt(maskRect.height()); | 750 desc.fHeight = SkScalarCeilToInt(maskRect.height()); |
| 688 // We actually only need A8, but it often isn't supported as a | 751 // We actually only need A8, but it often isn't supported as a |
| 689 // render target so default to RGBA_8888 | 752 // render target so default to RGBA_8888 |
| 690 desc.fConfig = kRGBA_8888_GrPixelConfig; | 753 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 691 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 754 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 716 // use a zero dst coeff when dual source blending isn't available. | 779 // use a zero dst coeff when dual source blending isn't available. |
| 717 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); | 780 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); |
| 718 } | 781 } |
| 719 | 782 |
| 720 GrContext::AutoMatrix am; | 783 GrContext::AutoMatrix am; |
| 721 | 784 |
| 722 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 785 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
| 723 SkMatrix translate; | 786 SkMatrix translate; |
| 724 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 787 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
| 725 am.set(context, translate); | 788 am.set(context, translate); |
| 726 context->drawPath(tempPaint, devPath, stroke); | 789 context->drawPath(tempPaint, devPath, style); |
| 727 return true; | 790 return true; |
| 728 } | 791 } |
| 729 | 792 |
| 730 SkBitmap wrap_texture(GrTexture* texture) { | 793 SkBitmap wrap_texture(GrTexture* texture) { |
| 731 SkImageInfo info; | 794 SkImageInfo info; |
| 732 texture->asImageInfo(&info); | 795 texture->asImageInfo(&info); |
| 733 | 796 |
| 734 SkBitmap result; | 797 SkBitmap result; |
| 735 result.setInfo(info); | 798 result.setInfo(info); |
| 736 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 799 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 763 pathIsMutable = true; | 826 pathIsMutable = true; |
| 764 } | 827 } |
| 765 // should I push prePathMatrix on our MV stack temporarily, instead | 828 // should I push prePathMatrix on our MV stack temporarily, instead |
| 766 // of applying it here? See SkDraw.cpp | 829 // of applying it here? See SkDraw.cpp |
| 767 pathPtr->transform(*prePathMatrix, result); | 830 pathPtr->transform(*prePathMatrix, result); |
| 768 pathPtr = result; | 831 pathPtr = result; |
| 769 } | 832 } |
| 770 // at this point we're done with prePathMatrix | 833 // at this point we're done with prePathMatrix |
| 771 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 834 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 772 | 835 |
| 836 GrPaintStyle style; |
| 773 SkStrokeRec stroke(paint); | 837 SkStrokeRec stroke(paint); |
| 838 style.setStrokeRec(&stroke); |
| 774 SkPathEffect* pathEffect = paint.getPathEffect(); | 839 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 775 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 840 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 776 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &strok
e, | 841 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &strok
e, |
| 777 cullRect)) { | 842 cullRect)) { |
| 778 pathPtr = effectPath.get(); | 843 pathPtr = effectPath.get(); |
| 779 pathIsMutable = true; | 844 pathIsMutable = true; |
| 780 } | 845 } |
| 781 | 846 |
| 782 if (paint.getMaskFilter()) { | 847 if (paint.getMaskFilter()) { |
| 783 if (!stroke.isHairlineStyle()) { | 848 if (!stroke.isHairlineStyle()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 813 | 878 |
| 814 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, | 879 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, |
| 815 stroke, *devPathPtr))
{ | 880 stroke, *devPathPtr))
{ |
| 816 // the mask filter was able to draw itself directly, so there's
nothing | 881 // the mask filter was able to draw itself directly, so there's
nothing |
| 817 // left to do. | 882 // left to do. |
| 818 return; | 883 return; |
| 819 } | 884 } |
| 820 | 885 |
| 821 GrAutoScratchTexture mask; | 886 GrAutoScratchTexture mask; |
| 822 | 887 |
| 823 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, | 888 if (create_mask_GPU(fContext, maskRect, *devPathPtr, style, |
| 824 grPaint.isAntiAlias(), &mask)) { | 889 grPaint.isAntiAlias(), &mask)) { |
| 825 GrTexture* filtered; | 890 GrTexture* filtered; |
| 826 | 891 |
| 827 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), | 892 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), |
| 828 ctm, maskRect, &filtere
d, true)) { | 893 ctm, maskRect, &filtere
d, true)) { |
| 829 // filterMaskGPU gives us ownership of a ref to the result | 894 // filterMaskGPU gives us ownership of a ref to the result |
| 830 SkAutoTUnref<GrTexture> atu(filtered); | 895 SkAutoTUnref<GrTexture> atu(filtered); |
| 831 | 896 |
| 832 // If the scratch texture that we used as the filter src als
o holds the filter | 897 // If the scratch texture that we used as the filter src als
o holds the filter |
| 833 // result then we must detach so that this texture isn't rec
ycled for a later | 898 // result then we must detach so that this texture isn't rec
ycled for a later |
| 834 // draw. | 899 // draw. |
| 835 if (filtered == mask.texture()) { | 900 if (filtered == mask.texture()) { |
| 836 mask.detach(); | 901 mask.detach(); |
| 837 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. | 902 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. |
| 838 } | 903 } |
| 839 | 904 |
| 840 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { | 905 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { |
| 841 // This path is completely drawn | 906 // This path is completely drawn |
| 842 return; | 907 return; |
| 843 } | 908 } |
| 844 } | 909 } |
| 845 } | 910 } |
| 846 } | 911 } |
| 847 | 912 |
| 848 // draw the mask on the CPU - this is a fallthrough path in case the | 913 // draw the mask on the CPU - this is a fallthrough path in case the |
| 849 // GPU path fails | 914 // GPU path fails |
| 850 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: | 915 SkPaint::Style paintStyle = stroke.isHairlineStyle() ? SkPaint::kStroke_
Style : |
| 851 SkPaint::kFill_Style; | 916 SkPaint::kFill_St
yle; |
| 852 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *dra
w.fClip, &grPaint, | 917 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), |
| 853 style); | 918 *draw.fClip, &grPaint, paintStyle); |
| 854 return; | 919 return; |
| 855 } | 920 } |
| 856 | 921 |
| 857 fContext->drawPath(grPaint, *pathPtr, stroke); | 922 fContext->drawPath(grPaint, *pathPtr, style); |
| 858 } | 923 } |
| 859 | 924 |
| 860 static const int kBmpSmallTileSize = 1 << 10; | 925 static const int kBmpSmallTileSize = 1 << 10; |
| 861 | 926 |
| 862 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 927 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
| 863 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; | 928 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; |
| 864 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; | 929 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; |
| 865 return tilesX * tilesY; | 930 return tilesX * tilesY; |
| 866 } | 931 } |
| 867 | 932 |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2071 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
| 2007 | 2072 |
| 2008 if (NULL != layer->getTexture()) { | 2073 if (NULL != layer->getTexture()) { |
| 2009 fContext->unlockScratchTexture(layer->getTexture()); | 2074 fContext->unlockScratchTexture(layer->getTexture()); |
| 2010 layer->setTexture(NULL); | 2075 layer->setTexture(NULL); |
| 2011 } | 2076 } |
| 2012 } | 2077 } |
| 2013 | 2078 |
| 2014 return true; | 2079 return true; |
| 2015 } | 2080 } |
| OLD | NEW |