| 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 | 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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 const SkPaint& paint, const SkMatrix* prePathMatrix, | 862 const SkPaint& paint, const SkMatrix* prePathMatrix, |
| 862 bool pathIsMutable) { | 863 bool pathIsMutable) { |
| 863 CHECK_FOR_NODRAW_ANNOTATION(paint); | 864 CHECK_FOR_NODRAW_ANNOTATION(paint); |
| 864 CHECK_SHOULD_DRAW(draw, false); | 865 CHECK_SHOULD_DRAW(draw, false); |
| 865 | 866 |
| 866 GrPaint grPaint; | 867 GrPaint grPaint; |
| 867 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 868 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
| 868 return; | 869 return; |
| 869 } | 870 } |
| 870 | 871 |
| 871 // 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) | |
| 873 SkScalar hairlineCoverage; | |
| 874 bool doHairLine = SkDrawTreatAsHairline(paint, fContext->getMatrix(), &hairl
ineCoverage); | |
| 875 if (doHairLine) { | |
| 876 grPaint.setCoverage(SkScalarRoundToInt(hairlineCoverage * grPaint.getCov
erage())); | |
| 877 } | |
| 878 | |
| 879 // If we have a prematrix, apply it to the path, optimizing for the case | 872 // 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 | 873 // where the original path can in fact be modified in place (even though |
| 881 // its parameter type is const). | 874 // its parameter type is const). |
| 882 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); | 875 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); |
| 883 SkPath tmpPath, effectPath; | 876 SkPath tmpPath, effectPath; |
| 884 | 877 |
| 885 if (prePathMatrix) { | 878 if (prePathMatrix) { |
| 886 SkPath* result = pathPtr; | 879 SkPath* result = pathPtr; |
| 887 | 880 |
| 888 if (!pathIsMutable) { | 881 if (!pathIsMutable) { |
| 889 result = &tmpPath; | 882 result = &tmpPath; |
| 890 pathIsMutable = true; | 883 pathIsMutable = true; |
| 891 } | 884 } |
| 892 // should I push prePathMatrix on our MV stack temporarily, instead | 885 // should I push prePathMatrix on our MV stack temporarily, instead |
| 893 // of applying it here? See SkDraw.cpp | 886 // of applying it here? See SkDraw.cpp |
| 894 pathPtr->transform(*prePathMatrix, result); | 887 pathPtr->transform(*prePathMatrix, result); |
| 895 pathPtr = result; | 888 pathPtr = result; |
| 896 } | 889 } |
| 897 // at this point we're done with prePathMatrix | 890 // at this point we're done with prePathMatrix |
| 898 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 891 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 899 | 892 |
| 900 SkStrokeRec stroke(paint); | 893 SkStrokeRec stroke(paint); |
| 901 SkPathEffect* pathEffect = paint.getPathEffect(); | 894 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 902 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 895 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 903 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, | 896 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, |
| 904 cullRect)) { | 897 cullRect)) { |
| 905 pathPtr = &effectPath; | 898 pathPtr = &effectPath; |
| 906 } | 899 } |
| 907 | 900 |
| 908 if (!pathEffect && doHairLine) { | |
| 909 stroke.setHairlineStyle(); | |
| 910 } | |
| 911 | |
| 912 if (paint.getMaskFilter()) { | 901 if (paint.getMaskFilter()) { |
| 913 if (!stroke.isHairlineStyle()) { | 902 if (!stroke.isHairlineStyle()) { |
| 914 if (stroke.applyToPath(&tmpPath, *pathPtr)) { | 903 if (stroke.applyToPath(&tmpPath, *pathPtr)) { |
| 915 pathPtr = &tmpPath; | 904 pathPtr = &tmpPath; |
| 916 pathIsMutable = true; | 905 pathIsMutable = true; |
| 917 stroke.setFillStyle(); | 906 stroke.setFillStyle(); |
| 918 } | 907 } |
| 919 } | 908 } |
| 920 | 909 |
| 921 // avoid possibly allocating a new path in transform if we can | 910 // avoid possibly allocating a new path in transform if we can |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 GrTexture* texture, | 1840 GrTexture* texture, |
| 1852 bool needClear) | 1841 bool needClear) |
| 1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1842 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1854 | 1843 |
| 1855 SkASSERT(texture && texture->asRenderTarget()); | 1844 SkASSERT(texture && texture->asRenderTarget()); |
| 1856 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1845 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
| 1857 // cache. We pass true for the third argument so that it will get unlocked. | 1846 // cache. We pass true for the third argument so that it will get unlocked. |
| 1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1847 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1859 fNeedClear = needClear; | 1848 fNeedClear = needClear; |
| 1860 } | 1849 } |
| OLD | NEW |