OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
9 | 9 |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPa
int, | 844 bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPa
int, |
845 const SkMatrix& viewM, bool constantColor, GrPaint* grPaint
) { | 845 const SkMatrix& viewM, bool constantColor, GrPaint* grPaint
) { |
846 SkShader* shader = skPaint.getShader(); | 846 SkShader* shader = skPaint.getShader(); |
847 if (nullptr == shader) { | 847 if (nullptr == shader) { |
848 return SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skP
aint.getColor()), | 848 return SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skP
aint.getColor()), |
849 constantColor, grPaint); | 849 constantColor, grPaint); |
850 } | 850 } |
851 | 851 |
852 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); | 852 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); |
853 | 853 |
854 // Start a new block here in order to preserve our context state after calli
ng | 854 const GrFragmentProcessor* fp = shader->asFragmentProcessor(context, viewM,
NULL, |
855 // asFragmentProcessor(). Since these calls get passed back to the client, w
e don't really | 855 skPaint.getFilterQuality(), grPaint->getProcessorDataManager()); |
856 // want them messing around with the context. | 856 if (!fp) { |
857 { | 857 return false; |
858 // Allow the shader to modify paintColor and also create an effect to be
installed as | |
859 // the first color effect on the GrPaint. | |
860 GrFragmentProcessor* fp = nullptr; | |
861 if (!shader->asFragmentProcessor(context, skPaint, viewM, nullptr, &pain
tColor, | |
862 grPaint->getProcessorDataManager(), &fp
)) { | |
863 return false; | |
864 } | |
865 if (fp) { | |
866 grPaint->addColorFragmentProcessor(fp)->unref(); | |
867 constantColor = false; | |
868 } | |
869 } | 858 } |
| 859 grPaint->addColorFragmentProcessor(fp)->unref(); |
| 860 constantColor = false; |
870 | 861 |
871 // The grcolor is automatically set when calling asFragmentProcessor. | 862 // The grcolor is automatically set when calling asFragmentProcessor. |
872 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 863 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
873 return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantCol
or, grPaint); | 864 return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantCol
or, grPaint); |
874 } | 865 } |
875 | 866 |
876 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { | 867 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { |
877 #ifdef SK_DEBUG | 868 #ifdef SK_DEBUG |
878 const GrSurfaceDesc& desc = tex->desc(); | 869 const GrSurfaceDesc& desc = tex->desc(); |
879 SkASSERT(w <= desc.fWidth); | 870 SkASSERT(w <= desc.fWidth); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 SkErrorInternals::SetError( kInvalidPaint_SkError, | 920 SkErrorInternals::SetError( kInvalidPaint_SkError, |
930 "Sorry, I don't understand the filtering
" | 921 "Sorry, I don't understand the filtering
" |
931 "mode you asked for. Falling back to " | 922 "mode you asked for. Falling back to " |
932 "MIPMaps."); | 923 "MIPMaps."); |
933 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 924 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
934 break; | 925 break; |
935 | 926 |
936 } | 927 } |
937 return textureFilterMode; | 928 return textureFilterMode; |
938 } | 929 } |
OLD | NEW |