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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 } | 477 } |
478 | 478 |
479 if (!usePath && paint.isAntiAlias() && !draw.fMatrix->rectStaysRect()) { | 479 if (!usePath && paint.isAntiAlias() && !draw.fMatrix->rectStaysRect()) { |
480 usePath = true; | 480 usePath = true; |
481 } | 481 } |
482 | 482 |
483 if (usePath) { | 483 if (usePath) { |
484 SkPath path; | 484 SkPath path; |
485 path.setIsVolatile(true); | 485 path.setIsVolatile(true); |
486 path.addRect(rect); | 486 path.addRect(rect); |
487 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarge
t, | 487 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
488 fClip, path, paint, | 488 fClip, path, paint, |
489 *draw.fMatrix, nullptr, | 489 *draw.fMatrix, nullptr, |
490 draw.fClip->getBounds(), true); | 490 draw.fClip->getBounds(), true); |
491 return; | 491 return; |
492 } | 492 } |
493 | 493 |
494 GrPaint grPaint; | 494 GrPaint grPaint; |
495 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 495 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
496 return; | 496 return; |
497 } | 497 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 if (paint.getMaskFilter() || paint.getPathEffect()) { | 550 if (paint.getMaskFilter() || paint.getPathEffect()) { |
551 // The only mask filter the native rrect drawing code could've handle wa
s taken | 551 // The only mask filter the native rrect drawing code could've handle wa
s taken |
552 // care of above. | 552 // care of above. |
553 // A path effect will presumably transform this rrect into something els
e. | 553 // A path effect will presumably transform this rrect into something els
e. |
554 SkPath path; | 554 SkPath path; |
555 path.setIsVolatile(true); | 555 path.setIsVolatile(true); |
556 path.addRRect(rect); | 556 path.addRRect(rect); |
557 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarge
t, | 557 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
558 fClip, path, paint, | 558 fClip, path, paint, |
559 *draw.fMatrix, nullptr, | 559 *draw.fMatrix, nullptr, |
560 draw.fClip->getBounds(), true); | 560 draw.fClip->getBounds(), true); |
561 return; | 561 return; |
562 } | 562 } |
563 | 563 |
564 SkASSERT(!strokeInfo.isDashed()); | 564 SkASSERT(!strokeInfo.isDashed()); |
565 | 565 |
566 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); | 566 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); |
567 } | 567 } |
(...skipping 15 matching lines...) Expand all Loading... |
583 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); | 583 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); |
584 return; | 584 return; |
585 } | 585 } |
586 | 586 |
587 SkPath path; | 587 SkPath path; |
588 path.setIsVolatile(true); | 588 path.setIsVolatile(true); |
589 path.addRRect(outer); | 589 path.addRRect(outer); |
590 path.addRRect(inner); | 590 path.addRRect(inner); |
591 path.setFillType(SkPath::kEvenOdd_FillType); | 591 path.setFillType(SkPath::kEvenOdd_FillType); |
592 | 592 |
593 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, | 593 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
594 fClip, path, paint, | 594 fClip, path, paint, |
595 *draw.fMatrix, nullptr, | 595 *draw.fMatrix, nullptr, |
596 draw.fClip->getBounds(), true); | 596 draw.fClip->getBounds(), true); |
597 } | 597 } |
598 | 598 |
599 | 599 |
600 ///////////////////////////////////////////////////////////////////////////// | 600 ///////////////////////////////////////////////////////////////////////////// |
601 | 601 |
602 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { | 602 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { |
603 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext); | 603 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 if (origSrcPath.isRRect(&rrect)) { | 659 if (origSrcPath.isRRect(&rrect)) { |
660 this->drawRRect(draw, rrect, paint); | 660 this->drawRRect(draw, rrect, paint); |
661 return; | 661 return; |
662 } | 662 } |
663 } | 663 } |
664 | 664 |
665 CHECK_FOR_ANNOTATION(paint); | 665 CHECK_FOR_ANNOTATION(paint); |
666 CHECK_SHOULD_DRAW(draw); | 666 CHECK_SHOULD_DRAW(draw); |
667 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); | 667 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); |
668 | 668 |
669 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, | 669 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
670 fClip, origSrcPath, paint, | 670 fClip, origSrcPath, paint, |
671 *draw.fMatrix, prePathMatrix, | 671 *draw.fMatrix, prePathMatrix, |
672 draw.fClip->getBounds(), pathIsMutable); | 672 draw.fClip->getBounds(), pathIsMutable); |
673 } | 673 } |
674 | 674 |
675 static const int kBmpSmallTileSize = 1 << 10; | 675 static const int kBmpSmallTileSize = 1 << 10; |
676 | 676 |
677 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 677 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
678 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; | 678 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; |
679 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; | 679 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; |
(...skipping 19 matching lines...) Expand all Loading... |
699 } | 699 } |
700 | 700 |
701 // Given a bitmap, an optional src rect, and a context with a clip and matrix de
termine what | 701 // Given a bitmap, an optional src rect, and a context with a clip and matrix de
termine what |
702 // pixels from the bitmap are necessary. | 702 // pixels from the bitmap are necessary. |
703 static void determine_clipped_src_rect(const GrRenderTarget* rt, | 703 static void determine_clipped_src_rect(const GrRenderTarget* rt, |
704 const GrClip& clip, | 704 const GrClip& clip, |
705 const SkMatrix& viewMatrix, | 705 const SkMatrix& viewMatrix, |
706 const SkISize& imageSize, | 706 const SkISize& imageSize, |
707 const SkRect* srcRectPtr, | 707 const SkRect* srcRectPtr, |
708 SkIRect* clippedSrcIRect) { | 708 SkIRect* clippedSrcIRect) { |
709 clip.getConservativeBounds(rt, clippedSrcIRect, nullptr); | 709 clip.getConservativeBounds(rt->width(), rt->height(), clippedSrcIRect, nullp
tr); |
710 SkMatrix inv; | 710 SkMatrix inv; |
711 if (!viewMatrix.invert(&inv)) { | 711 if (!viewMatrix.invert(&inv)) { |
712 clippedSrcIRect->setEmpty(); | 712 clippedSrcIRect->setEmpty(); |
713 return; | 713 return; |
714 } | 714 } |
715 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect); | 715 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect); |
716 inv.mapRect(&clippedSrcRect); | 716 inv.mapRect(&clippedSrcRect); |
717 if (srcRectPtr) { | 717 if (srcRectPtr) { |
718 // we've setup src space 0,0 to map to the top left of the src rect. | 718 // we've setup src space 0,0 to map to the top left of the src rect. |
719 clippedSrcRect.offset(srcRectPtr->fLeft, srcRectPtr->fTop); | 719 clippedSrcRect.offset(srcRectPtr->fLeft, srcRectPtr->fTop); |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1868 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1869 } | 1869 } |
1870 | 1870 |
1871 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1871 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1872 // We always return a transient cache, so it is freed after each | 1872 // We always return a transient cache, so it is freed after each |
1873 // filter traversal. | 1873 // filter traversal. |
1874 return SkGpuDevice::NewImageFilterCache(); | 1874 return SkGpuDevice::NewImageFilterCache(); |
1875 } | 1875 } |
1876 | 1876 |
1877 #endif | 1877 #endif |
OLD | NEW |