summaryrefslogtreecommitdiffstats
path: root/gfx/wr/wrench/src/angle.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /gfx/wr/wrench/src/angle.rs
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/wr/wrench/src/angle.rs')
-rw-r--r--gfx/wr/wrench/src/angle.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/gfx/wr/wrench/src/angle.rs b/gfx/wr/wrench/src/angle.rs
new file mode 100644
index 0000000000..94be95a625
--- /dev/null
+++ b/gfx/wr/wrench/src/angle.rs
@@ -0,0 +1,62 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use glutin::{self, ContextBuilder, ContextCurrentState, CreationError};
+use winit::{event_loop::EventLoop, window::Window, window::WindowBuilder};
+
+#[cfg(not(windows))]
+pub enum Context {}
+
+#[cfg(windows)]
+pub use crate::egl::Context;
+
+impl Context {
+ #[cfg(not(windows))]
+ pub fn with_window<T: ContextCurrentState>(
+ _: WindowBuilder,
+ _: ContextBuilder<'_, T>,
+ _: &EventLoop<()>,
+ ) -> Result<(Window, Self), CreationError> {
+ Err(CreationError::PlatformSpecific(
+ "ANGLE rendering is only supported on Windows".into(),
+ ))
+ }
+
+ #[cfg(windows)]
+ pub fn with_window<T: ContextCurrentState>(
+ window_builder: WindowBuilder,
+ context_builder: ContextBuilder<'_, T>,
+ events_loop: &EventLoop<()>,
+ ) -> Result<(Window, Self), CreationError> {
+ use winit::platform::windows::WindowExtWindows;
+
+ // FIXME: &context_builder.pf_reqs https://github.com/tomaka/glutin/pull/1002
+ let pf_reqs = &glutin::PixelFormatRequirements::default();
+ let gl_attr = &context_builder.gl_attr.map_sharing(|_| unimplemented!());
+ let window = window_builder.build(events_loop)?;
+ Self::new(pf_reqs, gl_attr)
+ .and_then(|p| p.finish(window.hwnd() as _))
+ .map(|context| (window, context))
+ }
+
+ #[cfg(not(windows))]
+ pub unsafe fn make_current(&self) -> Result<(), glutin::ContextError> {
+ match *self {}
+ }
+
+ #[cfg(not(windows))]
+ pub fn get_proc_address(&self, _: &str) -> *const () {
+ match *self {}
+ }
+
+ #[cfg(not(windows))]
+ pub fn swap_buffers(&self) -> Result<(), glutin::ContextError> {
+ match *self {}
+ }
+
+ #[cfg(not(windows))]
+ pub fn get_api(&self) -> glutin::Api {
+ match *self {}
+ }
+}