2021-07-14 18:04:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/effects/SkRuntimeEffect.h"
|
2022-02-09 18:14:25 +00:00
|
|
|
#include "tools/RuntimeBlendUtils.h"
|
2021-07-14 18:04:49 +00:00
|
|
|
|
|
|
|
sk_sp<SkBlender> GetRuntimeBlendForBlendMode(SkBlendMode mode) {
|
2021-07-30 15:20:48 +00:00
|
|
|
static auto result = SkRuntimeEffect::MakeForBlender(SkString(R"(
|
|
|
|
uniform blender b;
|
|
|
|
half4 main(half4 src, half4 dst) {
|
2021-09-02 13:26:27 +00:00
|
|
|
return b.eval(src, dst);
|
2021-07-14 18:04:49 +00:00
|
|
|
}
|
2021-07-30 15:20:48 +00:00
|
|
|
)"));
|
2021-07-14 18:04:49 +00:00
|
|
|
|
2021-07-30 15:20:48 +00:00
|
|
|
SkASSERTF(result.effect, "%s", result.errorText.c_str());
|
2021-07-14 18:04:49 +00:00
|
|
|
|
2021-07-30 15:20:48 +00:00
|
|
|
SkRuntimeBlendBuilder builder(result.effect);
|
|
|
|
builder.child("b") = SkBlender::Mode(mode);
|
|
|
|
return builder.makeBlender();
|
2021-07-14 18:04:49 +00:00
|
|
|
}
|