Use webrender UploadMethod::Immediate with ANGLE (#33177)

* Use webrender UploadMethod::Immediate with ANGLE

Signed-off-by: crbrz <cristianb@gmail.com>

* Added comment with Gecko link

Signed-off-by: crbrz <cristianb@gmail.com>

---------

Signed-off-by: crbrz <cristianb@gmail.com>
This commit is contained in:
Cristian Brinza 2024-08-25 08:43:06 +03:00 committed by GitHub
parent 6caaa0c955
commit c79d9e68a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,6 +66,7 @@ use fonts::FontCacheThread;
))] ))]
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods}; use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
pub use gleam::gl; pub use gleam::gl;
use gleam::gl::RENDERER;
use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::ipc::{self, IpcSender};
#[cfg(feature = "layout_2013")] #[cfg(feature = "layout_2013")]
pub use layout_thread_2013; pub use layout_thread_2013;
@ -89,7 +90,7 @@ use surfman::platform::generic::multi::context::NativeContext as LinuxNativeCont
use surfman::{GLApi, GLVersion}; use surfman::{GLApi, GLVersion};
#[cfg(all(target_os = "linux", not(target_env = "ohos")))] #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
use surfman::{NativeConnection, NativeContext}; use surfman::{NativeConnection, NativeContext};
use webrender::{RenderApiSender, ShaderPrecacheFlags}; use webrender::{RenderApiSender, ShaderPrecacheFlags, UploadMethod, ONE_TIME_USAGE_HINT};
use webrender_api::{ use webrender_api::{
ColorF, DocumentId, FontInstanceFlags, FontInstanceKey, FontKey, FramePublishId, ImageKey, ColorF, DocumentId, FontInstanceFlags, FontInstanceKey, FontKey, FramePublishId, ImageKey,
NativeFontHandle, NativeFontHandle,
@ -333,6 +334,13 @@ where
clear_color[2] as f32, clear_color[2] as f32,
clear_color[3] as f32, clear_color[3] as f32,
); );
// Use same texture upload method as Gecko with ANGLE:
// https://searchfox.org/mozilla-central/source/gfx/webrender_bindings/src/bindings.rs#1215-1219
let upload_method = if webrender_gl.get_string(RENDERER).starts_with("ANGLE") {
UploadMethod::Immediate
} else {
UploadMethod::PixelBuffer(ONE_TIME_USAGE_HINT)
};
webrender::create_webrender_instance( webrender::create_webrender_instance(
webrender_gl.clone(), webrender_gl.clone(),
render_notifier, render_notifier,
@ -354,6 +362,7 @@ where
!opts.debug.disable_subpixel_text_antialiasing, !opts.debug.disable_subpixel_text_antialiasing,
allow_texture_swizzling: pref!(gfx.texture_swizzling.enabled), allow_texture_swizzling: pref!(gfx.texture_swizzling.enabled),
clear_color, clear_color,
upload_method,
..Default::default() ..Default::default()
}, },
None, None,