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

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

Issue 193193002: plumbing for GPU fast blur (Closed) Base URL: https://skia.googlesource.com/skia.git@fast_rrect_blur_cpu_plumb
Patch Set: fix indentation issue Created 6 years, 9 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/SkBlurMaskFilter.cpp ('k') | no next file » | 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/GrTextureDomain.h" 11 #include "effects/GrTextureDomain.h"
12 #include "effects/GrSimpleTextureEffect.h" 12 #include "effects/GrSimpleTextureEffect.h"
13 13
14 #include "GrContext.h" 14 #include "GrContext.h"
15 #include "GrBitmapTextContext.h" 15 #include "GrBitmapTextContext.h"
16 #if SK_DISTANCEFIELD_FONTS 16 #if SK_DISTANCEFIELD_FONTS
17 #include "GrDistanceFieldTextContext.h" 17 #include "GrDistanceFieldTextContext.h"
18 #endif 18 #endif
19 19
20 #include "SkGrTexturePixelRef.h" 20 #include "SkGrTexturePixelRef.h"
21 21
22 #include "SkBounder.h"
22 #include "SkColorFilter.h" 23 #include "SkColorFilter.h"
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"
28 #include "SkMaskFilter.h"
27 #include "SkPathEffect.h" 29 #include "SkPathEffect.h"
28 #include "SkRRect.h" 30 #include "SkRRect.h"
29 #include "SkStroke.h" 31 #include "SkStroke.h"
30 #include "SkSurface.h" 32 #include "SkSurface.h"
31 #include "SkTLazy.h" 33 #include "SkTLazy.h"
32 #include "SkUtils.h" 34 #include "SkUtils.h"
33 #include "SkErrorInternals.h" 35 #include "SkErrorInternals.h"
34 36
35 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 37 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1
36 38
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 734 }
733 } 735 }
734 736
735 /////////////////////////////////////////////////////////////////////////////// 737 ///////////////////////////////////////////////////////////////////////////////
736 738
737 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 739 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
738 const SkPaint& paint) { 740 const SkPaint& paint) {
739 CHECK_FOR_ANNOTATION(paint); 741 CHECK_FOR_ANNOTATION(paint);
740 CHECK_SHOULD_DRAW(draw, false); 742 CHECK_SHOULD_DRAW(draw, false);
741 743
744 GrPaint grPaint;
745 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
746 return;
747 }
748
749 SkStrokeRec stroke(paint);
750 if (paint.getMaskFilter()) {
751 // try to hit the fast path for drawing filtered round rects
752
753 SkRRect devRRect;
754 if (rect.transform(fContext->getMatrix(), &devRRect)) {
755 if (devRRect.allCornersCircular()) {
756 SkRect maskRect;
757 if (paint.getMaskFilter()->canFilterMaskGPU(devRRect.rect(),
758 draw.fClip->getBounds(),
759 fContext->getMatrix(),
760 &maskRect)) {
761 SkIRect finalIRect;
762 maskRect.roundOut(&finalIRect);
763 if (draw.fClip->quickReject(finalIRect)) {
764 // clipped out
765 return;
766 }
767 if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIR ect)) {
768 // nothing to draw
769 return;
770 }
771 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext , &grPaint,
772 stroke, devRRect)) {
773 return;
774 }
775 }
776
777 }
778 }
779
780 }
781
742 bool usePath = !rect.isSimple(); 782 bool usePath = !rect.isSimple();
743 // another two reasons we might need to call drawPath... 783 // another two reasons we might need to call drawPath...
744 if (paint.getMaskFilter() || paint.getPathEffect()) { 784 if (paint.getMaskFilter() || paint.getPathEffect()) {
745 usePath = true; 785 usePath = true;
746 } 786 }
747 // until we can rotate rrects... 787 // until we can rotate rrects...
748 if (!usePath && !fContext->getMatrix().rectStaysRect()) { 788 if (!usePath && !fContext->getMatrix().rectStaysRect()) {
749 usePath = true; 789 usePath = true;
750 } 790 }
751 791
752 if (usePath) { 792 if (usePath) {
753 SkPath path; 793 SkPath path;
754 path.addRRect(rect); 794 path.addRRect(rect);
755 this->drawPath(draw, path, paint, NULL, true); 795 this->drawPath(draw, path, paint, NULL, true);
756 return; 796 return;
757 } 797 }
758 798
759 GrPaint grPaint;
760 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
761 return;
762 }
763
764 SkStrokeRec stroke(paint);
765 fContext->drawRRect(grPaint, rect, stroke); 799 fContext->drawRRect(grPaint, rect, stroke);
766 } 800 }
767 801
768 /////////////////////////////////////////////////////////////////////////////// 802 /////////////////////////////////////////////////////////////////////////////
769 803
770 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, 804 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
771 const SkPaint& paint) { 805 const SkPaint& paint) {
772 CHECK_FOR_ANNOTATION(paint); 806 CHECK_FOR_ANNOTATION(paint);
773 CHECK_SHOULD_DRAW(draw, false); 807 CHECK_SHOULD_DRAW(draw, false);
774 808
775 bool usePath = false; 809 bool usePath = false;
776 // some basic reasons we might need to call drawPath... 810 // some basic reasons we might need to call drawPath...
777 if (paint.getMaskFilter() || paint.getPathEffect()) { 811 if (paint.getMaskFilter() || paint.getPathEffect()) {
778 usePath = true; 812 usePath = true;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 if (draw.fClip->quickReject(finalIRect)) { 1038 if (draw.fClip->quickReject(finalIRect)) {
1005 // clipped out 1039 // clipped out
1006 return; 1040 return;
1007 } 1041 }
1008 if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) { 1042 if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
1009 // nothing to draw 1043 // nothing to draw
1010 return; 1044 return;
1011 } 1045 }
1012 1046
1013 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint, 1047 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
1014 SkStrokeRec(paint), * devPathPtr)) { 1048 stroke, *devPathPtr)) {
1015 // the mask filter was able to draw itself directly, so there's nothing 1049 // the mask filter was able to draw itself directly, so there's nothing
1016 // left to do. 1050 // left to do.
1017 return; 1051 return;
1018 } 1052 }
1019 1053
1020 GrAutoScratchTexture mask; 1054 GrAutoScratchTexture mask;
1021 1055
1022 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, 1056 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke,
1023 grPaint.isAntiAlias(), &mask)) { 1057 grPaint.isAntiAlias(), &mask)) {
1024 GrTexture* filtered; 1058 GrTexture* filtered;
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 GrTexture* texture, 2004 GrTexture* texture,
1971 bool needClear) 2005 bool needClear)
1972 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 2006 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1973 2007
1974 SkASSERT(texture && texture->asRenderTarget()); 2008 SkASSERT(texture && texture->asRenderTarget());
1975 // This constructor is called from onCreateDevice. It has locked the RT in t he texture 2009 // This constructor is called from onCreateDevice. It has locked the RT in t he texture
1976 // cache. We pass true for the third argument so that it will get unlocked. 2010 // cache. We pass true for the third argument so that it will get unlocked.
1977 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 2011 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1978 fNeedClear = needClear; 2012 fNeedClear = needClear;
1979 } 2013 }
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698