| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 SkScalar width = paint.getStrokeWidth(); | 460 SkScalar width = paint.getStrokeWidth(); |
| 460 | 461 |
| 461 /* | 462 /* |
| 462 We have special code for hairline strokes, miter-strokes, bevel-stroke | 463 We have special code for hairline strokes, miter-strokes, bevel-stroke |
| 463 and fills. Anything else we just call our path code. | 464 and fills. Anything else we just call our path code. |
| 464 */ | 465 */ |
| 465 bool usePath = doStroke && width > 0 && | 466 bool usePath = doStroke && width > 0 && |
| 466 (paint.getStrokeJoin() == SkPaint::kRound_Join || | 467 (paint.getStrokeJoin() == SkPaint::kRound_Join || |
| 467 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); | 468 (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
ty())); |
| 468 // another two reasons we might need to call drawPath... | 469 // another two reasons we might need to call drawPath... |
| 469 if (paint.getMaskFilter() || paint.getPathEffect()) { | 470 |
| 471 if (paint.getMaskFilter()) { |
| 470 usePath = true; | 472 usePath = true; |
| 471 } | 473 } |
| 474 |
| 472 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { | 475 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect(
)) { |
| 473 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 476 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 474 if (doStroke) { | 477 if (doStroke) { |
| 475 #endif | 478 #endif |
| 476 usePath = true; | 479 usePath = true; |
| 477 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 480 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 478 } else { | 481 } else { |
| 479 usePath = !fContext->getMatrix().preservesRightAngles(); | 482 usePath = !fContext->getMatrix().preservesRightAngles(); |
| 480 } | 483 } |
| 481 #endif | 484 #endif |
| 482 } | 485 } |
| 483 // until we can both stroke and fill rectangles | 486 // until we can both stroke and fill rectangles |
| 484 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { | 487 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { |
| 485 usePath = true; | 488 usePath = true; |
| 486 } | 489 } |
| 487 | 490 |
| 491 GrStrokeInfo strokeInfo(paint); |
| 492 |
| 493 SkPathEffect* pe = paint.getPathEffect(); |
| 494 if (!usePath && NULL != pe && !strokeInfo.setDashInfo(pe)) { |
| 495 usePath = true; |
| 496 } |
| 497 |
| 488 if (usePath) { | 498 if (usePath) { |
| 489 SkPath path; | 499 SkPath path; |
| 490 path.addRect(rect); | 500 path.addRect(rect); |
| 491 this->drawPath(draw, path, paint, NULL, true); | 501 this->drawPath(draw, path, paint, NULL, true); |
| 492 return; | 502 return; |
| 493 } | 503 } |
| 494 | 504 |
| 495 GrPaint grPaint; | 505 GrPaint grPaint; |
| 496 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 506 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 497 | 507 |
| 498 if (!doStroke) { | 508 fContext->drawRect(grPaint, rect, &strokeInfo); |
| 499 fContext->drawRect(grPaint, rect); | |
| 500 } else { | |
| 501 SkStrokeRec stroke(paint); | |
| 502 fContext->drawRect(grPaint, rect, &stroke); | |
| 503 } | |
| 504 } | 509 } |
| 505 | 510 |
| 506 /////////////////////////////////////////////////////////////////////////////// | 511 /////////////////////////////////////////////////////////////////////////////// |
| 507 | 512 |
| 508 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 513 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 509 const SkPaint& paint) { | 514 const SkPaint& paint) { |
| 510 CHECK_FOR_ANNOTATION(paint); | 515 CHECK_FOR_ANNOTATION(paint); |
| 511 CHECK_SHOULD_DRAW(draw, false); | 516 CHECK_SHOULD_DRAW(draw, false); |
| 512 | 517 |
| 513 GrPaint grPaint; | 518 GrPaint grPaint; |
| 514 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 519 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 515 | 520 |
| 516 SkStrokeRec stroke(paint); | 521 GrStrokeInfo strokeInfo(paint); |
| 517 if (paint.getMaskFilter()) { | 522 if (paint.getMaskFilter()) { |
| 518 // try to hit the fast path for drawing filtered round rects | 523 // try to hit the fast path for drawing filtered round rects |
| 519 | 524 |
| 520 SkRRect devRRect; | 525 SkRRect devRRect; |
| 521 if (rect.transform(fContext->getMatrix(), &devRRect)) { | 526 if (rect.transform(fContext->getMatrix(), &devRRect)) { |
| 522 if (devRRect.allCornersCircular()) { | 527 if (devRRect.allCornersCircular()) { |
| 523 SkRect maskRect; | 528 SkRect maskRect; |
| 524 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), | 529 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), |
| 525 draw.fClip->getBounds(), | 530 draw.fClip->getBounds(), |
| 526 fContext->getMatrix(), | 531 fContext->getMatrix(), |
| 527 &maskRect)) { | 532 &maskRect)) { |
| 528 SkIRect finalIRect; | 533 SkIRect finalIRect; |
| 529 maskRect.roundOut(&finalIRect); | 534 maskRect.roundOut(&finalIRect); |
| 530 if (draw.fClip->quickReject(finalIRect)) { | 535 if (draw.fClip->quickReject(finalIRect)) { |
| 531 // clipped out | 536 // clipped out |
| 532 return; | 537 return; |
| 533 } | 538 } |
| 534 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, | 539 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, &grPaint, |
| 535 stroke,
devRRect)) { | 540 strokeIn
fo.getStrokeRec(), |
| 541 devRRect
)) { |
| 536 return; | 542 return; |
| 537 } | 543 } |
| 538 } | 544 } |
| 539 | 545 |
| 540 } | 546 } |
| 541 } | 547 } |
| 542 | 548 |
| 543 } | 549 } |
| 544 | 550 |
| 545 if (paint.getMaskFilter() || paint.getPathEffect()) { | 551 bool usePath = false; |
| 552 |
| 553 if (paint.getMaskFilter()) { |
| 554 usePath = true; |
| 555 } else { |
| 556 SkPathEffect* pe = paint.getPathEffect(); |
| 557 if (NULL != pe && !strokeInfo.setDashInfo(pe)) { |
| 558 usePath = true; |
| 559 } |
| 560 } |
| 561 |
| 562 |
| 563 if (usePath) { |
| 546 SkPath path; | 564 SkPath path; |
| 547 path.addRRect(rect); | 565 path.addRRect(rect); |
| 548 this->drawPath(draw, path, paint, NULL, true); | 566 this->drawPath(draw, path, paint, NULL, true); |
| 549 return; | 567 return; |
| 550 } | 568 } |
| 551 | 569 |
| 552 fContext->drawRRect(grPaint, rect, stroke); | 570 fContext->drawRRect(grPaint, rect, strokeInfo); |
| 553 } | 571 } |
| 554 | 572 |
| 555 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 573 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 556 const SkRRect& inner, const SkPaint& paint) { | 574 const SkRRect& inner, const SkPaint& paint) { |
| 557 SkStrokeRec stroke(paint); | 575 SkStrokeRec stroke(paint); |
| 558 if (stroke.isFillStyle()) { | 576 if (stroke.isFillStyle()) { |
| 559 | 577 |
| 560 CHECK_FOR_ANNOTATION(paint); | 578 CHECK_FOR_ANNOTATION(paint); |
| 561 CHECK_SHOULD_DRAW(draw, false); | 579 CHECK_SHOULD_DRAW(draw, false); |
| 562 | 580 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 578 } | 596 } |
| 579 | 597 |
| 580 | 598 |
| 581 ///////////////////////////////////////////////////////////////////////////// | 599 ///////////////////////////////////////////////////////////////////////////// |
| 582 | 600 |
| 583 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, | 601 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| 584 const SkPaint& paint) { | 602 const SkPaint& paint) { |
| 585 CHECK_FOR_ANNOTATION(paint); | 603 CHECK_FOR_ANNOTATION(paint); |
| 586 CHECK_SHOULD_DRAW(draw, false); | 604 CHECK_SHOULD_DRAW(draw, false); |
| 587 | 605 |
| 606 GrStrokeInfo strokeInfo(paint); |
| 607 |
| 588 bool usePath = false; | 608 bool usePath = false; |
| 589 // some basic reasons we might need to call drawPath... | 609 // some basic reasons we might need to call drawPath... |
| 590 if (paint.getMaskFilter() || paint.getPathEffect()) { | 610 if (paint.getMaskFilter()) { |
| 591 usePath = true; | 611 usePath = true; |
| 612 } else { |
| 613 SkPathEffect* pe = paint.getPathEffect(); |
| 614 if (NULL != pe && !strokeInfo.setDashInfo(pe)) { |
| 615 usePath = true; |
| 616 } |
| 592 } | 617 } |
| 593 | 618 |
| 594 if (usePath) { | 619 if (usePath) { |
| 595 SkPath path; | 620 SkPath path; |
| 596 path.addOval(oval); | 621 path.addOval(oval); |
| 597 this->drawPath(draw, path, paint, NULL, true); | 622 this->drawPath(draw, path, paint, NULL, true); |
| 598 return; | 623 return; |
| 599 } | 624 } |
| 600 | 625 |
| 601 GrPaint grPaint; | 626 GrPaint grPaint; |
| 602 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); | 627 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); |
| 603 SkStrokeRec stroke(paint); | |
| 604 | 628 |
| 605 fContext->drawOval(grPaint, oval, stroke); | 629 fContext->drawOval(grPaint, oval, strokeInfo); |
| 606 } | 630 } |
| 607 | 631 |
| 608 #include "SkMaskFilter.h" | 632 #include "SkMaskFilter.h" |
| 609 | 633 |
| 610 /////////////////////////////////////////////////////////////////////////////// | 634 /////////////////////////////////////////////////////////////////////////////// |
| 611 | 635 |
| 612 // helpers for applying mask filters | 636 // helpers for applying mask filters |
| 613 namespace { | 637 namespace { |
| 614 | 638 |
| 615 // Draw a mask using the supplied paint. Since the coverage/geometry | 639 // 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); | 695 SkRect maskRect = SkRect::Make(dstM.fBounds); |
| 672 | 696 |
| 673 return draw_mask(context, maskRect, grp, texture); | 697 return draw_mask(context, maskRect, grp, texture); |
| 674 } | 698 } |
| 675 | 699 |
| 676 // Create a mask of 'devPath' and place the result in 'mask'. Return true on | 700 // Create a mask of 'devPath' and place the result in 'mask'. Return true on |
| 677 // success; false otherwise. | 701 // success; false otherwise. |
| 678 bool create_mask_GPU(GrContext* context, | 702 bool create_mask_GPU(GrContext* context, |
| 679 const SkRect& maskRect, | 703 const SkRect& maskRect, |
| 680 const SkPath& devPath, | 704 const SkPath& devPath, |
| 681 const SkStrokeRec& stroke, | 705 const GrStrokeInfo& strokeInfo, |
| 682 bool doAA, | 706 bool doAA, |
| 683 GrAutoScratchTexture* mask) { | 707 GrAutoScratchTexture* mask) { |
| 684 GrTextureDesc desc; | 708 GrTextureDesc desc; |
| 685 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 709 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 686 desc.fWidth = SkScalarCeilToInt(maskRect.width()); | 710 desc.fWidth = SkScalarCeilToInt(maskRect.width()); |
| 687 desc.fHeight = SkScalarCeilToInt(maskRect.height()); | 711 desc.fHeight = SkScalarCeilToInt(maskRect.height()); |
| 688 // We actually only need A8, but it often isn't supported as a | 712 // We actually only need A8, but it often isn't supported as a |
| 689 // render target so default to RGBA_8888 | 713 // render target so default to RGBA_8888 |
| 690 desc.fConfig = kRGBA_8888_GrPixelConfig; | 714 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 691 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 715 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. | 740 // use a zero dst coeff when dual source blending isn't available. |
| 717 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); | 741 tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); |
| 718 } | 742 } |
| 719 | 743 |
| 720 GrContext::AutoMatrix am; | 744 GrContext::AutoMatrix am; |
| 721 | 745 |
| 722 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 746 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
| 723 SkMatrix translate; | 747 SkMatrix translate; |
| 724 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 748 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
| 725 am.set(context, translate); | 749 am.set(context, translate); |
| 726 context->drawPath(tempPaint, devPath, stroke); | 750 context->drawPath(tempPaint, devPath, strokeInfo); |
| 727 return true; | 751 return true; |
| 728 } | 752 } |
| 729 | 753 |
| 730 SkBitmap wrap_texture(GrTexture* texture) { | 754 SkBitmap wrap_texture(GrTexture* texture) { |
| 731 SkImageInfo info; | 755 SkImageInfo info; |
| 732 texture->asImageInfo(&info); | 756 texture->asImageInfo(&info); |
| 733 | 757 |
| 734 SkBitmap result; | 758 SkBitmap result; |
| 735 result.setInfo(info); | 759 result.setInfo(info); |
| 736 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 760 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 763 pathIsMutable = true; | 787 pathIsMutable = true; |
| 764 } | 788 } |
| 765 // should I push prePathMatrix on our MV stack temporarily, instead | 789 // should I push prePathMatrix on our MV stack temporarily, instead |
| 766 // of applying it here? See SkDraw.cpp | 790 // of applying it here? See SkDraw.cpp |
| 767 pathPtr->transform(*prePathMatrix, result); | 791 pathPtr->transform(*prePathMatrix, result); |
| 768 pathPtr = result; | 792 pathPtr = result; |
| 769 } | 793 } |
| 770 // at this point we're done with prePathMatrix | 794 // at this point we're done with prePathMatrix |
| 771 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 795 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 772 | 796 |
| 773 SkStrokeRec stroke(paint); | 797 GrStrokeInfo strokeInfo(paint); |
| 774 SkPathEffect* pathEffect = paint.getPathEffect(); | 798 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 775 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 799 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 776 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &strok
e, | 800 SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); |
| 801 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, stroke
Ptr, |
| 777 cullRect)) { | 802 cullRect)) { |
| 778 pathPtr = effectPath.get(); | 803 pathPtr = effectPath.get(); |
| 779 pathIsMutable = true; | 804 pathIsMutable = true; |
| 780 } | 805 } |
| 781 | 806 |
| 807 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); |
| 782 if (paint.getMaskFilter()) { | 808 if (paint.getMaskFilter()) { |
| 783 if (!stroke.isHairlineStyle()) { | 809 if (!stroke.isHairlineStyle()) { |
| 784 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); | 810 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); |
| 785 if (stroke.applyToPath(strokedPath, *pathPtr)) { | 811 if (stroke.applyToPath(strokedPath, *pathPtr)) { |
| 786 pathPtr = strokedPath; | 812 pathPtr = strokedPath; |
| 787 pathIsMutable = true; | 813 pathIsMutable = true; |
| 788 stroke.setFillStyle(); | 814 strokeInfo.setFillStyle(); |
| 789 } | 815 } |
| 790 } | 816 } |
| 791 | 817 |
| 792 // avoid possibly allocating a new path in transform if we can | 818 // avoid possibly allocating a new path in transform if we can |
| 793 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); | 819 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); |
| 794 | 820 |
| 795 // transform the path into device space | 821 // transform the path into device space |
| 796 pathPtr->transform(fContext->getMatrix(), devPathPtr); | 822 pathPtr->transform(fContext->getMatrix(), devPathPtr); |
| 797 | 823 |
| 798 SkRect maskRect; | 824 SkRect maskRect; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 813 | 839 |
| 814 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, | 840 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, |
| 815 stroke, *devPathPtr))
{ | 841 stroke, *devPathPtr))
{ |
| 816 // the mask filter was able to draw itself directly, so there's
nothing | 842 // the mask filter was able to draw itself directly, so there's
nothing |
| 817 // left to do. | 843 // left to do. |
| 818 return; | 844 return; |
| 819 } | 845 } |
| 820 | 846 |
| 821 GrAutoScratchTexture mask; | 847 GrAutoScratchTexture mask; |
| 822 | 848 |
| 823 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, | 849 if (create_mask_GPU(fContext, maskRect, *devPathPtr, strokeInfo, |
| 824 grPaint.isAntiAlias(), &mask)) { | 850 grPaint.isAntiAlias(), &mask)) { |
| 825 GrTexture* filtered; | 851 GrTexture* filtered; |
| 826 | 852 |
| 827 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), | 853 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), |
| 828 ctm, maskRect, &filtere
d, true)) { | 854 ctm, maskRect, &filtere
d, true)) { |
| 829 // filterMaskGPU gives us ownership of a ref to the result | 855 // filterMaskGPU gives us ownership of a ref to the result |
| 830 SkAutoTUnref<GrTexture> atu(filtered); | 856 SkAutoTUnref<GrTexture> atu(filtered); |
| 831 | 857 |
| 832 // If the scratch texture that we used as the filter src als
o holds the filter | 858 // 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 | 859 // result then we must detach so that this texture isn't rec
ycled for a later |
| 834 // draw. | 860 // draw. |
| 835 if (filtered == mask.texture()) { | 861 if (filtered == mask.texture()) { |
| 836 mask.detach(); | 862 mask.detach(); |
| 837 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. | 863 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. |
| 838 } | 864 } |
| 839 | 865 |
| 840 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { | 866 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { |
| 841 // This path is completely drawn | 867 // This path is completely drawn |
| 842 return; | 868 return; |
| 843 } | 869 } |
| 844 } | 870 } |
| 845 } | 871 } |
| 846 } | 872 } |
| 847 | 873 |
| 848 // draw the mask on the CPU - this is a fallthrough path in case the | 874 // draw the mask on the CPU - this is a fallthrough path in case the |
| 849 // GPU path fails | 875 // GPU path fails |
| 850 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: | 876 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: |
| 851 SkPaint::kFill_Style; | 877 SkPaint::kFill_Style; |
| 852 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *dra
w.fClip, &grPaint, | 878 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), |
| 853 style); | 879 *draw.fClip, &grPaint, style); |
| 854 return; | 880 return; |
| 855 } | 881 } |
| 856 | 882 |
| 857 fContext->drawPath(grPaint, *pathPtr, stroke); | 883 fContext->drawPath(grPaint, *pathPtr, strokeInfo); |
| 858 } | 884 } |
| 859 | 885 |
| 860 static const int kBmpSmallTileSize = 1 << 10; | 886 static const int kBmpSmallTileSize = 1 << 10; |
| 861 | 887 |
| 862 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 888 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
| 863 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; | 889 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; |
| 864 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; | 890 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; |
| 865 return tilesX * tilesY; | 891 return tilesX * tilesY; |
| 866 } | 892 } |
| 867 | 893 |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2032 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
| 2007 | 2033 |
| 2008 if (NULL != layer->getTexture()) { | 2034 if (NULL != layer->getTexture()) { |
| 2009 fContext->unlockScratchTexture(layer->getTexture()); | 2035 fContext->unlockScratchTexture(layer->getTexture()); |
| 2010 layer->setTexture(NULL); | 2036 layer->setTexture(NULL); |
| 2011 } | 2037 } |
| 2012 } | 2038 } |
| 2013 | 2039 |
| 2014 return true; | 2040 return true; |
| 2015 } | 2041 } |
| OLD | NEW |