mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #20749 - mbrubeck:pinch, r=glennw
Basic pinch zoom handling r? glennw Basic fix for #20387 and #20109. Note: Without calling `generate_frame` when updating Webrender's pinch zoom level, rendering doesn't happen reliably during/after a pinch zoom gesture. I'm not sure whether this is the correct way to fix that or not. <!-- 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/20749) <!-- Reviewable:end -->
This commit is contained in:
commit
6ad085be59
1 changed files with 17 additions and 2 deletions
|
@ -918,6 +918,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
(delta * old_event_count + this_delta) /
|
||||
new_event_count);
|
||||
}
|
||||
last_combined_event.magnification *= scroll_event.magnification;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -937,6 +938,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let cursor = webrender_api::WorldPoint::from_untyped(&cursor);
|
||||
let mut txn = webrender_api::Transaction::new();
|
||||
txn.scroll(scroll_location, cursor);
|
||||
if combined_event.magnification != 1.0 {
|
||||
let old_zoom = self.pinch_zoom_level();
|
||||
self.set_pinch_zoom_level(old_zoom * combined_event.magnification);
|
||||
txn.set_pinch_zoom(webrender_api::ZoomFactor::new(self.pinch_zoom_level()));
|
||||
}
|
||||
txn.generate_frame();
|
||||
self.webrender_api.send_transaction(self.webrender_document, txn);
|
||||
self.waiting_for_results_of_scroll = true
|
||||
|
@ -1377,8 +1383,17 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
|
||||
pub fn pinch_zoom_level(&self) -> f32 {
|
||||
// TODO(gw): Access via WR.
|
||||
1.0
|
||||
self.viewport_zoom.get()
|
||||
}
|
||||
|
||||
fn set_pinch_zoom_level(&mut self, mut zoom: f32) {
|
||||
if let Some(min) = self.min_viewport_zoom {
|
||||
zoom = f32::max(min.get(), zoom);
|
||||
}
|
||||
if let Some(max) = self.max_viewport_zoom {
|
||||
zoom = f32::min(max.get(), zoom);
|
||||
}
|
||||
self.viewport_zoom = PinchZoomFactor::new(zoom);
|
||||
}
|
||||
|
||||
pub fn toggle_webrender_debug(&mut self, option: WebRenderDebugOption) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue