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

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: address problems 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 | « src/gpu/GrPathRenderer.h ('k') | src/gpu/gl/GrGLProgram.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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 const SkPaint& paint, const SkMatrix* prePathMatrix, 839 const SkPaint& paint, const SkMatrix* prePathMatrix,
840 bool pathIsMutable) { 840 bool pathIsMutable) {
841 CHECK_FOR_ANNOTATION(paint); 841 CHECK_FOR_ANNOTATION(paint);
842 CHECK_SHOULD_DRAW(draw, false); 842 CHECK_SHOULD_DRAW(draw, false);
843 843
844 GrPaint grPaint; 844 GrPaint grPaint;
845 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { 845 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
846 return; 846 return;
847 } 847 }
848 848
849 // can we cheat, and treat a thin stroke as a hairline w/ coverage
850 // if we can, we draw lots faster (raster device does this same test)
851 SkScalar hairlineCoverage;
852 bool doHairLine = SkDrawTreatAsHairline(paint, fContext->getMatrix(), &hairl ineCoverage);
853 if (doHairLine) {
854 grPaint.setCoverage(SkScalarRoundToInt(hairlineCoverage * grPaint.getCov erage()));
855 }
856
857 // If we have a prematrix, apply it to the path, optimizing for the case 849 // If we have a prematrix, apply it to the path, optimizing for the case
858 // where the original path can in fact be modified in place (even though 850 // where the original path can in fact be modified in place (even though
859 // its parameter type is const). 851 // its parameter type is const).
860 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); 852 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath);
861 SkPath tmpPath, effectPath; 853 SkPath tmpPath, effectPath;
862 854
863 if (prePathMatrix) { 855 if (prePathMatrix) {
864 SkPath* result = pathPtr; 856 SkPath* result = pathPtr;
865 857
866 if (!pathIsMutable) { 858 if (!pathIsMutable) {
867 result = &tmpPath; 859 result = &tmpPath;
868 pathIsMutable = true; 860 pathIsMutable = true;
869 } 861 }
870 // should I push prePathMatrix on our MV stack temporarily, instead 862 // should I push prePathMatrix on our MV stack temporarily, instead
871 // of applying it here? See SkDraw.cpp 863 // of applying it here? See SkDraw.cpp
872 pathPtr->transform(*prePathMatrix, result); 864 pathPtr->transform(*prePathMatrix, result);
873 pathPtr = result; 865 pathPtr = result;
874 } 866 }
875 // at this point we're done with prePathMatrix 867 // at this point we're done with prePathMatrix
876 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) 868 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
877 869
878 SkStrokeRec stroke(paint); 870 SkStrokeRec stroke(paint);
879 SkPathEffect* pathEffect = paint.getPathEffect(); 871 SkPathEffect* pathEffect = paint.getPathEffect();
880 const SkRect* cullRect = NULL; // TODO: what is our bounds? 872 const SkRect* cullRect = NULL; // TODO: what is our bounds?
881 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, 873 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke,
882 cullRect)) { 874 cullRect)) {
883 pathPtr = &effectPath; 875 pathPtr = &effectPath;
884 } 876 }
885 877
886 if (!pathEffect && doHairLine) {
887 stroke.setHairlineStyle();
888 }
889
890 if (paint.getMaskFilter()) { 878 if (paint.getMaskFilter()) {
891 if (!stroke.isHairlineStyle()) { 879 if (!stroke.isHairlineStyle()) {
892 if (stroke.applyToPath(&tmpPath, *pathPtr)) { 880 if (stroke.applyToPath(&tmpPath, *pathPtr)) {
893 pathPtr = &tmpPath; 881 pathPtr = &tmpPath;
894 pathIsMutable = true; 882 pathIsMutable = true;
895 stroke.setFillStyle(); 883 stroke.setFillStyle();
896 } 884 }
897 } 885 }
898 886
899 // avoid possibly allocating a new path in transform if we can 887 // avoid possibly allocating a new path in transform if we can
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 GrTexture* texture, 1831 GrTexture* texture,
1844 bool needClear) 1832 bool needClear)
1845 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1833 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1846 1834
1847 SkASSERT(texture && texture->asRenderTarget()); 1835 SkASSERT(texture && texture->asRenderTarget());
1848 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1836 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1849 // cache. We pass true for the third argument so that it will get unlocked. 1837 // cache. We pass true for the third argument so that it will get unlocked.
1850 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1838 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1851 fNeedClear = needClear; 1839 fNeedClear = needClear;
1852 } 1840 }
OLDNEW
« no previous file with comments | « src/gpu/GrPathRenderer.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698