Skip to content

Commit

Permalink
Check that engine types don't already match before setting a new engi…
Browse files Browse the repository at this point in the history
…ne type.
  • Loading branch information
mpaperno committed Aug 16, 2023
1 parent f0e6d81 commit c364fbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ pub fn get_engine(mut cx: FunctionContext) -> JsResult<JsString> {
pub fn set_engine(mut cx: FunctionContext) -> JsResult<JsUndefined> {
let this = cx.argument::<BoxedCanvas>(0)?;
if let Some(engine_name) = opt_string_arg(&mut cx, 1){
if let Some(new_engine) = to_engine(&engine_name){
if new_engine.supported() {
this.borrow_mut().engine = new_engine
if let Some(new_engine) = to_engine(&engine_name) {
if new_engine != this.borrow().engine {
if new_engine.supported() {
this.borrow_mut().engine = new_engine
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/gpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use crate::gpu::metal::autoreleasepool as runloop;
pub fn runloop<T, F: FnOnce() -> T>(f: F) -> T { f() }

#[derive(Copy, Clone, Debug)]
#[derive(PartialEq)]
pub enum RenderingEngine{
CPU,
GPU,
Expand Down

0 comments on commit c364fbd

Please sign in to comment.