Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c784d9ac authored by John Reck's avatar John Reck
Browse files

Fix RuntimeShader example bug

Also make the error message explicit

Test: ColorFiltersMutateActivity doesn't crash on launch

Change-Id: I8fb5b9204badd141cd51f6149cdab0233f8264e3
parent 570fc4b2
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -228,9 +228,12 @@ static jlong RuntimeShader_create(JNIEnv* env, jobject, jlong shaderFactory, jlo

static jlong RuntimeShader_createShaderFactory(JNIEnv* env, jobject, jstring sksl) {
    ScopedUtfChars strSksl(env, sksl);
    sk_sp<SkRuntimeEffect> effect = std::get<0>(SkRuntimeEffect::Make(SkString(strSksl.c_str())));
    ThrowIAE_IfNull(env, effect);

    auto result = SkRuntimeEffect::Make(SkString(strSksl.c_str()));
    sk_sp<SkRuntimeEffect> effect = std::get<0>(result);
    if (!effect) {
        const auto& err = std::get<1>(result);
        doThrowIAE(env, err.c_str());
    }
    return reinterpret_cast<jlong>(effect.release());
}

+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class ColorFiltersMutateActivity extends Activity {

        static final String sSkSL =
                "uniform float param1;\n"
                + "void main(float x, float y, inout half4 color) {\n"
                + "void main(float2 xy, inout half4 color) {\n"
                + "color = half4(color.r, half(param1), color.b, 1.0);\n"
                + "}\n";