diff --git a/webrender/res/prim_shared.glsl b/webrender/res/prim_shared.glsl index 4566c19da2..f568f224ae 100644 --- a/webrender/res/prim_shared.glsl +++ b/webrender/res/prim_shared.glsl @@ -549,6 +549,10 @@ TransformVertexInfo write_transform_vertex(RectWithSize instance_rect, vec2 current_local_pos, prev_local_pos, next_local_pos; + // Clamp to the two local clip rects. + local_rect.p0 = clamp_rect(clamp_rect(local_rect.p0, local_clip_rect), layer.local_clip_rect); + local_rect.p1 = clamp_rect(clamp_rect(local_rect.p1, local_clip_rect), layer.local_clip_rect); + // Select the current vertex and the previous/next vertices, // based on the vertex ID that is known based on the instance rect. switch (gl_VertexID) { diff --git a/webrender/res/ps_image.glsl b/webrender/res/ps_image.glsl index 74f3528505..3cb2550356 100644 --- a/webrender/res/ps_image.glsl +++ b/webrender/res/ps_image.glsl @@ -15,6 +15,7 @@ flat varying float vLayer; #ifdef WR_FEATURE_TRANSFORM varying vec3 vLocalPos; +flat varying vec4 vLocalRect; #else varying vec2 vLocalPos; #endif @@ -34,6 +35,7 @@ void main(void) { prim.task, prim.local_rect); vLocalPos = vi.local_pos; + vLocalRect = vec4(prim.local_rect.p0, prim.local_rect.p0 + prim.local_rect.size); #else VertexInfo vi = write_vertex(prim.local_rect, prim.local_clip_rect, @@ -89,7 +91,7 @@ void main(void) { // We clamp the texture coordinate calculation here to the local rectangle boundaries, // which makes the edge of the texture stretch instead of repeat. - vec2 relative_pos_in_rect = clamp(pos, vLocalBounds.xy, vLocalBounds.zw) - vLocalBounds.xy; + vec2 relative_pos_in_rect = clamp(pos, vLocalRect.xy, vLocalRect.zw) - vLocalRect.xy; #else float alpha = 1.0; vec2 relative_pos_in_rect = vLocalPos; diff --git a/webrender/res/ps_yuv_image.glsl b/webrender/res/ps_yuv_image.glsl index 3fbf33bbd3..211b7b5e62 100644 --- a/webrender/res/ps_yuv_image.glsl +++ b/webrender/res/ps_yuv_image.glsl @@ -19,6 +19,7 @@ flat varying vec3 vLayers; #ifdef WR_FEATURE_TRANSFORM varying vec3 vLocalPos; +flat varying vec4 vLocalRect; #else varying vec2 vLocalPos; #endif @@ -43,6 +44,7 @@ void main(void) { prim.task, prim.local_rect); vLocalPos = vi.local_pos; + vLocalRect = vec4(prim.local_rect.p0, prim.local_rect.p0 + prim.local_rect.size); #else VertexInfo vi = write_vertex(prim.local_rect, prim.local_clip_rect, @@ -154,7 +156,7 @@ void main(void) { // We clamp the texture coordinate calculation here to the local rectangle boundaries, // which makes the edge of the texture stretch instead of repeat. - vec2 relative_pos_in_rect = clamp(pos, vLocalBounds.xy, vLocalBounds.zw) - vLocalBounds.xy; + vec2 relative_pos_in_rect = clamp(pos, vLocalRect.xy, vLocalRect.zw) - vLocalRect.xy; #else float alpha = 1.0;; vec2 relative_pos_in_rect = vLocalPos; diff --git a/wrench/reftests/reftest.list b/wrench/reftests/reftest.list index 2eda30bfa0..66d39a5d03 100644 --- a/wrench/reftests/reftest.list +++ b/wrench/reftests/reftest.list @@ -11,3 +11,5 @@ include scrolling/reftest.list include snap/reftest.list include split/reftest.list include text/reftest.list +include transforms/reftest.list + diff --git a/wrench/reftests/transforms/local-clip.png b/wrench/reftests/transforms/local-clip.png new file mode 100644 index 0000000000..ea9b6097e3 Binary files /dev/null and b/wrench/reftests/transforms/local-clip.png differ diff --git a/wrench/reftests/transforms/local-clip.yaml b/wrench/reftests/transforms/local-clip.yaml new file mode 100644 index 0000000000..1e05f6ccfd --- /dev/null +++ b/wrench/reftests/transforms/local-clip.yaml @@ -0,0 +1,27 @@ +--- +root: + items: + - + bounds: [0, 0, 1000, 1000] + "clip-rect": [0, 0, 1000, 1000] + type: clip + id: 3 + "content-size": [1000, 1000] + - + bounds: [0, 0, 0, 0] + "clip-and-scroll": 3 + type: "stacking-context" + transform: rotate(45) translate(200, 200) + items: + - + bounds: [0, 0, 100, 100] + "clip-rect": [0, 0, 100, 100] + "clip-and-scroll": 3 + type: clip + id: 4 + "content-size": [100, 100] + - + bounds: [2, -182, 152, 216] + "clip-rect": [2, 0, 152, 34] + "clip-and-scroll": 4 + image: solid-color(255, 0, 0, 255, 100, 100) diff --git a/wrench/reftests/transforms/reftest.list b/wrench/reftests/transforms/reftest.list new file mode 100644 index 0000000000..ff56970229 --- /dev/null +++ b/wrench/reftests/transforms/reftest.list @@ -0,0 +1,2 @@ +== local-clip.yaml local-clip.png +