| 1 |
/* |
| 2 |
* Copyright 2021 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
#include "tools/RuntimeBlendUtils.h" |
| 8 |
|
| 9 |
#include "include/core/SkBlendMode.h" |
| 10 |
#include "include/core/SkRefCnt.h" |
| 11 |
#include "include/effects/SkRuntimeEffect.h" |
| 12 |
|
| 13 |
sk_sp<SkBlender> GetRuntimeBlendForBlendMode(SkBlendMode mode) { |
| 14 |
static auto result = SkRuntimeEffect::MakeForBlender(SkString( |
| 15 |
"uniform blender b;" |
| 16 |
"half4 main(half4 src, half4 dst) {" |
| 17 |
"return b.eval(src, dst);" |
| 18 |
"}" |
| 19 |
)); |
| 20 |
|
| 21 |
SkASSERTF(result.effect, "%s", result.errorText.c_str()); |
| 22 |
|
| 23 |
SkRuntimeBlendBuilder builder(result.effect); |
| 24 |
builder.child("b") = SkBlender::Mode(mode); |
| 25 |
return builder.makeBlender(); |
| 26 |
} |