Project Layout - ruffle-rs/ruffle GitHub Wiki
Project Layout
core
: Core emulator code, shared among all platformsdesktop
: Desktop frontend and backend coderender
: Rendering backends codeswf
: Crate to handle SWF and AS parsingvideo
: Video decoding backendsweb
: Web frontend and backend codepackages/demo
: The web demo page (served at https://ruffle.rs/demo/)packages/extension
: The Ruffle browser extension
wstr
: A Flash-compatible implementation of strings using the UCS-2 character set
Core
The core
directory contains the Flash Player emulation code. This is used on all platforms to parse and execute the SWF file. The Player
struct is the main entry point of the core code.
SWF
The swf
directory contains a library for reading and writing SWF files and ActionScript bytecode.
Backends
There are several different types of backends to handle platform-specific behavior. There is a trait defining the interface for each type of backend. In addition, a "null" backend is provided for "no-op" behavior during development (for example, NullAudioBackend
does not play any audio).
An instance of each backend type is passed into Player
when it is created. Player
uses trait objects to reference the backends, allowing for the backends to be dynamically chosen at runtime.
Rendering backend
The rendering backend handles drawing vector art, bitmaps, and text in whatever way suits the platform. The interface is defined by the RenderBackend
trait.
Current rendering backends:
- Desktop and web
WgpuRenderBackend
(usinglyon
for vector art tessellation andwgpu
for rendering)NullRenderer
- Web only
WebCanvasRenderBackend
(usingCanvasRenderingContext2D
)WebGlRenderBackend
(using WebGL)
Potential future changes:
- Desktop
- Add software rendering backend?
Audio backend
The audio backend controls the playback, mixing, and dynamic control of audio from the SWF file. The interface is defined by the AudioBackend
trait.
Current audio backends:
NullAudioBackend
CpalAudioBackend
(desktop, usingcpal
)WebAudioBackend
(web, using Web Audio API).
Potential future changes:
- Web
- Use
AudioWorklet
as they become standardized.
- Use
UI Backend
The user interface backend handles things such as keyboard and mouse events and changing mouse pointer state. The interface is defined by the UiBackend
trait.
Current UI backends:
NullUiBackend
DesktopUiBackend
(desktop)WebUiBackend
(web)
Navigator Backend
The navigator backend handles things such as loading external content, HTTP calls, or browsing to different pages. The interface is defined by the NavigatorBackend
trait.
Current navigator backends:
NullNavigatorBackend
ExternalNavigatorBackend
(desktop)WebNavigatorBackend
(web)