Skip to content

Commit 264816f

Browse files
authored
Move all getUniformX tests to web_ui/test. (#180910)
- Moves all the existing web tests for getUniformX to web_ui/tests. - Commits shaders to github in addition to the impellerc generated string. Had to manually translate them from the dumped SKSL string to GLSL and recompile, there may be small differences. - Updates the impellerc generated strings Does not fix the web testing build system to have this happen in a non-brittle way. That should happen at some point.
1 parent 5d566a6 commit 264816f

6 files changed

Lines changed: 526 additions & 176 deletions

File tree

engine/src/flutter/impeller/fixtures/ink_sparkle.frag

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
// Use of this source code is governed by a BSD-style license that can be
55
// found in the LICENSE file.
66

7+
// If updating this file, also update
8+
// engine/src/flutter/lib/web_ui/test/canvaskit/fragment_program_test.dart and
9+
// engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart
10+
711
precision highp float;
812

913
#include <flutter/runtime_effect.glsl>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// If updating this file, also update
6+
// engine/src/flutter/lib/web_ui/test/canvaskit/fragment_program_test.dart and
7+
// engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart
8+
9+
#include <flutter/runtime_effect.glsl>
10+
11+
uniform vec2 uSize;
12+
uniform float uFloats[10];
13+
uniform float uLoneFloat;
14+
uniform vec2 uVectors[3];
15+
uniform vec3 uLoneVector;
16+
uniform mat4 uMatrices[2];
17+
uniform mat4 uLoneMatrix;
18+
19+
out vec4 fragColor;
20+
21+
void main() {
22+
vec2 pos = FlutterFragCoord().xy;
23+
vec2 uv = pos / uSize;
24+
float barWidth = 0.100000001490116119384765625;
25+
float barIndex = floor(uv.x / barWidth);
26+
for (int i = 0; i < 10; i++) {
27+
if (i == int(barIndex)) {
28+
float barHeight = uFloats[i];
29+
if (uv.y > (1.0 - barHeight)) {
30+
fragColor =
31+
vec4(0.3300000131130218505859375, 0.0900000035762786865234375,
32+
0.0900000035762786865234375, 1.0);
33+
} else {
34+
fragColor = vec4(1.0);
35+
}
36+
}
37+
}
38+
}

engine/src/flutter/lib/ui/fixtures/shaders/general_shaders/texture.frag

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// If updating this file, also update
6+
// engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart
7+
58
#include <flutter/runtime_effect.glsl>
69

710
uniform vec2 u_size;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// If updating this file, also update
6+
// engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart
7+
8+
#include <flutter/runtime_effect.glsl>
9+
10+
uniform float uTileSize;
11+
12+
out vec4 fragColor;
13+
14+
float rand(vec2 co) {
15+
return fract(sin(dot(co, vec2(12.98980045318603515625, 78.233001708984375))) *
16+
43758.546875);
17+
}
18+
19+
vec2 fuzzGridPoint(vec2 coordinate) {
20+
return coordinate +
21+
vec2((rand(coordinate * 400.0) - 0.5) * 0.800000011920928955078125,
22+
(rand(coordinate * 400.0) - 0.5) * 0.800000011920928955078125);
23+
}
24+
25+
vec3 getColorForGridPoint(vec2 coordinate) {
26+
return vec3(rand(coordinate * 100.0), rand(coordinate * 200.0),
27+
rand(coordinate * 300.0));
28+
}
29+
30+
void main() {
31+
vec2 uv = FlutterFragCoord().xy / vec2(uTileSize);
32+
vec2 upperLeft = floor(uv);
33+
vec2 upperRight = vec2(ceil(uv.x), floor(uv.y));
34+
vec2 bottomLeft = vec2(floor(uv.x), ceil(uv.y));
35+
vec2 bottomRight = ceil(uv);
36+
vec2 closestPoint = upperLeft;
37+
float dist = distance(uv, fuzzGridPoint(upperLeft));
38+
float upperRightDistance = distance(uv, fuzzGridPoint(upperRight));
39+
if (upperRightDistance < dist) {
40+
dist = upperRightDistance;
41+
closestPoint = upperRight;
42+
}
43+
float bottomLeftDistance = distance(uv, fuzzGridPoint(bottomLeft));
44+
if (bottomLeftDistance < dist) {
45+
dist = bottomLeftDistance;
46+
closestPoint = bottomLeft;
47+
}
48+
float bottomRightDistance = distance(uv, fuzzGridPoint(bottomRight));
49+
if (bottomRightDistance < dist) {
50+
dist = bottomRightDistance;
51+
closestPoint = bottomRight;
52+
}
53+
fragColor = vec4(getColorForGridPoint(closestPoint), 1.0);
54+
}

0 commit comments

Comments
 (0)