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 "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 #include "GrGpu.h" | 15 |
16 #include "GrDrawTargetCaps.h" | |
17 #include "SkGrTexturePixelRef.h" | 16 #include "SkGrTexturePixelRef.h" |
18 | 17 |
19 #include "SkColorFilter.h" | 18 #include "SkColorFilter.h" |
20 #include "SkDeviceImageFilterProxy.h" | 19 #include "SkDeviceImageFilterProxy.h" |
21 #include "SkDrawProcs.h" | 20 #include "SkDrawProcs.h" |
22 #include "SkGlyphCache.h" | 21 #include "SkGlyphCache.h" |
23 #include "SkImageFilter.h" | 22 #include "SkImageFilter.h" |
24 #include "SkPathEffect.h" | 23 #include "SkPathEffect.h" |
25 #include "SkRRect.h" | 24 #include "SkRRect.h" |
26 #include "SkStroke.h" | 25 #include "SkStroke.h" |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 const SkPaint& paint, const SkMatrix* prePathMatrix, | 843 const SkPaint& paint, const SkMatrix* prePathMatrix, |
845 bool pathIsMutable) { | 844 bool pathIsMutable) { |
846 CHECK_FOR_ANNOTATION(paint); | 845 CHECK_FOR_ANNOTATION(paint); |
847 CHECK_SHOULD_DRAW(draw, false); | 846 CHECK_SHOULD_DRAW(draw, false); |
848 | 847 |
849 GrPaint grPaint; | 848 GrPaint grPaint; |
850 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 849 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
851 return; | 850 return; |
852 } | 851 } |
853 | 852 |
| 853 // can we cheat, and treat a thin stroke as a hairline w/ coverage |
| 854 // if we can, we draw lots faster (raster device does this same test) |
| 855 SkScalar hairlineCoverage; |
| 856 bool doHairLine = SkDrawTreatAsHairline(paint, fContext->getMatrix(), &hairl
ineCoverage); |
| 857 if (doHairLine) { |
| 858 grPaint.setCoverage(SkScalarRoundToInt(hairlineCoverage * grPaint.getCov
erage())); |
| 859 } |
| 860 |
854 // If we have a prematrix, apply it to the path, optimizing for the case | 861 // If we have a prematrix, apply it to the path, optimizing for the case |
855 // where the original path can in fact be modified in place (even though | 862 // where the original path can in fact be modified in place (even though |
856 // its parameter type is const). | 863 // its parameter type is const). |
857 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); | 864 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); |
858 SkPath tmpPath, effectPath; | 865 SkPath tmpPath, effectPath; |
859 | 866 |
860 if (prePathMatrix) { | 867 if (prePathMatrix) { |
861 SkPath* result = pathPtr; | 868 SkPath* result = pathPtr; |
862 | 869 |
863 if (!pathIsMutable) { | 870 if (!pathIsMutable) { |
864 result = &tmpPath; | 871 result = &tmpPath; |
865 pathIsMutable = true; | 872 pathIsMutable = true; |
866 } | 873 } |
867 // should I push prePathMatrix on our MV stack temporarily, instead | 874 // should I push prePathMatrix on our MV stack temporarily, instead |
868 // of applying it here? See SkDraw.cpp | 875 // of applying it here? See SkDraw.cpp |
869 pathPtr->transform(*prePathMatrix, result); | 876 pathPtr->transform(*prePathMatrix, result); |
870 pathPtr = result; | 877 pathPtr = result; |
871 } | 878 } |
872 // at this point we're done with prePathMatrix | 879 // at this point we're done with prePathMatrix |
873 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 880 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
874 | 881 |
875 SkStrokeRec stroke(paint); | 882 SkStrokeRec stroke(paint); |
876 SkPathEffect* pathEffect = paint.getPathEffect(); | 883 SkPathEffect* pathEffect = paint.getPathEffect(); |
877 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 884 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
878 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, | 885 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, |
879 cullRect)) { | 886 cullRect)) { |
880 pathPtr = &effectPath; | 887 pathPtr = &effectPath; |
881 } | 888 } |
882 | 889 |
| 890 if (!pathEffect && doHairLine) { |
| 891 stroke.setHairlineStyle(); |
| 892 } |
| 893 |
883 if (paint.getMaskFilter()) { | 894 if (paint.getMaskFilter()) { |
884 if (!stroke.isHairlineStyle()) { | 895 if (!stroke.isHairlineStyle()) { |
885 if (stroke.applyToPath(&tmpPath, *pathPtr)) { | 896 if (stroke.applyToPath(&tmpPath, *pathPtr)) { |
886 pathPtr = &tmpPath; | 897 pathPtr = &tmpPath; |
887 pathIsMutable = true; | 898 pathIsMutable = true; |
888 stroke.setFillStyle(); | 899 stroke.setFillStyle(); |
889 } | 900 } |
890 } | 901 } |
891 | 902 |
892 // avoid possibly allocating a new path in transform if we can | 903 // avoid possibly allocating a new path in transform if we can |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 GrTexture* texture, | 1833 GrTexture* texture, |
1823 bool needClear) | 1834 bool needClear) |
1824 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1835 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1825 | 1836 |
1826 SkASSERT(texture && texture->asRenderTarget()); | 1837 SkASSERT(texture && texture->asRenderTarget()); |
1827 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1838 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1828 // cache. We pass true for the third argument so that it will get unlocked. | 1839 // cache. We pass true for the third argument so that it will get unlocked. |
1829 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1840 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1830 fNeedClear = needClear; | 1841 fNeedClear = needClear; |
1831 } | 1842 } |
OLD | NEW |