diff --git a/gfx/wr/webrender/res/brush.glsl b/gfx/wr/webrender/res/brush.glsl index 034fe61609ad..6696c1a4a6f3 100644 --- a/gfx/wr/webrender/res/brush.glsl +++ b/gfx/wr/webrender/res/brush.glsl @@ -164,8 +164,12 @@ void main(void) { // Write the normal vertex information out. if (transform.is_axis_aligned) { + + // Select the corner of the local rect that we are processing. + vec2 local_pos = segment_rect.p0 + segment_rect.size * aPosition.xy; + vi = write_vertex( - segment_rect, + local_pos, ph.local_clip_rect, ph.z, transform, diff --git a/gfx/wr/webrender/res/prim_shared.glsl b/gfx/wr/webrender/res/prim_shared.glsl index 60c0fe7e5b7b..fb3b605ff706 100644 --- a/gfx/wr/webrender/res/prim_shared.glsl +++ b/gfx/wr/webrender/res/prim_shared.glsl @@ -109,15 +109,11 @@ struct VertexInfo { vec4 world_pos; }; -VertexInfo write_vertex(RectWithSize instance_rect, +VertexInfo write_vertex(vec2 local_pos, RectWithSize local_clip_rect, float z, Transform transform, PictureTask task) { - - // Select the corner of the local rect that we are processing. - vec2 local_pos = instance_rect.p0 + instance_rect.size * aPosition.xy; - // Clamp to the two local clip rects. vec2 clamped_local_pos = clamp_rect(local_pos, local_clip_rect); diff --git a/gfx/wr/webrender/res/ps_text_run.glsl b/gfx/wr/webrender/res/ps_text_run.glsl index 0fd1943ed7ba..20b3c6d5925b 100644 --- a/gfx/wr/webrender/res/ps_text_run.glsl +++ b/gfx/wr/webrender/res/ps_text_run.glsl @@ -220,26 +220,22 @@ void main(void) { vec2 local_pos = glyph_rect.p0 + glyph_rect.size * aPosition.xy; #endif - // Clamp to the local clip rect. - local_pos = clamp_rect(local_pos, ph.local_clip_rect); - - // Map the clamped local space corner into device space. - vec4 world_pos = transform.m * vec4(local_pos, 0.0, 1.0); - vec2 device_pos = world_pos.xy * task.device_pixel_scale; - - // Apply offsets for the render task to get correct screen location. - vec2 final_offset = -task.content_origin + task.common_data.task_rect.p0; - - gl_Position = uTransform * vec4(device_pos + final_offset * world_pos.w, ph.z * world_pos.w, world_pos.w); + VertexInfo vi = write_vertex( + local_pos, + ph.local_clip_rect, + ph.z, + transform, + task + ); #ifdef WR_FEATURE_GLYPH_TRANSFORM - vec2 f = (glyph_transform * local_pos - glyph_rect.p0) / glyph_rect.size; + vec2 f = (glyph_transform * vi.local_pos - glyph_rect.p0) / glyph_rect.size; V_UV_CLIP = vec4(f, 1.0 - f); #else - vec2 f = (local_pos - glyph_rect.p0) / glyph_rect.size; + vec2 f = (vi.local_pos - glyph_rect.p0) / glyph_rect.size; #endif - write_clip(world_pos, clip_area); + write_clip(vi.world_pos, clip_area); switch (color_mode) { case COLOR_MODE_ALPHA: