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