Skip to content

Commit 37622ba

Browse files
author
bors-servo
authored
Auto merge of #1773 - glennw:fix-clip-rotated, r=kvark
Fix rounded clips on rotated rects. We can only safely (for now) apply the clip mask corner optimization if the primitive is axis aligned. In the future, we can handle this once we improve how inner rect calculations work. Fixes #1729 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1773) <!-- Reviewable:end -->
2 parents 6b29455 + b3464b0 commit 37622ba

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

webrender/src/prim_store.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use render_task::{ClipWorkItem, RenderTask, RenderTaskId, RenderTaskTree};
1818
use renderer::MAX_VERTEX_TEXTURE_WIDTH;
1919
use resource_cache::{ImageProperties, ResourceCache};
2020
use std::{mem, usize};
21-
use util::{pack_as_float, recycle_vec, TransformedRect};
21+
use util::{MatrixHelpers, pack_as_float, recycle_vec, TransformedRect};
2222

2323
#[derive(Debug, Copy, Clone)]
2424
pub struct PrimitiveOpacity {
@@ -1142,6 +1142,7 @@ impl PrimitiveStore {
11421142

11431143
// Try to create a mask if we may need to.
11441144
let prim_clips = clip_store.get(&metadata.clip_sources);
1145+
let is_axis_aligned = prim_context.packed_layer.transform.preserves_2d_axis_alignment();
11451146
let clip_task = if prim_clips.is_masking() {
11461147
// Take into account the actual clip info of the primitive, and
11471148
// mutate the current bounds accordingly.
@@ -1169,6 +1170,7 @@ impl PrimitiveStore {
11691170
Some(extra),
11701171
prim_screen_rect,
11711172
clip_store,
1173+
is_axis_aligned,
11721174
)
11731175
} else if !prim_context.current_clip_stack.is_empty() {
11741176
// If the primitive doesn't have a specific clip, key the task ID off the
@@ -1182,6 +1184,7 @@ impl PrimitiveStore {
11821184
None,
11831185
prim_screen_rect,
11841186
clip_store,
1187+
is_axis_aligned,
11851188
)
11861189
} else {
11871190
None

webrender/src/render_task.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ impl RenderTask {
307307
extra_clip: Option<ClipWorkItem>,
308308
prim_rect: DeviceIntRect,
309309
clip_store: &ClipStore,
310+
is_axis_aligned: bool,
310311
) -> Option<RenderTask> {
311312
// Filter out all the clip instances that don't contribute to the result
312313
let mut inner_rect = Some(task_rect);
@@ -358,7 +359,7 @@ impl RenderTask {
358359
if inner_rect.contains_rect(&prim_rect) {
359360
return None;
360361
}
361-
if clips.len() == 1 {
362+
if is_axis_aligned && clips.len() == 1 {
362363
geometry_kind = clips[0].get_geometry_kind(clip_store);
363364
}
364365
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
== local-clip.yaml local-clip.png
2+
== rotated-clip.yaml rotated-clip.png
23

3.2 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
root:
3+
items:
4+
-
5+
bounds: 100 100 100 100
6+
items:
7+
- type: clip
8+
bounds: [20, 20, 100, 100]
9+
complex:
10+
- rect: [20, 20, 100, 100]
11+
radius: 32
12+
items:
13+
- type: rect
14+
bounds: 20 20 100 100
15+
color: blue
16+
type: stacking-context
17+
transform: rotate(30)

0 commit comments

Comments
 (0)