Skip to content

Commit 9153157

Browse files
ref, rename
1 parent 4fee76e commit 9153157

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

core/src/avm2/globals/flash/display3D/context_3d.rs

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,10 @@ pub fn set_culling<'gc>(
293293
if let Some(context) = this.as_context_3d() {
294294
let culling = args.get_string(activation, 0)?;
295295

296-
let culling = if &*culling == b"none" {
297-
Context3DTriangleFace::None
298-
} else if &*culling == b"back" {
299-
Context3DTriangleFace::Back
300-
} else if &*culling == b"front" {
301-
Context3DTriangleFace::Front
302-
} else if &*culling == b"frontAndBack" {
303-
Context3DTriangleFace::FrontAndBack
304-
} else {
296+
let culling = Context3DTriangleFace::from_wstr(&culling).unwrap_or_else(|| {
305297
tracing::error!("Unknown culling {:?}", culling);
306298
Context3DTriangleFace::None
307-
};
299+
});
308300

309301
context.set_culling(culling);
310302
}
@@ -694,45 +686,37 @@ pub fn set_stencil_actions<'gc>(
694686
let this = this.as_object().unwrap();
695687

696688
if let Some(context) = this.as_context_3d() {
697-
let triangle_face = args.get_string_non_null(activation, 0, "triangleFace")?;
689+
let triangle_face = args.get_string(activation, 0)?;
698690

699-
let culling = if &*triangle_face == b"none" {
691+
let triangle_face = Context3DTriangleFace::from_wstr(&triangle_face).unwrap_or_else(|| {
692+
tracing::error!("Unknown triangle_face {:?}", triangle_face);
700693
Context3DTriangleFace::None
701-
} else if &*triangle_face == b"back" {
702-
Context3DTriangleFace::Back
703-
} else if &*triangle_face == b"front" {
704-
Context3DTriangleFace::Front
705-
} else if &*triangle_face == b"frontAndBack" {
706-
Context3DTriangleFace::FrontAndBack
707-
} else {
708-
tracing::error!("Unknown culling {:?}", triangle_face);
709-
Context3DTriangleFace::None
710-
};
694+
});
711695

712696
let compare_mode = args.get_string_non_null(activation, 1, "compareMode")?;
713697
let compare_mode = Context3DCompareMode::from_wstr(&compare_mode)
714698
.ok_or_else(|| make_error_2008(activation, "compareMode"))?;
715699

716-
let action_on_both_pass = args.get_string_non_null(activation, 2, "actionOnBothPass")?;
717-
let action_on_both_pass = Context3DStencilAction::from_wstr(&action_on_both_pass)
700+
let on_both_pass = args.get_string_non_null(activation, 2, "actionOnBothPass")?;
701+
let on_both_pass = Context3DStencilAction::from_wstr(&on_both_pass)
718702
.ok_or_else(|| make_error_2008(activation, "actionOnBothPass"))?;
719703

720-
let action_on_depth_fail = args.get_string_non_null(activation, 3, "actionOnDepthFail")?;
721-
let action_on_depth_fail = Context3DStencilAction::from_wstr(&action_on_depth_fail)
704+
let on_depth_fail = args.get_string_non_null(activation, 3, "actionOnDepthFail")?;
705+
let on_depth_fail = Context3DStencilAction::from_wstr(&on_depth_fail)
722706
.ok_or_else(|| make_error_2008(activation, "actionOnDepthFail"))?;
723707

724-
let action_on_depth_pass_stencil_fail =
708+
let on_depth_pass_stencil_fail =
725709
args.get_string_non_null(activation, 4, "actionOnDepthPassStencilFail")?;
726-
let action_on_depth_pass_stencil_fail =
727-
Context3DStencilAction::from_wstr(&action_on_depth_pass_stencil_fail)
710+
let on_depth_pass_stencil_fail =
711+
Context3DStencilAction::from_wstr(&on_depth_pass_stencil_fail)
728712
.ok_or_else(|| make_error_2008(activation, "actionOnDepthPassStencilFail"))?;
729713

730714
context.set_stencil_actions(
731-
culling,
715+
triangle_face,
732716
compare_mode,
733-
action_on_both_pass,
734-
action_on_depth_fail,
735-
action_on_depth_pass_stencil_fail,
717+
on_both_pass,
718+
on_depth_fail,
719+
on_depth_pass_stencil_fail,
736720
);
737721
}
738722

core/src/avm2/object/context3d_object.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,17 @@ impl<'gc> Context3DObject<'gc> {
481481
&self,
482482
triangle_face: Context3DTriangleFace,
483483
compare_mode: Context3DCompareMode,
484-
action_on_both_pass: Context3DStencilAction,
485-
action_on_depth_fail: Context3DStencilAction,
486-
action_on_depth_pass_stencil_fail: Context3DStencilAction,
484+
on_both_pass: Context3DStencilAction,
485+
on_depth_fail: Context3DStencilAction,
486+
on_depth_pass_stencil_fail: Context3DStencilAction,
487487
) {
488488
self.with_context_3d(|ctx| {
489489
ctx.process_command(Context3DCommand::SetStencilActions {
490490
triangle_face,
491491
compare_mode,
492-
action_on_both_pass,
493-
action_on_depth_fail,
494-
action_on_depth_pass_stencil_fail,
492+
on_both_pass,
493+
on_depth_fail,
494+
on_depth_pass_stencil_fail,
495495
})
496496
});
497497
}

render/src/backend.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,22 @@ pub enum Context3DTriangleFace {
296296
FrontAndBack,
297297
}
298298

299+
impl Context3DTriangleFace {
300+
pub fn from_wstr(s: &WStr) -> Option<Self> {
301+
if s == b"none" {
302+
Some(Context3DTriangleFace::None)
303+
} else if s == b"back" {
304+
Some(Context3DTriangleFace::Back)
305+
} else if s == b"Front" {
306+
Some(Context3DTriangleFace::Front)
307+
} else if s == b"frontAndBack" {
308+
Some(Context3DTriangleFace::FrontAndBack)
309+
} else {
310+
None
311+
}
312+
}
313+
}
314+
299315
#[derive(Copy, Clone, Debug)]
300316
pub enum Context3DProfile {
301317
Baseline,
@@ -588,9 +604,9 @@ pub enum Context3DCommand<'a> {
588604
SetStencilActions {
589605
triangle_face: Context3DTriangleFace,
590606
compare_mode: Context3DCompareMode,
591-
action_on_both_pass: Context3DStencilAction,
592-
action_on_depth_fail: Context3DStencilAction,
593-
action_on_depth_pass_stencil_fail: Context3DStencilAction,
607+
on_both_pass: Context3DStencilAction,
608+
on_depth_fail: Context3DStencilAction,
609+
on_depth_pass_stencil_fail: Context3DStencilAction,
594610
},
595611
SetStencilReferenceValue {
596612
reference_value: u32,

render/wgpu/src/context3d/current_pipeline.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,15 @@ impl CurrentPipeline {
592592
&mut self,
593593
triangle_face: Context3DTriangleFace,
594594
compare_mode: Context3DCompareMode,
595-
action_on_both_pass: Context3DStencilAction,
596-
action_on_depth_fail: Context3DStencilAction,
597-
action_on_depth_pass_stencil_fail: Context3DStencilAction,
595+
on_both_pass: Context3DStencilAction,
596+
on_depth_fail: Context3DStencilAction,
597+
on_depth_pass_stencil_fail: Context3DStencilAction,
598598
) {
599599
let stencil_state = wgpu::StencilFaceState {
600600
compare: compare_mode.into(),
601-
fail_op: action_on_depth_pass_stencil_fail.into(),
602-
depth_fail_op: action_on_depth_fail.into(),
603-
pass_op: action_on_both_pass.into(),
601+
fail_op: on_depth_pass_stencil_fail.into(),
602+
depth_fail_op: on_depth_fail.into(),
603+
pass_op: on_both_pass.into(),
604604
};
605605

606606
match triangle_face {

render/wgpu/src/context3d/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ruffle_render::backend::{
2-
Context3D, Context3DBlendFactor, Context3DCommand, Context3DCompareMode, Context3DProfile,
3-
Context3DTextureFormat, Context3DVertexBufferFormat, IndexBuffer, ProgramType, VertexBuffer,
2+
Context3D, Context3DBlendFactor, Context3DCommand, Context3DProfile, Context3DTextureFormat,
3+
Context3DVertexBufferFormat, IndexBuffer, ProgramType, VertexBuffer,
44
};
55
use ruffle_render::bitmap::BitmapHandle;
66
use ruffle_render::error::Error;
@@ -1194,16 +1194,16 @@ impl Context3D for WgpuContext3D {
11941194
Context3DCommand::SetStencilActions {
11951195
triangle_face,
11961196
compare_mode,
1197-
action_on_both_pass,
1198-
action_on_depth_fail,
1199-
action_on_depth_pass_stencil_fail,
1197+
on_both_pass,
1198+
on_depth_fail,
1199+
on_depth_pass_stencil_fail,
12001200
} => {
12011201
self.current_pipeline.update_stencil_actions(
12021202
triangle_face,
12031203
compare_mode,
1204-
action_on_both_pass,
1205-
action_on_depth_fail,
1206-
action_on_depth_pass_stencil_fail,
1204+
on_both_pass,
1205+
on_depth_fail,
1206+
on_depth_pass_stencil_fail,
12071207
);
12081208
}
12091209
Context3DCommand::SetStencilReferenceValue {

0 commit comments

Comments
 (0)