OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkArithmeticMode.h" | 8 #include "SkArithmeticMode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 dstColor = builder->dstColor(); | 359 dstColor = builder->dstColor(); |
360 } | 360 } |
361 | 361 |
362 SkASSERT(NULL != dstColor); | 362 SkASSERT(NULL != dstColor); |
363 fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 363 fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
364 kVec4f_GrSLType, "k"); | 364 kVec4f_GrSLType, "k"); |
365 const char* kUni = builder->getUniformCStr(fKUni); | 365 const char* kUni = builder->getUniformCStr(fKUni); |
366 | 366 |
367 // We don't try to optimize for this case at all | 367 // We don't try to optimize for this case at all |
368 if (NULL == inputColor) { | 368 if (NULL == inputColor) { |
369 builder->fsCodeAppendf("\t\tconst vec4 src = %s;\n", GrGLSLOnesVecf(4)); | 369 builder->fsCodeAppendf("\t\tconst vec4 src = vec4(1);\n"); |
370 } else { | 370 } else { |
371 builder->fsCodeAppendf("\t\tvec4 src = %s;\n", inputColor); | 371 builder->fsCodeAppendf("\t\tvec4 src = %s;\n", inputColor); |
372 if (gUseUnpremul) { | 372 if (gUseUnpremul) { |
373 builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1.
0);\n"); | 373 builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1.
0);\n"); |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 builder->fsCodeAppendf("\t\tvec4 dst = %s;\n", dstColor); | 377 builder->fsCodeAppendf("\t\tvec4 dst = %s;\n", dstColor); |
378 if (gUseUnpremul) { | 378 if (gUseUnpremul) { |
379 builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\
n"); | 379 builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\
n"); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 background); | 421 background); |
422 } | 422 } |
423 return true; | 423 return true; |
424 } | 424 } |
425 | 425 |
426 #endif | 426 #endif |
427 | 427 |
428 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 428 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
429 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 429 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
430 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 430 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |