#gpu-accelerated #renderer #content #2d #zng #web #fork

zng-webrender

A GPU accelerated 2D renderer for web content

6 releases

0.64.1 Nov 3, 2024
0.64.0 Sep 28, 2024
0.63.1 Jun 10, 2024
0.62.2 Apr 10, 2024

#142 in Graphics APIs

Download history 112/week @ 2024-07-29 91/week @ 2024-08-05 294/week @ 2024-08-12 140/week @ 2024-08-19 171/week @ 2024-08-26 334/week @ 2024-09-02 155/week @ 2024-09-09 233/week @ 2024-09-16 481/week @ 2024-09-23 250/week @ 2024-09-30 226/week @ 2024-10-07 362/week @ 2024-10-14 180/week @ 2024-10-21 340/week @ 2024-10-28 298/week @ 2024-11-04 150/week @ 2024-11-11

982 downloads per month
Used in 2 crates (via zng-view)

MPL-2.0 license

4.5MB
89K SLoC

This crate is a fork of servo/webrender published for use in zng-ui/zng.

Feel free to use it in your own project, the code is the same, the crate is just renamed with "zng-" prefix.


lib.rs:

A GPU based renderer for the web.

It serves as an experimental render backend for Servo, but it can also be used as such in a standalone application.

External dependencies

WebRender currently depends on FreeType

Api Structure

The main entry point to WebRender is the crate::Renderer.

By calling Renderer::new(...) you get a Renderer, as well as a RenderApiSender. Your Renderer is responsible to render the previously processed frames onto the screen.

By calling yourRenderApiSender.create_api(), you'll get a RenderApi instance, which is responsible for managing resources and documents. A worker thread is used internally to untie the workload from the application thread and therefore be able to make better use of multicore systems.

Frame

What is referred to as a frame, is the current geometry on the screen. A new Frame is created by calling set_display_list() on the RenderApi. When the geometry is processed, the application will be informed via a RenderNotifier, a callback which you pass to Renderer::new. More information about stacking contexts.

set_display_list() also needs to be supplied with BuiltDisplayLists. These are obtained by finalizing a DisplayListBuilder. These are used to draw your geometry. But it doesn't only contain trivial geometry, it can also store another StackingContext, as they're nestable.

Dependencies

~3.5–7.5MB
~149K SLoC