| 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/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 GrPaint grPaint; | 871 GrPaint grPaint; |
| 872 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 872 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
| 873 return; | 873 return; |
| 874 } | 874 } |
| 875 | 875 |
| 876 // If we have a prematrix, apply it to the path, optimizing for the case | 876 // If we have a prematrix, apply it to the path, optimizing for the case |
| 877 // where the original path can in fact be modified in place (even though | 877 // where the original path can in fact be modified in place (even though |
| 878 // its parameter type is const). | 878 // its parameter type is const). |
| 879 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); | 879 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); |
| 880 SkPath tmpPath, effectPath; | 880 SkTLazy<SkPath> tmpPath; |
| 881 SkTLazy<SkPath> effectPath; |
| 881 | 882 |
| 882 if (prePathMatrix) { | 883 if (prePathMatrix) { |
| 883 SkPath* result = pathPtr; | 884 SkPath* result = pathPtr; |
| 884 | 885 |
| 885 if (!pathIsMutable) { | 886 if (!pathIsMutable) { |
| 886 result = &tmpPath; | 887 result = tmpPath.init(); |
| 887 pathIsMutable = true; | 888 pathIsMutable = true; |
| 888 } | 889 } |
| 889 // should I push prePathMatrix on our MV stack temporarily, instead | 890 // should I push prePathMatrix on our MV stack temporarily, instead |
| 890 // of applying it here? See SkDraw.cpp | 891 // of applying it here? See SkDraw.cpp |
| 891 pathPtr->transform(*prePathMatrix, result); | 892 pathPtr->transform(*prePathMatrix, result); |
| 892 pathPtr = result; | 893 pathPtr = result; |
| 893 } | 894 } |
| 894 // at this point we're done with prePathMatrix | 895 // at this point we're done with prePathMatrix |
| 895 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 896 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 896 | 897 |
| 897 SkStrokeRec stroke(paint); | 898 SkStrokeRec stroke(paint); |
| 898 SkPathEffect* pathEffect = paint.getPathEffect(); | 899 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 899 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 900 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 900 if (pathEffect && pathEffect->filterPath(&effectPath, *pathPtr, &stroke, | 901 if (pathEffect && pathEffect->filterPath(effectPath.init(), *pathPtr, &strok
e, |
| 901 cullRect)) { | 902 cullRect)) { |
| 902 pathPtr = &effectPath; | 903 pathPtr = effectPath.get(); |
| 904 pathIsMutable = true; |
| 903 } | 905 } |
| 904 | 906 |
| 905 if (paint.getMaskFilter()) { | 907 if (paint.getMaskFilter()) { |
| 906 if (!stroke.isHairlineStyle()) { | 908 if (!stroke.isHairlineStyle()) { |
| 907 if (stroke.applyToPath(&tmpPath, *pathPtr)) { | 909 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); |
| 908 pathPtr = &tmpPath; | 910 if (stroke.applyToPath(strokedPath, *pathPtr)) { |
| 911 pathPtr = strokedPath; |
| 909 pathIsMutable = true; | 912 pathIsMutable = true; |
| 910 stroke.setFillStyle(); | 913 stroke.setFillStyle(); |
| 911 } | 914 } |
| 912 } | 915 } |
| 913 | 916 |
| 914 // avoid possibly allocating a new path in transform if we can | 917 // avoid possibly allocating a new path in transform if we can |
| 915 SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath; | 918 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); |
| 916 | 919 |
| 917 // transform the path into device space | 920 // transform the path into device space |
| 918 pathPtr->transform(fContext->getMatrix(), devPathPtr); | 921 pathPtr->transform(fContext->getMatrix(), devPathPtr); |
| 919 | 922 |
| 920 SkRect maskRect; | 923 SkRect maskRect; |
| 921 if (paint.getMaskFilter()->canFilterMaskGPU(devPathPtr->getBounds(), | 924 if (paint.getMaskFilter()->canFilterMaskGPU(devPathPtr->getBounds(), |
| 922 draw.fClip->getBounds(), | 925 draw.fClip->getBounds(), |
| 923 fContext->getMatrix(), | 926 fContext->getMatrix(), |
| 924 &maskRect)) { | 927 &maskRect)) { |
| 925 // The context's matrix may change while creating the mask, so save
the CTM here to | 928 // The context's matrix may change while creating the mask, so save
the CTM here to |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 GrTexture* texture, | 1962 GrTexture* texture, |
| 1960 bool needClear) | 1963 bool needClear) |
| 1961 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1964 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1962 | 1965 |
| 1963 SkASSERT(texture && texture->asRenderTarget()); | 1966 SkASSERT(texture && texture->asRenderTarget()); |
| 1964 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1967 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
| 1965 // cache. We pass true for the third argument so that it will get unlocked. | 1968 // cache. We pass true for the third argument so that it will get unlocked. |
| 1966 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1969 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1967 fNeedClear = needClear; | 1970 fNeedClear = needClear; |
| 1968 } | 1971 } |
| OLD | NEW |