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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 unPMColor, colorCubeSizeUni); | 270 unPMColor, colorCubeSizeUni); |
271 | 271 |
272 // Compute y coord for for texture fetches. | 272 // Compute y coord for for texture fetches. |
273 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (floor(%s.b) + %s.g) * %s);\n
", | 273 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (floor(%s.b) + %s.g) * %s);\n
", |
274 cCoords1, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi
zeUni); | 274 cCoords1, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi
zeUni); |
275 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (ceil(%s.b) + %s.g) * %s);\n"
, | 275 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (ceil(%s.b) + %s.g) * %s);\n"
, |
276 cCoords2, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi
zeUni); | 276 cCoords2, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi
zeUni); |
277 | 277 |
278 // Apply the cube. | 278 // Apply the cube. |
279 fragBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor); | 279 fragBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor); |
280 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords1); | 280 fragBuilder->appendTextureLookup(args.fTexSamplers[0], cCoords1); |
281 fragBuilder->codeAppend(".bgr, "); | 281 fragBuilder->codeAppend(".bgr, "); |
282 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords2); | 282 fragBuilder->appendTextureLookup(args.fTexSamplers[0], cCoords2); |
283 | 283 |
284 // Premultiply color by alpha. Note that the input alpha is not modified by
this shader. | 284 // Premultiply color by alpha. Note that the input alpha is not modified by
this shader. |
285 fragBuilder->codeAppendf(".bgr, fract(%s.b)) * vec3(%s), %s.a);\n", | 285 fragBuilder->codeAppendf(".bgr, fract(%s.b)) * vec3(%s), %s.a);\n", |
286 cubeIdx, nonZeroAlpha, args.fInputColor); | 286 cubeIdx, nonZeroAlpha, args.fInputColor); |
287 } | 287 } |
288 | 288 |
289 void GrColorCubeEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager&
pdman, | 289 void GrColorCubeEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager&
pdman, |
290 const GrProcessor& proc) { | 290 const GrProcessor& proc) { |
291 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); | 291 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); |
292 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); | 292 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); |
(...skipping 27 matching lines...) Expand all Loading... |
320 if (textureCube) { | 320 if (textureCube) { |
321 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); | 321 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); |
322 } else { | 322 } else { |
323 return nullptr; | 323 return nullptr; |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 return GrColorCubeEffect::Create(textureCube); | 327 return GrColorCubeEffect::Create(textureCube); |
328 } | 328 } |
329 #endif | 329 #endif |
OLD | NEW |