tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

angle.rs (2067B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 use glutin::{self, ContextBuilder, ContextCurrentState, CreationError};
      6 use winit::{event_loop::EventLoop, window::Window, window::WindowBuilder};
      7 
      8 #[cfg(not(windows))]
      9 pub enum Context {}
     10 
     11 #[cfg(windows)]
     12 pub use crate::egl::Context;
     13 
     14 impl Context {
     15    #[cfg(not(windows))]
     16    pub fn with_window<T: ContextCurrentState>(
     17        _: WindowBuilder,
     18        _: ContextBuilder<'_, T>,
     19        _: &EventLoop<()>,
     20        _: bool,
     21    ) -> Result<(Window, Self), CreationError> {
     22        Err(CreationError::PlatformSpecific(
     23            "ANGLE rendering is only supported on Windows".into(),
     24        ))
     25    }
     26 
     27    #[cfg(windows)]
     28    pub fn with_window<T: ContextCurrentState>(
     29        window_builder: WindowBuilder,
     30        context_builder: ContextBuilder<'_, T>,
     31        events_loop: &EventLoop<()>,
     32        using_compositor: bool,
     33    ) -> Result<(Window, Self), CreationError> {
     34        use winit::platform::windows::WindowExtWindows;
     35 
     36        // FIXME: &context_builder.pf_reqs  https://github.com/tomaka/glutin/pull/1002
     37        let pf_reqs = &glutin::PixelFormatRequirements::default();
     38        let gl_attr = &context_builder.gl_attr.map_sharing(|_| unimplemented!());
     39        let window = window_builder.build(events_loop)?;
     40        Self::new(pf_reqs, gl_attr)
     41            .and_then(|p| p.finish(window.hwnd() as _, using_compositor))
     42            .map(|context| (window, context))
     43    }
     44 
     45    #[cfg(not(windows))]
     46    pub unsafe fn make_current(&self) -> Result<(), glutin::ContextError> {
     47        match *self {}
     48    }
     49 
     50    #[cfg(not(windows))]
     51    pub fn get_proc_address(&self, _: &str) -> *const () {
     52        match *self {}
     53    }
     54 
     55    #[cfg(not(windows))]
     56    pub fn swap_buffers(&self) -> Result<(), glutin::ContextError> {
     57        match *self {}
     58    }
     59 
     60    #[cfg(not(windows))]
     61    pub fn get_api(&self) -> glutin::Api {
     62        match *self {}
     63    }
     64 }