mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
Auto merge of #13927 - glennw:update-wr-texture-layers, r=emilio
Update WR - texture layers, image mask, profiler, optimizations. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13927) <!-- Reviewable:end -->
This commit is contained in:
commit
2b236c20cd
19 changed files with 182 additions and 58 deletions
|
@ -160,6 +160,7 @@ impl ToClipRegion for ClippingRegion {
|
|||
complex_clipping_region.radii.to_border_radius(),
|
||||
)
|
||||
}).collect(),
|
||||
None,
|
||||
&mut frame_builder.auxiliary_lists_builder)
|
||||
}
|
||||
}
|
||||
|
|
4
components/servo/Cargo.lock
generated
4
components/servo/Cargo.lock
generated
|
@ -2661,7 +2661,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/servo/webrender#860da4ff8b7dcb079ae85d4369d2412300e61599"
|
||||
source = "git+https://github.com/servo/webrender#4440d1daa3d6e9630d4b164f7bae644b9dc4cb8a"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2686,7 +2686,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/servo/webrender#860da4ff8b7dcb079ae85d4369d2412300e61599"
|
||||
source = "git+https://github.com/servo/webrender#4440d1daa3d6e9630d4b164f7bae644b9dc4cb8a"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
4
ports/cef/Cargo.lock
generated
4
ports/cef/Cargo.lock
generated
|
@ -2519,7 +2519,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/servo/webrender#860da4ff8b7dcb079ae85d4369d2412300e61599"
|
||||
source = "git+https://github.com/servo/webrender#4440d1daa3d6e9630d4b164f7bae644b9dc4cb8a"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2544,7 +2544,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/servo/webrender#860da4ff8b7dcb079ae85d4369d2412300e61599"
|
||||
source = "git+https://github.com/servo/webrender#4440d1daa3d6e9630d4b164f7bae644b9dc4cb8a"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -5,14 +5,19 @@
|
|||
|
||||
flat varying vec4 vClipRect;
|
||||
flat varying vec4 vClipRadius;
|
||||
flat varying vec4 vClipMaskUvRect;
|
||||
flat varying vec4 vClipMaskLocalRect;
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
void write_clip(Clip clip) {
|
||||
void write_clip(ClipInfo clip) {
|
||||
vClipRect = vec4(clip.rect.rect.xy, clip.rect.rect.xy + clip.rect.rect.zw);
|
||||
vClipRadius = vec4(clip.top_left.outer_inner_radius.x,
|
||||
clip.top_right.outer_inner_radius.x,
|
||||
clip.bottom_right.outer_inner_radius.x,
|
||||
clip.bottom_left.outer_inner_radius.x);
|
||||
//TODO: interpolate the final mask UV
|
||||
vClipMaskUvRect = clip.mask_info.uv_rect;
|
||||
vClipMaskLocalRect = clip.mask_info.local_rect; //TODO: transform
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -29,23 +34,31 @@ float do_clip(vec2 pos) {
|
|||
float d_bl = distance(pos, ref_bl);
|
||||
|
||||
float pixels_per_fragment = length(fwidth(pos.xy));
|
||||
// TODO: compute the `nudge` separately for X and Y
|
||||
float nudge = 0.5 * pixels_per_fragment;
|
||||
|
||||
bool out0 = pos.x < ref_tl.x && pos.y < ref_tl.y && d_tl > vClipRadius.x - nudge;
|
||||
bool out1 = pos.x > ref_tr.x && pos.y < ref_tr.y && d_tr > vClipRadius.y - nudge;
|
||||
bool out2 = pos.x > ref_br.x && pos.y > ref_br.y && d_br > vClipRadius.z - nudge;
|
||||
bool out3 = pos.x < ref_bl.x && pos.y > ref_bl.y && d_bl > vClipRadius.w - nudge;
|
||||
|
||||
vec4 distances = vec4(d_tl, d_tr, d_br, d_bl) - vClipRadius + nudge;
|
||||
float distance_from_border = dot(vec4(out0, out1, out2, out3), distances);
|
||||
|
||||
bvec4 is_out = bvec4(pos.x < ref_tl.x && pos.y < ref_tl.y,
|
||||
pos.x > ref_tr.x && pos.y < ref_tr.y,
|
||||
pos.x > ref_br.x && pos.y > ref_br.y,
|
||||
pos.x < ref_bl.x && pos.y > ref_bl.y);
|
||||
|
||||
float distance_from_border = dot(vec4(is_out),
|
||||
max(vec4(0.0, 0.0, 0.0, 0.0), distances));
|
||||
|
||||
// Move the distance back into pixels.
|
||||
distance_from_border /= pixels_per_fragment;
|
||||
|
||||
// Apply a more gradual fade out to transparent.
|
||||
//distance_from_border -= 0.5;
|
||||
|
||||
return 1.0 - smoothstep(0.0, 1.0, distance_from_border);
|
||||
float border_alpha = 1.0 - smoothstep(0.0, 1.0, distance_from_border);
|
||||
|
||||
bool repeat_mask = false; //TODO
|
||||
vec2 vMaskUv = (pos - vClipMaskLocalRect.xy) / vClipMaskLocalRect.zw;
|
||||
vec2 clamped_mask_uv = repeat_mask ? fract(vMaskUv) :
|
||||
clamp(vMaskUv, vec2(0.0, 0.0), vec2(1.0, 1.0));
|
||||
vec2 source_uv = clamped_mask_uv * vClipMaskUvRect.zw + vClipMaskUvRect.xy;
|
||||
float mask_alpha = texture(sMask, source_uv).r; //careful: texture has type A8
|
||||
|
||||
return border_alpha * mask_alpha;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#define MAX_STOPS_PER_ANGLE_GRADIENT 8
|
||||
|
||||
uniform sampler2DArray sCache;
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
|
||||
#define VECS_PER_LAYER 13
|
||||
|
@ -121,7 +123,7 @@ Layer fetch_layer(int index) {
|
|||
|
||||
struct Tile {
|
||||
vec4 screen_origin_task_origin;
|
||||
vec4 size;
|
||||
vec4 size_target_index;
|
||||
};
|
||||
|
||||
Tile fetch_tile(int index) {
|
||||
|
@ -130,7 +132,7 @@ Tile fetch_tile(int index) {
|
|||
ivec2 uv = get_fetch_uv(index, VECS_PER_TILE);
|
||||
|
||||
tile.screen_origin_task_origin = texelFetchOffset(sRenderTasks, uv, 0, ivec2(0, 0));
|
||||
tile.size = texelFetchOffset(sRenderTasks, uv, 0, ivec2(1, 0));
|
||||
tile.size_target_index = texelFetchOffset(sRenderTasks, uv, 0, ivec2(1, 0));
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
@ -257,7 +259,6 @@ PrimitiveInstance fetch_instance(int index) {
|
|||
|
||||
return pi;
|
||||
}
|
||||
|
||||
struct Primitive {
|
||||
Layer layer;
|
||||
Tile tile;
|
||||
|
@ -298,11 +299,28 @@ ClipRect fetch_clip_rect(int index) {
|
|||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
rect.rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
rect.dummy = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
//rect.dummy = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
rect.dummy = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct ImageMaskInfo {
|
||||
vec4 uv_rect;
|
||||
vec4 local_rect;
|
||||
};
|
||||
|
||||
ImageMaskInfo fetch_mask_info(int index) {
|
||||
ImageMaskInfo info;
|
||||
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
info.uv_rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
info.local_rect = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
struct ClipCorner {
|
||||
vec4 rect;
|
||||
vec4 outer_inner_radius;
|
||||
|
@ -319,22 +337,24 @@ ClipCorner fetch_clip_corner(int index) {
|
|||
return corner;
|
||||
}
|
||||
|
||||
struct Clip {
|
||||
struct ClipInfo {
|
||||
ClipRect rect;
|
||||
ClipCorner top_left;
|
||||
ClipCorner top_right;
|
||||
ClipCorner bottom_left;
|
||||
ClipCorner bottom_right;
|
||||
ImageMaskInfo mask_info;
|
||||
};
|
||||
|
||||
Clip fetch_clip(int index) {
|
||||
Clip clip;
|
||||
ClipInfo fetch_clip(int index) {
|
||||
ClipInfo clip;
|
||||
|
||||
clip.rect = fetch_clip_rect(index + 0);
|
||||
clip.top_left = fetch_clip_corner(index + 1);
|
||||
clip.top_right = fetch_clip_corner(index + 2);
|
||||
clip.bottom_left = fetch_clip_corner(index + 3);
|
||||
clip.bottom_right = fetch_clip_corner(index + 4);
|
||||
clip.mask_info = fetch_mask_info(index+5);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
@ -407,7 +427,7 @@ VertexInfo write_vertex(vec4 instance_rect,
|
|||
|
||||
vec2 clamped_pos = clamp(device_pos,
|
||||
vec2(tile.screen_origin_task_origin.xy),
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size.xy));
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size_target_index.xy));
|
||||
|
||||
vec4 local_clamped_pos = layer.inv_transform * vec4(clamped_pos / uDevicePixelRatio, world_pos.z, 1);
|
||||
local_clamped_pos.xyz /= local_clamped_pos.w;
|
||||
|
@ -461,11 +481,11 @@ TransformVertexInfo write_transform_vertex(vec4 instance_rect,
|
|||
|
||||
vec2 min_pos_clamped = clamp(min_pos * uDevicePixelRatio,
|
||||
vec2(tile.screen_origin_task_origin.xy),
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size.xy));
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size_target_index.xy));
|
||||
|
||||
vec2 max_pos_clamped = clamp(max_pos * uDevicePixelRatio,
|
||||
vec2(tile.screen_origin_task_origin.xy),
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size.xy));
|
||||
vec2(tile.screen_origin_task_origin.xy + tile.size_target_index.xy));
|
||||
|
||||
vec2 clamped_pos = mix(min_pos_clamped,
|
||||
max_pos_clamped,
|
||||
|
@ -578,7 +598,7 @@ Composite fetch_composite(int index) {
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
float squared_distance_from_rect(vec2 p, vec2 origin, vec2 size) {
|
||||
float distance_from_rect(vec2 p, vec2 origin, vec2 size) {
|
||||
vec2 clamped = clamp(p, origin, origin + size);
|
||||
return distance(clamped, p);
|
||||
}
|
||||
|
@ -587,10 +607,10 @@ vec2 init_transform_fs(vec3 local_pos, vec4 local_rect, out float fragment_alpha
|
|||
fragment_alpha = 1.0;
|
||||
vec2 pos = local_pos.xy / local_pos.z;
|
||||
|
||||
float squared_distance = squared_distance_from_rect(pos, local_rect.xy, local_rect.zw);
|
||||
if (squared_distance != 0.0) {
|
||||
float border_distance = distance_from_rect(pos, local_rect.xy, local_rect.zw);
|
||||
if (border_distance != 0.0) {
|
||||
float delta = length(fwidth(local_pos.xy));
|
||||
fragment_alpha = smoothstep(1.0, 0.0, squared_distance / delta * 2.0);
|
||||
fragment_alpha = 1.0 - smoothstep(0.0, 1.0, border_distance / delta * 2.0);
|
||||
}
|
||||
|
||||
return pos;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
uniform sampler2D sCache;
|
||||
|
||||
vec3 rgbToHsv(vec3 c) {
|
||||
float value = max(max(c.r, c.g), c.b);
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
varying vec2 vUv;
|
||||
varying vec3 vUv;
|
||||
flat varying float vAmount;
|
||||
flat varying int vOp;
|
||||
|
|
|
@ -13,12 +13,13 @@ void main(void) {
|
|||
src.screen_origin_task_origin.xy;
|
||||
|
||||
vec2 local_pos = mix(dest_origin,
|
||||
dest_origin + src.size.xy,
|
||||
dest_origin + src.size_target_index.xy,
|
||||
aPosition.xy);
|
||||
|
||||
vec2 st0 = vec2(src.screen_origin_task_origin.zw) / 2048.0;
|
||||
vec2 st1 = vec2(src.screen_origin_task_origin.zw + src.size.xy) / 2048.0;
|
||||
vUv = mix(st0, st1, aPosition.xy);
|
||||
vec2 texture_size = vec2(textureSize(sCache, 0));
|
||||
vec2 st0 = src.screen_origin_task_origin.zw / texture_size;
|
||||
vec2 st1 = (src.screen_origin_task_origin.zw + src.size_target_index.xy) / texture_size;
|
||||
vUv = vec3(mix(st0, st1, aPosition.xy), src.size_target_index.z);
|
||||
|
||||
vOp = blend.src_id_target_id_op_amount.z;
|
||||
vAmount = blend.src_id_target_id_op_amount.w / 65535.0;
|
||||
|
|
|
@ -41,7 +41,7 @@ float alpha_for_solid_border(float distance_from_ref,
|
|||
// Apply a more gradual fade out to transparent.
|
||||
// distance_from_border -= 0.5;
|
||||
|
||||
return smoothstep(1.0, 0.0, distance_from_border);
|
||||
return 1.0 - smoothstep(0.0, 1.0, distance_from_border);
|
||||
}
|
||||
|
||||
float alpha_for_solid_border_corner(vec2 local_pos,
|
||||
|
@ -97,7 +97,7 @@ vec4 draw_dotted_edge(vec2 local_pos, vec4 piece_rect, float pixels_per_fragment
|
|||
// Move the distance back into pixels.
|
||||
distance_from_circle_edge /= pixels_per_fragment;
|
||||
|
||||
float alpha = smoothstep(1.0, 0.0, min(1.0, max(0.0, distance_from_circle_edge)));
|
||||
float alpha = 1.0 - smoothstep(0.0, 1.0, min(1.0, max(0.0, distance_from_circle_edge)));
|
||||
return vHorizontalColor * vec4(1.0, 1.0, 1.0, alpha);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
uniform sampler2D sCache;
|
||||
|
||||
float gauss(float x, float sigma) {
|
||||
if (sigma == 0.0)
|
||||
return 1.0;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
varying vec2 vUv0;
|
||||
varying vec2 vUv1;
|
||||
varying vec3 vUv0;
|
||||
varying vec3 vUv1;
|
||||
flat varying vec4 vUv1Rect;
|
||||
flat varying int vOp;
|
||||
|
|
|
@ -10,20 +10,21 @@ void main(void) {
|
|||
Tile dest = fetch_tile(composite.src0_src1_target_id_op.z);
|
||||
|
||||
vec2 local_pos = mix(dest.screen_origin_task_origin.zw,
|
||||
dest.screen_origin_task_origin.zw + dest.size.xy,
|
||||
dest.screen_origin_task_origin.zw + dest.size_target_index.xy,
|
||||
aPosition.xy);
|
||||
|
||||
vec2 st0 = vec2(src0.screen_origin_task_origin.zw) / 2048.0;
|
||||
vec2 st1 = vec2(src0.screen_origin_task_origin.zw + src0.size.xy) / 2048.0;
|
||||
vUv0 = mix(st0, st1, aPosition.xy);
|
||||
vec2 texture_size = vec2(textureSize(sCache, 0));
|
||||
vec2 st0 = src0.screen_origin_task_origin.zw / texture_size;
|
||||
vec2 st1 = (src0.screen_origin_task_origin.zw + src0.size_target_index.xy) / texture_size;
|
||||
vUv0 = vec3(mix(st0, st1, aPosition.xy), src0.size_target_index.z);
|
||||
|
||||
st0 = vec2(src1.screen_origin_task_origin.zw) / 2048.0;
|
||||
st1 = vec2(src1.screen_origin_task_origin.zw + src1.size.xy) / 2048.0;
|
||||
st0 = vec2(src1.screen_origin_task_origin.zw) / texture_size;
|
||||
st1 = vec2(src1.screen_origin_task_origin.zw + src1.size_target_index.xy) / texture_size;
|
||||
vec2 local_virtual_pos = mix(dest.screen_origin_task_origin.xy,
|
||||
dest.screen_origin_task_origin.xy + dest.size.xy,
|
||||
dest.screen_origin_task_origin.xy + dest.size_target_index.xy,
|
||||
aPosition.xy);
|
||||
vec2 f = (local_virtual_pos - src1.screen_origin_task_origin.xy) / src1.size.xy;
|
||||
vUv1 = mix(st0, st1, f);
|
||||
vec2 f = (local_virtual_pos - src1.screen_origin_task_origin.xy) / src1.size_target_index.xy;
|
||||
vUv1 = vec3(mix(st0, st1, f), src1.size_target_index.z);
|
||||
vUv1Rect = vec4(st0, st1);
|
||||
|
||||
vOp = composite.src0_src1_target_id_op.w;
|
||||
|
|
15
resources/shaders/ps_gradient.fs.glsl
Normal file
15
resources/shaders/ps_gradient.fs.glsl
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
void main(void) {
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
float alpha = 0.0;
|
||||
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
|
||||
#else
|
||||
float alpha = 1.0;
|
||||
vec2 local_pos = vPos;
|
||||
#endif
|
||||
|
||||
oFragColor = vColor * vec4(1, 1, 1, alpha);
|
||||
}
|
12
resources/shaders/ps_gradient.glsl
Normal file
12
resources/shaders/ps_gradient.glsl
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
varying vec4 vColor;
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
varying vec3 vLocalPos;
|
||||
flat varying vec4 vLocalRect;
|
||||
#else
|
||||
varying vec2 vPos;
|
||||
#endif
|
69
resources/shaders/ps_gradient.vs.glsl
Normal file
69
resources/shaders/ps_gradient.vs.glsl
Normal file
|
@ -0,0 +1,69 @@
|
|||
#line 1
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
void main(void) {
|
||||
Primitive prim = load_primitive(gl_InstanceID);
|
||||
Gradient gradient = fetch_gradient(prim.prim_index);
|
||||
|
||||
int stop_index = prim.user_data.x + prim.user_data.y;
|
||||
GradientStop g0 = fetch_gradient_stop(stop_index + 0);
|
||||
GradientStop g1 = fetch_gradient_stop(stop_index + 1);
|
||||
|
||||
vec4 segment_rect;
|
||||
switch (int(gradient.kind.x)) {
|
||||
case GRADIENT_HORIZONTAL:
|
||||
float x0 = mix(gradient.start_end_point.x,
|
||||
gradient.start_end_point.z,
|
||||
g0.offset.x);
|
||||
float x1 = mix(gradient.start_end_point.x,
|
||||
gradient.start_end_point.z,
|
||||
g1.offset.x);
|
||||
segment_rect.yw = prim.local_rect.yw;
|
||||
segment_rect.x = x0;
|
||||
segment_rect.z = x1 - x0;
|
||||
break;
|
||||
case GRADIENT_VERTICAL:
|
||||
float y0 = mix(gradient.start_end_point.y,
|
||||
gradient.start_end_point.w,
|
||||
g0.offset.x);
|
||||
float y1 = mix(gradient.start_end_point.y,
|
||||
gradient.start_end_point.w,
|
||||
g1.offset.x);
|
||||
segment_rect.xz = prim.local_rect.xz;
|
||||
segment_rect.y = y0;
|
||||
segment_rect.w = y1 - y0;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
TransformVertexInfo vi = write_transform_vertex(segment_rect,
|
||||
prim.local_clip_rect,
|
||||
prim.layer,
|
||||
prim.tile);
|
||||
vLocalRect = vi.clipped_local_rect;
|
||||
vLocalPos = vi.local_pos;
|
||||
vec2 f = (vi.local_pos.xy - prim.local_rect.xy) / prim.local_rect.zw;
|
||||
#else
|
||||
VertexInfo vi = write_vertex(segment_rect,
|
||||
prim.local_clip_rect,
|
||||
prim.layer,
|
||||
prim.tile);
|
||||
|
||||
vec2 f = (vi.local_clamped_pos - segment_rect.xy) / segment_rect.zw;
|
||||
vPos = vi.local_clamped_pos;
|
||||
#endif
|
||||
|
||||
switch (int(gradient.kind.x)) {
|
||||
case GRADIENT_HORIZONTAL:
|
||||
vColor = mix(g0.color, g1.color, f.x);
|
||||
break;
|
||||
case GRADIENT_VERTICAL:
|
||||
vColor = mix(g0.color, g1.color, f.y);
|
||||
break;
|
||||
case GRADIENT_ROTATED:
|
||||
vColor = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -13,8 +13,4 @@ void main(void) {
|
|||
|
||||
alpha = min(alpha, do_clip(local_pos));
|
||||
oFragColor = vColor * vec4(1, 1, 1, alpha);
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
oFragColor.a *= alpha;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -67,6 +67,6 @@ void main(void) {
|
|||
break;
|
||||
}
|
||||
|
||||
Clip clip = fetch_clip(prim.clip_index);
|
||||
ClipInfo clip = fetch_clip(prim.clip_index);
|
||||
write_clip(clip);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ void main(void) {
|
|||
vLocalPos = vi.local_clamped_pos;
|
||||
#endif
|
||||
|
||||
Clip clip = fetch_clip(prim.clip_index);
|
||||
ClipInfo clip = fetch_clip(prim.clip_index);
|
||||
write_clip(clip);
|
||||
|
||||
// vUv will contain how many times this image has wrapped around the image size.
|
||||
|
|
|
@ -22,6 +22,6 @@ void main(void) {
|
|||
vPos = vi.local_clamped_pos;
|
||||
#endif
|
||||
|
||||
Clip clip = fetch_clip(prim.clip_index);
|
||||
ClipInfo clip = fetch_clip(prim.clip_index);
|
||||
write_clip(clip);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue