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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 devRRect )) { | 560 devRRect )) { |
561 return; | 561 return; |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 } | 565 } |
566 } | 566 } |
567 | 567 |
568 } | 568 } |
569 | 569 |
570 bool usePath = false; | 570 if (paint.getMaskFilter() || paint.getPathEffect()) { |
reed1
2015/11/24 14:42:29
I wonder if a brief comment would help here. Is th
| |
571 | |
572 if (paint.getMaskFilter()) { | |
573 usePath = true; | |
574 } else { | |
575 const SkPathEffect* pe = paint.getPathEffect(); | |
576 if (pe && !strokeInfo.isDashed()) { | |
577 usePath = true; | |
578 } | |
579 } | |
580 | |
581 | |
582 if (usePath) { | |
583 SkPath path; | 571 SkPath path; |
584 path.setIsVolatile(true); | 572 path.setIsVolatile(true); |
585 path.addRRect(rect); | 573 path.addRRect(rect); |
586 this->drawPath(draw, path, paint, nullptr, true); | 574 this->drawPath(draw, path, paint, nullptr, true); |
587 return; | 575 return; |
588 } | 576 } |
589 | 577 |
578 SkASSERT(!strokeInfo.isDashed()); | |
579 | |
590 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); | 580 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); |
591 } | 581 } |
592 | 582 |
593 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 583 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
594 const SkRRect& inner, const SkPaint& paint) { | 584 const SkRRect& inner, const SkPaint& paint) { |
595 SkStrokeRec stroke(paint); | 585 SkStrokeRec stroke(paint); |
596 if (stroke.isFillStyle()) { | 586 if (stroke.isFillStyle()) { |
597 | 587 |
598 CHECK_FOR_ANNOTATION(paint); | 588 CHECK_FOR_ANNOTATION(paint); |
599 CHECK_SHOULD_DRAW(draw); | 589 CHECK_SHOULD_DRAW(draw); |
(...skipping 14 matching lines...) Expand all Loading... | |
614 path.addRRect(outer); | 604 path.addRRect(outer); |
615 path.addRRect(inner); | 605 path.addRRect(inner); |
616 path.setFillType(SkPath::kEvenOdd_FillType); | 606 path.setFillType(SkPath::kEvenOdd_FillType); |
617 | 607 |
618 this->drawPath(draw, path, paint, nullptr, true); | 608 this->drawPath(draw, path, paint, nullptr, true); |
619 } | 609 } |
620 | 610 |
621 | 611 |
622 ///////////////////////////////////////////////////////////////////////////// | 612 ///////////////////////////////////////////////////////////////////////////// |
623 | 613 |
624 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, | 614 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint & paint) { |
625 const SkPaint& paint) { | |
626 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext); | 615 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext); |
627 CHECK_FOR_ANNOTATION(paint); | 616 CHECK_FOR_ANNOTATION(paint); |
628 CHECK_SHOULD_DRAW(draw); | 617 CHECK_SHOULD_DRAW(draw); |
629 | 618 |
630 GrStrokeInfo strokeInfo(paint); | 619 // Presumably the path effect warps this to something other than an oval |
631 | 620 if (paint.getPathEffect()) { |
632 bool usePath = false; | |
633 // some basic reasons we might need to call drawPath... | |
634 if (paint.getMaskFilter()) { | |
635 // The RRect path can handle special case blurring | |
636 SkRRect rr = SkRRect::MakeOval(oval); | |
637 return this->drawRRect(draw, rr, paint); | |
638 } else { | |
639 const SkPathEffect* pe = paint.getPathEffect(); | |
640 if (pe && !strokeInfo.isDashed()) { | |
641 usePath = true; | |
642 } | |
643 } | |
644 | |
645 if (usePath) { | |
646 SkPath path; | 621 SkPath path; |
647 path.setIsVolatile(true); | 622 path.setIsVolatile(true); |
648 path.addOval(oval); | 623 path.addOval(oval); |
649 this->drawPath(draw, path, paint, nullptr, true); | 624 this->drawPath(draw, path, paint, nullptr, true); |
650 return; | 625 return; |
626 } | |
627 | |
628 if (paint.getMaskFilter()) { | |
629 // The RRect path can handle special case blurring | |
630 SkRRect rr = SkRRect::MakeOval(oval); | |
631 return this->drawRRect(draw, rr, paint); | |
651 } | 632 } |
652 | 633 |
653 GrPaint grPaint; | 634 GrPaint grPaint; |
654 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 635 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
655 return; | 636 return; |
656 } | 637 } |
657 | 638 |
639 GrStrokeInfo strokeInfo(paint); | |
640 SkASSERT(!strokeInfo.isDashed()); | |
641 | |
658 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); | 642 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); |
659 } | 643 } |
660 | 644 |
661 #include "SkMaskFilter.h" | 645 #include "SkMaskFilter.h" |
662 | 646 |
663 /////////////////////////////////////////////////////////////////////////////// | 647 /////////////////////////////////////////////////////////////////////////////// |
664 | 648 |
665 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { | 649 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { |
666 SkBitmap result; | 650 SkBitmap result; |
667 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); | 651 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1878 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1862 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1879 } | 1863 } |
1880 | 1864 |
1881 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1865 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1882 // We always return a transient cache, so it is freed after each | 1866 // We always return a transient cache, so it is freed after each |
1883 // filter traversal. | 1867 // filter traversal. |
1884 return SkGpuDevice::NewImageFilterCache(); | 1868 return SkGpuDevice::NewImageFilterCache(); |
1885 } | 1869 } |
1886 | 1870 |
1887 #endif | 1871 #endif |
OLD | NEW |