Commit 6c947c2a authored by Brian Osman's avatar Brian Osman Committed by Commit Bot

Update to new SkRuntimeEffect main() signature

The color filters used for exotic color space conversion in
skia_renderer are built on SkRuntimeEffect. The required signature
for main() in the SkSL has changed, this just adapts to the new
signature and semantics.

Bug: skia:10613
Change-Id: I031cbd597810ec9629b3308db4548c5842b0b5de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375932Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Cr-Commit-Position: refs/heads/master@{#801749}
parent 34c9b093
......@@ -2265,8 +2265,10 @@ sk_sp<SkColorFilter> SkiaRenderer::GetColorSpaceConversionFilter(
const char* hdr = R"(
uniform half offset;
uniform half multiplier;
in shader child;
void main(inout half4 color) {
half4 main() {
half4 color = sample(child);
// un-premultiply alpha
if (color.a > 0)
color.rgb /= color.a;
......@@ -2277,6 +2279,7 @@ void main(inout half4 color) {
const char* ftr = R"(
// premultiply alpha
color.rgb *= color.a;
return color;
}
)";
......@@ -2292,7 +2295,8 @@ void main(inout half4 color) {
input.multiplier = resource_multiplier;
sk_sp<SkData> data = SkData::MakeWithCopy(&input, sizeof(input));
return effect->makeColorFilter(std::move(data));
sk_sp<SkColorFilter> child = nullptr; // = default input color
return effect->makeColorFilter(std::move(data), &child, 1);
}
sk_sp<SkColorFilter> SkiaRenderer::GetContentColorFilter() {
......
......@@ -225,9 +225,6 @@ SK_API void SkDebugf_FileLine(const char* file,
#define SK_SUPPORT_LEGACY_AAA_CHOICE
#endif
// Staging for changes to SkRuntimeEffect main() signature
#define SK_USE_LEGACY_RUNTIME_EFFECT_SIGNATURE
// Staging for lowp::bilerp_clamp_8888, and for planned misc. others.
#define SK_DISABLE_LOWP_BILERP_CLAMP_CLAMP_STAGE
......
......@@ -519,8 +519,11 @@ TEST(SimpleColorSpace, CanParseSkShaderSource) {
for (const auto& dst : common_color_spaces) {
auto transform = ColorTransform::NewColorTransform(
src, dst, ColorTransform::Intent::INTENT_PERCEPTUAL);
std::string source = "void main(inout half4 color) {" +
transform->GetSkShaderSource() + "}";
std::string source =
"in shader child;\n"
"half4 main() {\n"
" half4 color = sample(child);\n" +
transform->GetSkShaderSource() + " return color; }";
auto result =
SkRuntimeEffect::Make(SkString(source.c_str(), source.length()));
EXPECT_NE(std::get<0>(result), nullptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment