| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkColorCubeFilter.h" | 8 #include "SkColorCubeFilter.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 const char* nonZeroAlpha = "nonZeroAlpha"; | 289 const char* nonZeroAlpha = "nonZeroAlpha"; |
| 290 const char* unPMColor = "unPMColor"; | 290 const char* unPMColor = "unPMColor"; |
| 291 const char* cubeIdx = "cubeIdx"; | 291 const char* cubeIdx = "cubeIdx"; |
| 292 const char* cCoords1 = "cCoords1"; | 292 const char* cCoords1 = "cCoords1"; |
| 293 const char* cCoords2 = "cCoords2"; | 293 const char* cCoords2 = "cCoords2"; |
| 294 | 294 |
| 295 // Note: if implemented using texture3D in OpenGL ES older than OpenGL ES 3.
0, | 295 // Note: if implemented using texture3D in OpenGL ES older than OpenGL ES 3.
0, |
| 296 // the shader might need "#extension GL_OES_texture_3D : enable". | 296 // the shader might need "#extension GL_OES_texture_3D : enable". |
| 297 | 297 |
| 298 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 298 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 299 | 299 |
| 300 // Unpremultiply color | 300 // Unpremultiply color |
| 301 fsBuilder->codeAppendf("\tfloat %s = max(%s.a, 0.00001);\n", nonZeroAlpha, i
nputColor); | 301 fsBuilder->codeAppendf("\tfloat %s = max(%s.a, 0.00001);\n", nonZeroAlpha, i
nputColor); |
| 302 fsBuilder->codeAppendf("\tvec4 %s = vec4(%s.rgb / %s, %s);\n", | 302 fsBuilder->codeAppendf("\tvec4 %s = vec4(%s.rgb / %s, %s);\n", |
| 303 unPMColor, inputColor, nonZeroAlpha, nonZeroAlpha); | 303 unPMColor, inputColor, nonZeroAlpha, nonZeroAlpha); |
| 304 | 304 |
| 305 // Fit input color into the cube. | 305 // Fit input color into the cube. |
| 306 fsBuilder->codeAppendf( | 306 fsBuilder->codeAppendf( |
| 307 "vec3 %s = vec3(%s.rg * vec2((%s - 1.0) * %s) + vec2(0.5 * %s), %s.b * (
%s - 1.0));\n", | 307 "vec3 %s = vec3(%s.rg * vec2((%s - 1.0) * %s) + vec2(0.5 * %s), %s.b * (
%s - 1.0));\n", |
| 308 cubeIdx, unPMColor, colorCubeSizeUni, colorCubeInvSizeUni, colorCubeInvS
izeUni, | 308 cubeIdx, unPMColor, colorCubeSizeUni, colorCubeInvSizeUni, colorCubeInvS
izeUni, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 GrFragmentProcessor* frag = textureCube ? GrColorCubeEffect::Create(textureC
ube) : NULL; | 362 GrFragmentProcessor* frag = textureCube ? GrColorCubeEffect::Create(textureC
ube) : NULL; |
| 363 if (frag) { | 363 if (frag) { |
| 364 if (array) { | 364 if (array) { |
| 365 *array->append() = frag; | 365 *array->append() = frag; |
| 366 } | 366 } |
| 367 return true; | 367 return true; |
| 368 } | 368 } |
| 369 return false; | 369 return false; |
| 370 } | 370 } |
| 371 #endif | 371 #endif |
| OLD | NEW |