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

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

Issue 38573007: Do not apply hairline optimization for paths if nv_path_rendering is used (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
11 #include "effects/GrSimpleTextureEffect.h" 11 #include "effects/GrSimpleTextureEffect.h"
12 12
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrBitmapTextContext.h" 14 #include "GrBitmapTextContext.h"
15 15 #include "GrGpu.h"
16 #include "GrDrawTargetCaps.h"
16 #include "SkGrTexturePixelRef.h" 17 #include "SkGrTexturePixelRef.h"
17 18
18 #include "SkColorFilter.h" 19 #include "SkColorFilter.h"
19 #include "SkDeviceImageFilterProxy.h" 20 #include "SkDeviceImageFilterProxy.h"
20 #include "SkDrawProcs.h" 21 #include "SkDrawProcs.h"
21 #include "SkGlyphCache.h" 22 #include "SkGlyphCache.h"
22 #include "SkImageFilter.h" 23 #include "SkImageFilter.h"
23 #include "SkPathEffect.h" 24 #include "SkPathEffect.h"
24 #include "SkRRect.h" 25 #include "SkRRect.h"
25 #include "SkStroke.h" 26 #include "SkStroke.h"
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 849
849 SkBitmap wrap_texture(GrTexture* texture) { 850 SkBitmap wrap_texture(GrTexture* texture) {
850 SkBitmap result; 851 SkBitmap result;
851 bool dummy; 852 bool dummy;
852 SkBitmap::Config config = grConfig2skConfig(texture->config(), &dummy); 853 SkBitmap::Config config = grConfig2skConfig(texture->config(), &dummy);
853 result.setConfig(config, texture->width(), texture->height()); 854 result.setConfig(config, texture->width(), texture->height());
854 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref(); 855 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref();
855 return result; 856 return result;
856 } 857 }
857 858
859 bool treat_paint_as_hairline(const SkPaint& paint, const GrContext* context, SkS calar* hairlineCoverage) {
bsalomon 2013/10/24 13:28:36 Kimmo, maybe we can do this check from GrContext::
Kimmo Kinnunen 2013/10/30 09:33:41 Done.
860 return !context->getGpu()->caps()->pathRenderingSupport() &&
861 SkDrawTreatAsHairline(paint, context->getMatrix(), hairlineCoverage);
862 }
863
858 }; 864 };
859 865
860 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 866 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
861 const SkPaint& paint, const SkMatrix* prePathMatrix, 867 const SkPaint& paint, const SkMatrix* prePathMatrix,
862 bool pathIsMutable) { 868 bool pathIsMutable) {
863 CHECK_FOR_NODRAW_ANNOTATION(paint); 869 CHECK_FOR_NODRAW_ANNOTATION(paint);
864 CHECK_SHOULD_DRAW(draw, false); 870 CHECK_SHOULD_DRAW(draw, false);
865 871
866 GrPaint grPaint; 872 GrPaint grPaint;
867 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { 873 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
868 return; 874 return;
869 } 875 }
870 876
871 // can we cheat, and treat a thin stroke as a hairline w/ coverage 877 // can we cheat, and treat a thin stroke as a hairline w/ coverage
872 // if we can, we draw lots faster (raster device does this same test) 878 // if we can, we draw lots faster (raster device does this same test)
873 SkScalar hairlineCoverage; 879 SkScalar hairlineCoverage;
874 bool doHairLine = SkDrawTreatAsHairline(paint, fContext->getMatrix(), &hairl ineCoverage); 880 bool doHairLine = treat_paint_as_hairline(paint, fContext, &hairlineCoverage );
875 if (doHairLine) { 881 if (doHairLine) {
876 grPaint.setCoverage(SkScalarRoundToInt(hairlineCoverage * grPaint.getCov erage())); 882 grPaint.setCoverage(SkScalarRoundToInt(hairlineCoverage * grPaint.getCov erage()));
877 } 883 }
878 884
879 // If we have a prematrix, apply it to the path, optimizing for the case 885 // If we have a prematrix, apply it to the path, optimizing for the case
880 // where the original path can in fact be modified in place (even though 886 // where the original path can in fact be modified in place (even though
881 // its parameter type is const). 887 // its parameter type is const).
882 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); 888 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath);
883 SkPath tmpPath, effectPath; 889 SkPath tmpPath, effectPath;
884 890
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 GrTexture* texture, 1852 GrTexture* texture,
1847 bool needClear) 1853 bool needClear)
1848 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1854 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1849 1855
1850 SkASSERT(texture && texture->asRenderTarget()); 1856 SkASSERT(texture && texture->asRenderTarget());
1851 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1857 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1852 // cache. We pass true for the third argument so that it will get unlocked. 1858 // cache. We pass true for the third argument so that it will get unlocked.
1853 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1859 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1854 fNeedClear = needClear; 1860 fNeedClear = needClear;
1855 } 1861 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698