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: Ib6b895208ae70368901965b7ca13434c51a7455f
diff --git a/graphics/java/android/graphics/drawable/RippleShader.java b/graphics/java/android/graphics/drawable/RippleShader.java
index 57b3223..272b840 100644
--- a/graphics/java/android/graphics/drawable/RippleShader.java
+++ b/graphics/java/android/graphics/drawable/RippleShader.java
@@ -119,7 +119,7 @@
+ " vec4 waveColor = vec4(in_color.rgb * waveAlpha, waveAlpha);\n"
+ " vec4 sparkleColor = vec4(in_sparkleColor.rgb * in_sparkleColor.a, "
+ "in_sparkleColor.a);\n"
- + " float mask = in_hasMask == 1. ? sample(in_shader, p).a > 0. ? 1. : 0. : 1.;\n"
+ + " float mask = in_hasMask == 1. ? in_shader.eval(p).a > 0. ? 1. : 0. : 1.;\n"
+ " return mix(waveColor, sparkleColor, sparkleAlpha) * mask;\n"
+ "}";
private static final String SHADER = SHADER_UNIFORMS + SHADER_LIB + SHADER_MAIN;
diff --git a/libs/hwui/effects/StretchEffect.cpp b/libs/hwui/effects/StretchEffect.cpp
index 17cd3ce..8cb4515 100644
--- a/libs/hwui/effects/StretchEffect.cpp
+++ b/libs/hwui/effects/StretchEffect.cpp
@@ -181,7 +181,7 @@
);
coord.x = outU;
coord.y = outV;
- return sample(uContentTexture, coord);
+ return uContentTexture.eval(coord);
})");
static const float ZERO = 0.f;
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
index c06f8fd..46d3a3d 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
@@ -63,7 +63,7 @@
"uniform shader bitmapShader;\n"
+ "uniform float param1;\n"
+ "half4 main(float2 xy) {\n"
- + " return half4(sample(bitmapShader, xy).rgb, param1);\n"
+ + " return half4(bitmapShader.eval(xy).rgb, param1);\n"
+ "}\n";
BitmapsView(Context c) {
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
index d925541..83e2de9 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
@@ -91,7 +91,7 @@
+ " d = rand(float2(x, y)) > density ? d : d * .2;\n"
+ " d = d * rand(float2(fraction, x * y));\n"
+ " float alpha = 1. - pow(fraction, 3.);\n"
- + " return float4(sample(in_paintColor, p).rgb, d * alpha);\n"
+ + " return float4(in_paintColor.eval(p).rgb, d * alpha);\n"
+ "}";
RippleView(Context c) {
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
index 3307c36..fcdee63 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
@@ -532,6 +532,6 @@
+ " uv.y = outV;\n"
+ " coord.x = uv.x * viewportWidth;\n"
+ " coord.y = uv.y * viewportHeight;\n"
- + " return sample(uContentTexture, coord);\n"
+ + " return uContentTexture.eval(coord);\n"
+ "}";
}