Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension: Log used renderer. #10909

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions render/canvas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ impl RenderBackend for WebCanvasRenderBackend {
Cow::Borrowed("Renderer: Canvas")
}

fn name(&self) -> &'static str {
"canvas"
}

fn set_quality(&mut self, _quality: StageQuality) {}
}

Expand Down
4 changes: 4 additions & 0 deletions render/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub trait RenderBackend: Downcast {
fn context3d_present(&mut self, context: &mut dyn Context3D) -> Result<(), Error>;

fn debug_info(&self) -> Cow<'static, str>;
/// An internal name that is used to identify the render-backend.
/// For valid values, look at:
/// web/packages/core/src/load-options.ts:RenderBackend
fn name(&self) -> &'static str;

fn set_quality(&mut self, quality: StageQuality);
}
Expand Down
4 changes: 4 additions & 0 deletions render/src/backend/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ impl RenderBackend for NullRenderer {
Cow::Borrowed("Renderer: Null")
}

fn name(&self) -> &'static str {
""
}

fn set_quality(&mut self, _quality: StageQuality) {}
}
4 changes: 4 additions & 0 deletions render/webgl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,10 @@ impl RenderBackend for WebGlRenderBackend {
Cow::Owned(result.join("\n"))
}

fn name(&self) -> &'static str {
"webgl"
}

fn set_quality(&mut self, _quality: StageQuality) {}
}

Expand Down
4 changes: 4 additions & 0 deletions render/wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
Cow::Owned(result.join("\n"))
}

fn name(&self) -> &'static str {
"webgpu"
}

fn set_quality(&mut self, quality: StageQuality) {
self.surface = Surface::new(
&self.descriptors,
Expand Down
11 changes: 9 additions & 2 deletions web/packages/core/src/ruffle-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,17 @@ export class RufflePlayer extends HTMLElement {
this.loadedConfig
);
this._cachedDebugInfo = this.instance!.renderer_debug_info();

const actuallyUsedRendererName = this.instance!.renderer_name();

console.log(
"New Ruffle instance created (WebAssembly extensions: " +
"%c" +
"New Ruffle instance created (WebAssembly extensions: " +
(ruffleConstructor.is_wasm_simd_used() ? "ON" : "OFF") +
")"
" | Used renderer: " +
(actuallyUsedRendererName ?? "") +
")",
"background: #37528C; color: #FFAD33"
);

// In Firefox, AudioContext.state is always "suspended" when the object has just been created.
Expand Down
5 changes: 5 additions & 0 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ impl Ruffle {
.unwrap_or(JsValue::NULL)
}

pub fn renderer_name(&self) -> JsValue {
self.with_core(|core| JsValue::from_str(core.renderer().name()))
.unwrap_or(JsValue::NULL)
}

// after the context menu is closed, remember to call `clear_custom_menu_items`!
pub fn prepare_context_menu(&mut self) -> JsValue {
self.with_core_mut(|core| {
Expand Down