blob: 758ec3e1d9d75d520d61a46e68e959831e224334 [file]
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tools/RuntimeBlendUtils.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkRefCnt.h"
#include "include/effects/SkRuntimeEffect.h"
sk_sp<SkBlender> GetRuntimeBlendForBlendMode(SkBlendMode mode) {
static auto result = SkRuntimeEffect::MakeForBlender(SkString(
"uniform blender b;"
"half4 main(half4 src, half4 dst) {"
"return b.eval(src, dst);"
"}"
));
SkASSERTF(result.effect, "%s", result.errorText.c_str());
SkRuntimeBlendBuilder builder(result.effect);
builder.child("b") = SkBlender::Mode(mode);
return builder.makeBlender();
}