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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1027 |
1028 // If there is no mask filter than it is OK to handle the src rect -> dst re
ct scaling using | 1028 // If there is no mask filter than it is OK to handle the src rect -> dst re
ct scaling using |
1029 // the view matrix rather than a local matrix. | 1029 // the view matrix rather than a local matrix. |
1030 SkMatrix m; | 1030 SkMatrix m; |
1031 m.setScale(dstSize.fWidth / srcRect.width(), | 1031 m.setScale(dstSize.fWidth / srcRect.width(), |
1032 dstSize.fHeight / srcRect.height()); | 1032 dstSize.fHeight / srcRect.height()); |
1033 SkMatrix viewM = *draw.fMatrix; | 1033 SkMatrix viewM = *draw.fMatrix; |
1034 viewM.preConcat(m); | 1034 viewM.preConcat(m); |
1035 | 1035 |
1036 GrTextureParams params; | 1036 GrTextureParams params; |
1037 SkFilterQuality paintFilterQuality = paint.getFilterQuality(); | 1037 bool doBicubic; |
1038 GrTextureParams::FilterMode textureFilterMode; | 1038 GrTextureParams::FilterMode textureFilterMode = |
1039 | 1039 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, SkM
atrix::I(), |
1040 bool doBicubic = false; | 1040 &doBicubic); |
1041 | |
1042 switch(paintFilterQuality) { | |
1043 case kNone_SkFilterQuality: | |
1044 textureFilterMode = GrTextureParams::kNone_FilterMode; | |
1045 break; | |
1046 case kLow_SkFilterQuality: | |
1047 textureFilterMode = GrTextureParams::kBilerp_FilterMode; | |
1048 break; | |
1049 case kMedium_SkFilterQuality: | |
1050 if (viewM.getMinScale() < SK_Scalar1) { | |
1051 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | |
1052 } else { | |
1053 // Don't trigger MIP level generation unnecessarily. | |
1054 textureFilterMode = GrTextureParams::kBilerp_FilterMode; | |
1055 } | |
1056 break; | |
1057 case kHigh_SkFilterQuality: | |
1058 // Minification can look bad with the bicubic effect. | |
1059 doBicubic = | |
1060 GrBicubicEffect::ShouldUseBicubic(viewM, &textureFilterMode); | |
1061 break; | |
1062 default: | |
1063 SkErrorInternals::SetError( kInvalidPaint_SkError, | |
1064 "Sorry, I don't understand the filtering
" | |
1065 "mode you asked for. Falling back to " | |
1066 "MIPMaps."); | |
1067 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | |
1068 break; | |
1069 } | |
1070 | 1041 |
1071 int tileFilterPad; | 1042 int tileFilterPad; |
1072 if (doBicubic) { | 1043 if (doBicubic) { |
1073 tileFilterPad = GrBicubicEffect::kFilterTexelPad; | 1044 tileFilterPad = GrBicubicEffect::kFilterTexelPad; |
1074 } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) { | 1045 } else if (GrTextureParams::kNone_FilterMode == textureFilterMode) { |
1075 tileFilterPad = 0; | 1046 tileFilterPad = 0; |
1076 } else { | 1047 } else { |
1077 tileFilterPad = 1; | 1048 tileFilterPad = 1; |
1078 } | 1049 } |
1079 params.setFilterMode(textureFilterMode); | 1050 params.setFilterMode(textureFilterMode); |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 #endif | 1837 #endif |
1867 } | 1838 } |
1868 | 1839 |
1869 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1840 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1870 // We always return a transient cache, so it is freed after each | 1841 // We always return a transient cache, so it is freed after each |
1871 // filter traversal. | 1842 // filter traversal. |
1872 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1843 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1873 } | 1844 } |
1874 | 1845 |
1875 #endif | 1846 #endif |
OLD | NEW |