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

Commit a0ea3b7b authored by Brian Osman's avatar Brian Osman
Browse files

In SkSL, replace 'sample' with '.eval'

SkSL syntax is evolving to better communicate how the effects integrate
with the rest of the Skia pipeline. 'sample' suggests texture sampling,
but the invocation of the shader object is really a call to a function
(the entry point of the SkShader's generated code).

Bug: skbug.com/12302
Change-Id: I64bf04846000ce204f1d175e316f3c03202b66aa
parent 69152f4c
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -39,14 +39,14 @@ BlurFilter::BlurFilter() {
        uniform float2 in_maxSizeXY;

        half4 main(float2 xy) {
            half4 c = sample(input, xy);
            c += sample(input, float2( clamp( in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
            half4 c = input.eval(xy);
            c += input.eval(float2(clamp( in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
                                   clamp( in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
            c += sample(input, float2( clamp( in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
            c += input.eval(float2(clamp( in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
                                   clamp(-in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
            c += sample(input, float2( clamp( -in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
            c += input.eval(float2(clamp(-in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
                                   clamp( in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));
            c += sample(input, float2( clamp( -in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
            c += input.eval(float2(clamp(-in_blurOffset.x + xy.x, 0, in_maxSizeXY.x),
                                   clamp(-in_blurOffset.y + xy.y, 0, in_maxSizeXY.y)));

            return half4(c.rgb * 0.2, 1.0);
@@ -65,7 +65,7 @@ BlurFilter::BlurFilter() {
        uniform float mixFactor;

        half4 main(float2 xy) {
            return half4(mix(sample(originalInput, xy), sample(blurredInput, xy), mixFactor));
            return half4(mix(originalInput.eval(xy), blurredInput.eval(xy), mixFactor));
        }
    )");

+1 −1
Original line number Diff line number Diff line
@@ -391,7 +391,7 @@ static void generateEffectiveOOTF(bool undoPremultipliedAlpha, SkString& shader)
    shader.append(R"(
        uniform shader input;
        half4 main(float2 xy) {
            float4 c = float4(sample(input, xy));
            float4 c = float4(input.eval(xy));
    )");
    if (undoPremultipliedAlpha) {
        shader.append(R"(
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ static const SkString stretchShader = SkString(R"(
        );
        coord.x = (outU - uScrollX) * viewportWidth;
        coord.y = (outV - uScrollY) * viewportHeight;
        return sample(uContentTexture, coord);
        return uContentTexture.eval(coord);
    })");

const float INTERPOLATION_STRENGTH_VALUE = 0.7f;