mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Simplify RenderingContext
trait methods (#35251)
There are a few methods are still difficult to implement without the help of surfman. To simplify the trait methods, all methods that return surfman types are removed. They are either handled by embedders themselves or abstract to simpler types that servo components need. The most noticeable changes are: - Methods related to native surface are moved to servo_glue. The embedder should decide when to remove/replace the surface and it's outside of servo's scope. - Methods required by servo media now return exact media types for it. The other major change is sevevral difficult trait methods that are reuiqred by WebGL and Servo media have default implementation. So they can be optional for users to implement. Signed-off-by: Wu Wayne <yuweiwu@pm.me>
This commit is contained in:
parent
175f28866d
commit
07aa4ce093
10 changed files with 176 additions and 230 deletions
|
@ -479,23 +479,6 @@ impl IOCompositor {
|
|||
self.shutdown_state = ShutdownState::FinishedShuttingDown;
|
||||
}
|
||||
|
||||
/// The underlying native surface can be lost during servo's lifetime.
|
||||
/// On Android, for example, this happens when the app is sent to background.
|
||||
/// We need to unbind the surface so that we don't try to use it again.
|
||||
pub fn invalidate_native_surface(&mut self) {
|
||||
debug!("Invalidating native surface in compositor");
|
||||
self.rendering_context.invalidate_native_surface();
|
||||
}
|
||||
|
||||
/// On Android, this function will be called when the app moves to foreground
|
||||
/// and the system creates a new native surface that needs to bound to the current
|
||||
/// context.
|
||||
pub fn replace_native_surface(&mut self, native_widget: *mut c_void, coords: DeviceIntSize) {
|
||||
debug!("Replacing native surface in compositor: {native_widget:?}");
|
||||
self.rendering_context
|
||||
.replace_native_surface(native_widget, coords);
|
||||
}
|
||||
|
||||
fn handle_browser_message(&mut self, msg: CompositorMsg) -> bool {
|
||||
trace_msg_from_constellation!(msg, "{msg:?}");
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ use embedder_traits::{
|
|||
};
|
||||
use euclid::Scale;
|
||||
use keyboard_types::{CompositionEvent, KeyboardEvent};
|
||||
use libc::c_void;
|
||||
use net::protocols::ProtocolRegistry;
|
||||
use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel};
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -119,14 +118,6 @@ pub enum EmbedderEvent {
|
|||
SetWebViewThrottled(TopLevelBrowsingContextId, bool),
|
||||
/// Virtual keyboard was dismissed
|
||||
IMEDismissed,
|
||||
/// Sent on platforms like Android where the native widget surface can be
|
||||
/// automatically destroyed by the system, for example when the app
|
||||
/// is sent to background.
|
||||
InvalidateNativeSurface,
|
||||
/// Sent on platforms like Android where system recreates a new surface for
|
||||
/// the native widget when it is brough back to foreground. This event
|
||||
/// carries the pointer to the native widget and its new size.
|
||||
ReplaceNativeSurface(*mut c_void, DeviceIntSize),
|
||||
/// Sent when new Gamepad information is available.
|
||||
Gamepad(GamepadEvent),
|
||||
/// Vertical Synchronization tick
|
||||
|
@ -190,8 +181,6 @@ impl Debug for EmbedderEvent {
|
|||
EmbedderEvent::SetWebViewThrottled(..) => write!(f, "SetWebViewThrottled"),
|
||||
EmbedderEvent::IMEDismissed => write!(f, "IMEDismissed"),
|
||||
EmbedderEvent::ClearCache => write!(f, "ClearCache"),
|
||||
EmbedderEvent::InvalidateNativeSurface => write!(f, "InvalidateNativeSurface"),
|
||||
EmbedderEvent::ReplaceNativeSurface(..) => write!(f, "ReplaceNativeSurface"),
|
||||
EmbedderEvent::Gamepad(..) => write!(f, "Gamepad"),
|
||||
EmbedderEvent::Vsync => write!(f, "Vsync"),
|
||||
EmbedderEvent::ClipboardAction(_) => write!(f, "ClipboardAction"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue