Skip to content

Commit

Permalink
Auto merge of rust-windowing#469 - floppyhammer:fix-d3d9-cohen-suther…
Browse files Browse the repository at this point in the history
…land-implementation, r=jdm

Fix Cohen-Sutherland algorithm implementation for d3d9

Fix the artifact caused by view box clipping on d3d9 level. Note that d3d11 doesn't have this issue.

![clipping_issue](https://user-images.githubusercontent.com/28705694/125883499-53ea8660-f7e2-43a5-ab27-8f820da9a05a.gif)
  • Loading branch information
bors-servo authored Jul 19, 2021
2 parents 62fbfcc + 7a57ce2 commit 6ce65b2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions content/src/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,25 +515,25 @@ pub fn clip_line_segment_to_rect(mut line_segment: LineSegment2F, rect: RectF)
point = vec2f(rect.min_x(),
lerp(line_segment.from_y(),
line_segment.to_y(),
(line_segment.min_x() - line_segment.from_x()) /
(line_segment.max_x() - line_segment.min_x())));
(rect.min_x() - line_segment.from_x()) /
(line_segment.to_x() - line_segment.from_x())));
} else if outcode.contains(Outcode::RIGHT) {
point = vec2f(rect.max_x(),
lerp(line_segment.from_y(),
line_segment.to_y(),
(line_segment.max_x() - line_segment.from_x()) /
(line_segment.max_x() - line_segment.min_x())));
(rect.max_x() - line_segment.from_x()) /
(line_segment.to_x() - line_segment.from_x())));
} else if outcode.contains(Outcode::TOP) {
point = vec2f(lerp(line_segment.from_x(),
line_segment.to_x(),
(line_segment.min_y() - line_segment.from_y()) /
(line_segment.max_y() - line_segment.min_y())),
(rect.min_y() - line_segment.from_y()) /
(line_segment.to_y() - line_segment.from_y())),
rect.min_y());
} else if outcode.contains(Outcode::BOTTOM) {
point = vec2f(lerp(line_segment.from_x(),
line_segment.to_x(),
(line_segment.max_y() - line_segment.from_y()) /
(line_segment.max_y() - line_segment.min_y())),
(rect.max_y() - line_segment.from_y()) /
(line_segment.to_y() - line_segment.from_y())),
rect.max_y());
}

Expand Down

0 comments on commit 6ce65b2

Please sign in to comment.