| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
| 10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 // warp the fragment position to the appropriate part of the 9patch blur tex
ture | 1033 // warp the fragment position to the appropriate part of the 9patch blur tex
ture |
| 1034 | 1034 |
| 1035 builder->fsCodeAppendf("\t\tvec2 rectCenter = (%s.xy + %s.zw)/2.0;\n", rectN
ame, rectName); | 1035 builder->fsCodeAppendf("\t\tvec2 rectCenter = (%s.xy + %s.zw)/2.0;\n", rectN
ame, rectName); |
| 1036 builder->fsCodeAppendf("\t\tvec2 translatedFragPos = %s.xy - %s.xy;\n", frag
mentPos, rectName); | 1036 builder->fsCodeAppendf("\t\tvec2 translatedFragPos = %s.xy - %s.xy;\n", frag
mentPos, rectName); |
| 1037 builder->fsCodeAppendf("\t\tfloat threshold = %s + 2.0*%s;\n", cornerRadiusN
ame, blurRadiusName ); | 1037 builder->fsCodeAppendf("\t\tfloat threshold = %s + 2.0*%s;\n", cornerRadiusN
ame, blurRadiusName ); |
| 1038 builder->fsCodeAppendf("\t\tvec2 middle = %s.zw - %s.xy - 2.0*threshold;\n",
rectName, rectName ); | 1038 builder->fsCodeAppendf("\t\tvec2 middle = %s.zw - %s.xy - 2.0*threshold;\n",
rectName, rectName ); |
| 1039 | 1039 |
| 1040 builder->fsCodeAppendf("\t\tif (translatedFragPos.x >= threshold && translat
edFragPos.x < (middle.x+threshold)) {\n" ); | 1040 builder->fsCodeAppendf("\t\tif (translatedFragPos.x >= threshold && translat
edFragPos.x < (middle.x+threshold)) {\n" ); |
| 1041 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.x = threshold;\n"); | 1041 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.x = threshold;\n"); |
| 1042 builder->fsCodeAppendf("\t\t} else if (translatedFragPos.x >= (middle.x + th
reshold)) {\n"); | 1042 builder->fsCodeAppendf("\t\t} else if (translatedFragPos.x >= (middle.x + th
reshold)) {\n"); |
| 1043 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.x -= middle.x;\n"); | 1043 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.x -= middle.x - 1.0;\n"); |
| 1044 builder->fsCodeAppendf("\t\t}\n"); | 1044 builder->fsCodeAppendf("\t\t}\n"); |
| 1045 | 1045 |
| 1046 builder->fsCodeAppendf("\t\tif (translatedFragPos.y > threshold && translate
dFragPos.y < (middle.y+threshold)) {\n" ); | 1046 builder->fsCodeAppendf("\t\tif (translatedFragPos.y > threshold && translate
dFragPos.y < (middle.y+threshold)) {\n" ); |
| 1047 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.y = threshold;\n"); | 1047 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.y = threshold;\n"); |
| 1048 builder->fsCodeAppendf("\t\t} else if (translatedFragPos.y >= (middle.y + th
reshold)) {\n"); | 1048 builder->fsCodeAppendf("\t\t} else if (translatedFragPos.y >= (middle.y + th
reshold)) {\n"); |
| 1049 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.y -= middle.y;\n"); | 1049 builder->fsCodeAppendf("\t\t\ttranslatedFragPos.y -= middle.y - 1.0;\n"); |
| 1050 builder->fsCodeAppendf("\t\t}\n"); | 1050 builder->fsCodeAppendf("\t\t}\n"); |
| 1051 | 1051 |
| 1052 builder->fsCodeAppendf("\t\tvec2 proxyDims = vec2(2.0*threshold+1.0);\n"); | 1052 builder->fsCodeAppendf("\t\tvec2 proxyDims = vec2(2.0*threshold+1.0);\n"); |
| 1053 builder->fsCodeAppendf("\t\tvec2 texCoord = translatedFragPos / proxyDims;\n
"); | 1053 builder->fsCodeAppendf("\t\tvec2 texCoord = translatedFragPos / proxyDims;\n
"); |
| 1054 | 1054 |
| 1055 builder->fsCodeAppendf("\t%s = ", outputColor); | 1055 builder->fsCodeAppendf("\t%s = ", outputColor); |
| 1056 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "texCoord
"); | 1056 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "texCoord
"); |
| 1057 builder->fsCodeAppend(";\n"); | 1057 builder->fsCodeAppend(";\n"); |
| 1058 } | 1058 } |
| 1059 | 1059 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 } else { | 1225 } else { |
| 1226 str->append("None"); | 1226 str->append("None"); |
| 1227 } | 1227 } |
| 1228 str->append("))"); | 1228 str->append("))"); |
| 1229 } | 1229 } |
| 1230 #endif | 1230 #endif |
| 1231 | 1231 |
| 1232 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1232 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1233 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1233 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1234 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1234 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |