Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 312553006: remove SkBounder -- unused and unloved (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20
21 #include "SkGrTexturePixelRef.h" 21 #include "SkGrTexturePixelRef.h"
22 22
23 #include "SkBounder.h"
24 #include "SkDeviceImageFilterProxy.h" 23 #include "SkDeviceImageFilterProxy.h"
25 #include "SkDrawProcs.h" 24 #include "SkDrawProcs.h"
26 #include "SkGlyphCache.h" 25 #include "SkGlyphCache.h"
27 #include "SkImageFilter.h" 26 #include "SkImageFilter.h"
28 #include "SkMaskFilter.h" 27 #include "SkMaskFilter.h"
29 #include "SkPathEffect.h" 28 #include "SkPathEffect.h"
30 #include "SkPicture.h" 29 #include "SkPicture.h"
31 #include "SkPicturePlayback.h" 30 #include "SkPicturePlayback.h"
32 #include "SkRRect.h" 31 #include "SkRRect.h"
33 #include "SkStroke.h" 32 #include "SkStroke.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(), 524 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(),
526 draw.fClip->getBounds(), 525 draw.fClip->getBounds(),
527 fContext->getMatrix(), 526 fContext->getMatrix(),
528 &maskRect)) { 527 &maskRect)) {
529 SkIRect finalIRect; 528 SkIRect finalIRect;
530 maskRect.roundOut(&finalIRect); 529 maskRect.roundOut(&finalIRect);
531 if (draw.fClip->quickReject(finalIRect)) { 530 if (draw.fClip->quickReject(finalIRect)) {
532 // clipped out 531 // clipped out
533 return; 532 return;
534 } 533 }
535 if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIR ect)) {
536 // nothing to draw
537 return;
538 }
539 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext , &grPaint, 534 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext , &grPaint,
540 stroke, devRRect)) { 535 stroke, devRRect)) {
541 return; 536 return;
542 } 537 }
543 } 538 }
544 539
545 } 540 }
546 } 541 }
547 542
548 } 543 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 599 }
605 600
606 GrPaint grPaint; 601 GrPaint grPaint;
607 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 602 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
608 SkStrokeRec stroke(paint); 603 SkStrokeRec stroke(paint);
609 604
610 fContext->drawOval(grPaint, oval, stroke); 605 fContext->drawOval(grPaint, oval, stroke);
611 } 606 }
612 607
613 #include "SkMaskFilter.h" 608 #include "SkMaskFilter.h"
614 #include "SkBounder.h"
615 609
616 /////////////////////////////////////////////////////////////////////////////// 610 ///////////////////////////////////////////////////////////////////////////////
617 611
618 // helpers for applying mask filters 612 // helpers for applying mask filters
619 namespace { 613 namespace {
620 614
621 // Draw a mask using the supplied paint. Since the coverage/geometry 615 // Draw a mask using the supplied paint. Since the coverage/geometry
622 // is already burnt into the mask this boils down to a rect draw. 616 // is already burnt into the mask this boils down to a rect draw.
623 // Return true if the mask was successfully drawn. 617 // Return true if the mask was successfully drawn.
624 bool draw_mask(GrContext* context, const SkRect& maskRect, 618 bool draw_mask(GrContext* context, const SkRect& maskRect,
625 GrPaint* grp, GrTexture* mask) { 619 GrPaint* grp, GrTexture* mask) {
626 GrContext::AutoMatrix am; 620 GrContext::AutoMatrix am;
627 if (!am.setIdentity(context, grp)) { 621 if (!am.setIdentity(context, grp)) {
628 return false; 622 return false;
629 } 623 }
630 624
631 SkMatrix matrix; 625 SkMatrix matrix;
632 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop); 626 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
633 matrix.postIDiv(mask->width(), mask->height()); 627 matrix.postIDiv(mask->width(), mask->height());
634 628
635 grp->addCoverageEffect(GrSimpleTextureEffect::Create(mask, matrix))->unref() ; 629 grp->addCoverageEffect(GrSimpleTextureEffect::Create(mask, matrix))->unref() ;
636 context->drawRect(*grp, maskRect); 630 context->drawRect(*grp, maskRect);
637 return true; 631 return true;
638 } 632 }
639 633
640 bool draw_with_mask_filter(GrContext* context, const SkPath& devPath, 634 bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
641 SkMaskFilter* filter, const SkRegion& clip, SkBounder * bounder, 635 SkMaskFilter* filter, const SkRegion& clip,
642 GrPaint* grp, SkPaint::Style style) { 636 GrPaint* grp, SkPaint::Style style) {
643 SkMask srcM, dstM; 637 SkMask srcM, dstM;
644 638
645 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &context->getMat rix(), &srcM, 639 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &context->getMat rix(), &srcM,
646 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty le)) { 640 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty le)) {
647 return false; 641 return false;
648 } 642 }
649 SkAutoMaskFreeImage autoSrc(srcM.fImage); 643 SkAutoMaskFreeImage autoSrc(srcM.fImage);
650 644
651 if (!filter->filterMask(&dstM, srcM, context->getMatrix(), NULL)) { 645 if (!filter->filterMask(&dstM, srcM, context->getMatrix(), NULL)) {
652 return false; 646 return false;
653 } 647 }
654 // this will free-up dstM when we're done (allocated in filterMask()) 648 // this will free-up dstM when we're done (allocated in filterMask())
655 SkAutoMaskFreeImage autoDst(dstM.fImage); 649 SkAutoMaskFreeImage autoDst(dstM.fImage);
656 650
657 if (clip.quickReject(dstM.fBounds)) { 651 if (clip.quickReject(dstM.fBounds)) {
658 return false; 652 return false;
659 } 653 }
660 if (bounder && !bounder->doIRect(dstM.fBounds)) {
661 return false;
662 }
663 654
664 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using 655 // we now have a device-aligned 8bit mask in dstM, ready to be drawn using
665 // the current clip (and identity matrix) and GrPaint settings 656 // the current clip (and identity matrix) and GrPaint settings
666 GrTextureDesc desc; 657 GrTextureDesc desc;
667 desc.fWidth = dstM.fBounds.width(); 658 desc.fWidth = dstM.fBounds.width();
668 desc.fHeight = dstM.fBounds.height(); 659 desc.fHeight = dstM.fBounds.height();
669 desc.fConfig = kAlpha_8_GrPixelConfig; 660 desc.fConfig = kAlpha_8_GrPixelConfig;
670 661
671 GrAutoScratchTexture ast(context, desc); 662 GrAutoScratchTexture ast(context, desc);
672 GrTexture* texture = ast.texture(); 663 GrTexture* texture = ast.texture();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // The context's matrix may change while creating the mask, so save the CTM here to 803 // The context's matrix may change while creating the mask, so save the CTM here to
813 // pass to filterMaskGPU. 804 // pass to filterMaskGPU.
814 const SkMatrix ctm = fContext->getMatrix(); 805 const SkMatrix ctm = fContext->getMatrix();
815 806
816 SkIRect finalIRect; 807 SkIRect finalIRect;
817 maskRect.roundOut(&finalIRect); 808 maskRect.roundOut(&finalIRect);
818 if (draw.fClip->quickReject(finalIRect)) { 809 if (draw.fClip->quickReject(finalIRect)) {
819 // clipped out 810 // clipped out
820 return; 811 return;
821 } 812 }
822 if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
823 // nothing to draw
824 return;
825 }
826 813
827 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, 814 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
828 stroke, *devPathPtr)) { 815 stroke, *devPathPtr)) {
829 // the mask filter was able to draw itself directly, so there's nothing 816 // the mask filter was able to draw itself directly, so there's nothing
830 // left to do. 817 // left to do.
831 return; 818 return;
832 } 819 }
833 820
834 GrAutoScratchTexture mask; 821 GrAutoScratchTexture mask;
835 822
(...skipping 19 matching lines...) Expand all
855 return; 842 return;
856 } 843 }
857 } 844 }
858 } 845 }
859 } 846 }
860 847
861 // draw the mask on the CPU - this is a fallthrough path in case the 848 // draw the mask on the CPU - this is a fallthrough path in case the
862 // GPU path fails 849 // GPU path fails
863 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style : 850 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style :
864 SkPaint::kFill_Style; 851 SkPaint::kFill_Style;
865 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), 852 draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *dra w.fClip, &grPaint,
866 *draw.fClip, draw.fBounder, &grPaint, style); 853 style);
867 return; 854 return;
868 } 855 }
869 856
870 fContext->drawPath(grPaint, *pathPtr, stroke); 857 fContext->drawPath(grPaint, *pathPtr, stroke);
871 } 858 }
872 859
873 static const int kBmpSmallTileSize = 1 << 10; 860 static const int kBmpSmallTileSize = 1 << 10;
874 861
875 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { 862 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) {
876 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; 863 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1;
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i); 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict ure, i);
2020 2007
2021 if (NULL != layer->getTexture()) { 2008 if (NULL != layer->getTexture()) {
2022 fContext->unlockScratchTexture(layer->getTexture()); 2009 fContext->unlockScratchTexture(layer->getTexture());
2023 layer->setTexture(NULL); 2010 layer->setTexture(NULL);
2024 } 2011 }
2025 } 2012 }
2026 2013
2027 return true; 2014 return true;
2028 } 2015 }
OLDNEW
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698