feat: Turn RenderingContext into a trait (#35052)

* feat: turn RenderingContext into a trait

Signed-off-by: DK Liao <dklassic@gmail.com>

Add comment and handle drop error

Signed-off-by: DK Liao <dklassic@gmail.com>

Add doc comment

Signed-off-by: DK Liao <dklassic@gmail.com>

Allow make_current to propagate Error

Signed-off-by: DK Liao <dklassic@gmail.com>

Fix all make_current occurances

Signed-off-by: DK Liao <dklassic@gmail.com>

Move back to Rc<dyn RenderingContext>

Signed-off-by: DK Liao <dklassic@gmail.com>

fix android/ohos

Signed-off-by: DK Liao <dklassic@gmail.com>

Fix build

Signed-off-by: DK Liao <dklassic@gmail.com>

fix android/ohos again

Signed-off-by: DK Liao <dklassic@gmail.com>

* Fix macOS smoke test

Signed-off-by: DK Liao <dklassic@gmail.com>

* Add comment for create_texture and destroy_texture

Signed-off-by: DK Liao <dklassic@gmail.com>

* Improve comments written

Signed-off-by: DK Liao <dklassic@gmail.com>

---------

Signed-off-by: DK Liao <dklassic@gmail.com>
This commit is contained in:
DK Liao 2025-01-24 10:39:39 +08:00 committed by GitHub
parent ac22157491
commit a0eceee2ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 236 additions and 112 deletions

View file

@ -18,7 +18,7 @@ pub use servo::embedder_traits::EventLoopWaker;
pub use servo::embedder_traits::{InputMethodType, MediaSessionPlaybackState, PromptResult};
use servo::servo_url::ServoUrl;
pub use servo::webrender_api::units::DeviceIntRect;
use servo::webrender_traits::RenderingContext;
use servo::webrender_traits::SurfmanRenderingContext;
use servo::{self, Servo};
use surfman::{Connection, SurfaceType};
@ -98,7 +98,7 @@ pub fn init(
SurfaceType::Widget { native_widget }
},
};
let rendering_context = RenderingContext::create(&connection, &adapter, None)
let rendering_context = SurfmanRenderingContext::create(&connection, &adapter, None)
.or(Err("Failed to create surface manager"))?;
let surface = rendering_context
.create_surface(surface_type)
@ -122,7 +122,7 @@ pub fn init(
let servo = Servo::new(
opts,
preferences,
rendering_context.clone(),
Rc::new(rendering_context.clone()),
embedder_callbacks,
window_callbacks.clone(),
None,