pub struct RenderTargetBrowserSurface { /* private fields */ }Expand description
The surface of a view that is rendered through a render target of the page (a WebGL context or a 2D canvas).
The object belongs to the thread of the user interface. What the thread
that renders needs of the canvas is in the two objects it shares with
that thread: BrowserSurfaceShared (the id of the render target, the
size, whether the target exists and its kind) and the
BrowserRenderSurface over it, which is the surface the compositor
draws to.
Implementations§
Source§impl RenderTargetBrowserSurface
impl RenderTargetBrowserSurface
Sourcepub fn create(
container: &JsObject,
modes: &[BrowserRenderingMode],
top_level_id: i32,
) -> Rc<Self>
pub fn create( container: &JsObject, modes: &[BrowserRenderingMode], top_level_id: i32, ) -> Rc<Self>
Creates a canvas in container with a render target of the first of
modes the browser supports, and the surface over it.
Sourcepub fn compositor(&self) -> Rc<Compositor>
pub fn compositor(&self) -> Rc<Compositor>
The compositor that renders to the surface.
Sourcepub fn client_size(&self) -> Size
pub fn client_size(&self) -> Size
The size in logical units.
Sourcepub fn render_size(&self) -> PixelSize
pub fn render_size(&self) -> PixelSize
The size in device pixels.
Sourcepub fn size_changed(&self, handler: Rc<dyn Fn()>) -> u64
pub fn size_changed(&self, handler: Rc<dyn Fn()>) -> u64
Subscribes to changes of the client size.
Sourcepub fn scaling_changed(&self, handler: Rc<dyn Fn()>) -> u64
pub fn scaling_changed(&self, handler: Rc<dyn Fn()>) -> u64
Subscribes to changes of the scaling.
Sourcepub fn get_render_surfaces(&self) -> Vec<Arc<dyn IPlatformRenderSurface>>
pub fn get_render_surfaces(&self) -> Vec<Arc<dyn IPlatformRenderSurface>>
The surfaces a render backend can draw to: the render surface of the canvas. It is handed out from the start and is not ready until the thread that owns the render target has published it (upstream hands out nothing until then).
What the thread of the user interface and the thread that renders share about the canvas.
Sourcepub fn on_size_changed(&self, pixel_width: f64, pixel_height: f64, dpr: f64)
pub fn on_size_changed(&self, pixel_width: f64, pixel_height: f64, dpr: f64)
The canvas changed its size or its scaling.
Sourcepub fn dispose(&self)
pub fn dispose(&self)
Releases the canvas surface.
Upstream posts a job to the compositor, which takes its server
compositor out of the render loop, and then destroys the surface of
the script side. A job is not what this port can use: it runs with a
batch, and the batch of a closed view is the one that is likely never
applied (the compositor is dropped as soon as the media context has
committed it, and its graph is released in place of the next frame);
a job does not run either while the graphics are not ready. So the
thread that renders is given the work directly ([release_canvas]):
- this thread, when it renders the view itself: the work is done here, before the call returns;
- the render thread, when the compositor is confined to it: the work is queued for that thread, which enters the graph under the compositor lock. Whether it gets there before or after the graph is released does not matter: a graph that is released has released what it drew with, in its own graphics context.
The top-level is disposed before its renderer: the composition target of the view is disposed after this call, in a batch of its own that this thread waits for. The work does not depend on which of the two reaches the thread that renders first.
A canvas that never reached the render thread (the view was closed before that thread had reported itself) is let go of here: the script of this thread still holds it back. When the work cannot be queued for a render thread that runs, the canvas is only marked as disposed and stays alive in the worker, unused.
A surface that is dropped without this call makes it itself: a view that is let go of without being closed releases what it drew with in the same way, and not when its compositor happens to be dropped.
Trait Implementations§
Source§impl Drop for RenderTargetBrowserSurface
impl Drop for RenderTargetBrowserSurface
Auto Trait Implementations§
impl !Freeze for RenderTargetBrowserSurface
impl !RefUnwindSafe for RenderTargetBrowserSurface
impl !Send for RenderTargetBrowserSurface
impl !Sync for RenderTargetBrowserSurface
impl !UnwindSafe for RenderTargetBrowserSurface
impl Unpin for RenderTargetBrowserSurface
impl UnsafeUnpin for RenderTargetBrowserSurface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more