Skip to content

Commit eb44cc5

Browse files
DinnerboneHerschel
authored andcommitted
render: Made ShapeHandle an Arc of an internal, droppable mesh
1 parent cc8ac4f commit eb44cc5

File tree

12 files changed

+309
-275
lines changed

12 files changed

+309
-275
lines changed

core/src/display_object/graphic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
190190

191191
if let Some(drawing) = &self.0.read().drawing {
192192
drawing.render(context);
193-
} else if let Some(render_handle) = self.0.read().static_data.render_handle {
193+
} else if let Some(render_handle) = self.0.read().static_data.render_handle.clone() {
194194
context
195195
.commands
196196
.render_shape(render_handle, context.transform_stack.transform())

core/src/display_object/morph_shape.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl MorphShapeStatic {
194194
ratio: u16,
195195
) -> ShapeHandle {
196196
let mut frame = self.get_frame(ratio);
197-
if let Some(handle) = frame.shape_handle {
197+
if let Some(handle) = frame.shape_handle.clone() {
198198
handle
199199
} else {
200200
let library = library.library_for_movie(self.movie.clone()).unwrap();
@@ -205,7 +205,7 @@ impl MorphShapeStatic {
205205
gc_context: context.gc_context,
206206
},
207207
);
208-
frame.shape_handle = Some(handle);
208+
frame.shape_handle = Some(handle.clone());
209209
handle
210210
}
211211
}

core/src/drawing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use ruffle_render::backend::{RenderBackend, ShapeHandle};
44
use ruffle_render::bitmap::{BitmapHandle, BitmapInfo, BitmapSize, BitmapSource};
55
use ruffle_render::commands::CommandHandler;
66
use ruffle_render::shape_utils::{DistilledShape, DrawCommand, DrawPath, FillRule};
7-
use std::cell::Cell;
7+
use std::cell::{Cell, RefCell};
88
use swf::{FillStyle, LineStyle, Rectangle, Twips};
99

1010
#[derive(Clone, Debug, Collect)]
1111
#[collect(require_static)]
1212
pub struct Drawing {
13-
render_handle: Cell<Option<ShapeHandle>>,
13+
render_handle: RefCell<Option<ShapeHandle>>,
1414
shape_bounds: Rectangle<Twips>,
1515
edge_bounds: Rectangle<Twips>,
1616
dirty: Cell<bool>,
@@ -33,7 +33,7 @@ impl Default for Drawing {
3333
impl Drawing {
3434
pub fn new() -> Self {
3535
Self {
36-
render_handle: Cell::new(None),
36+
render_handle: RefCell::new(None),
3737
shape_bounds: Default::default(),
3838
edge_bounds: Default::default(),
3939
dirty: Cell::new(false),
@@ -50,7 +50,7 @@ impl Drawing {
5050

5151
pub fn from_swf_shape(shape: &swf::Shape) -> Self {
5252
let mut this = Self {
53-
render_handle: Cell::new(None),
53+
render_handle: RefCell::new(None),
5454
shape_bounds: shape.shape_bounds.clone(),
5555
edge_bounds: shape.edge_bounds.clone(),
5656
dirty: Cell::new(true),
@@ -305,10 +305,10 @@ impl Drawing {
305305
id: 0,
306306
};
307307
self.render_handle
308-
.set(Some(context.renderer.register_shape(shape, self)));
308+
.replace(Some(context.renderer.register_shape(shape, self)));
309309
}
310310

311-
if let Some(handle) = self.render_handle.get() {
311+
if let Some(handle) = self.render_handle.borrow().to_owned() {
312312
context
313313
.commands
314314
.render_shape(handle, context.transform_stack.transform());

core/src/font.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::string::WStr;
44
use gc_arena::{Collect, Gc, MutationContext};
55
use ruffle_render::backend::{RenderBackend, ShapeHandle};
66
use ruffle_render::transform::Transform;
7-
use std::cell::{Cell, Ref, RefCell};
7+
use std::cell::{Ref, RefCell};
88
use std::cmp::max;
99

1010
pub use swf::TextGridFit;
@@ -126,7 +126,7 @@ impl<'gc> Font<'gc> {
126126
};
127127
let glyph_code = swf_glyph.code;
128128
let glyph = Glyph {
129-
shape_handle: Cell::new(handle),
129+
shape_handle: RefCell::new(handle),
130130
advance: swf_glyph.advance,
131131
shape: RefCell::new(None),
132132
swf_glyph,
@@ -419,7 +419,7 @@ pub struct Glyph {
419419
pub advance: i16,
420420
// Handle to registered shape.
421421
// If None, it'll be loaded lazily on first render of this glyph.
422-
shape_handle: Cell<Option<ShapeHandle>>,
422+
shape_handle: RefCell<Option<ShapeHandle>>,
423423
// Same shape as one in swf_glyph, but wrapped in an swf::Shape;
424424
// For use in hit tests. Created lazily on first use.
425425
// (todo: refactor hit tests to not require this?
@@ -431,11 +431,11 @@ pub struct Glyph {
431431

432432
impl Glyph {
433433
pub fn shape_handle(&self, renderer: &mut dyn RenderBackend) -> ShapeHandle {
434-
if self.shape_handle.get().is_none() {
434+
if self.shape_handle.borrow().is_none() {
435435
self.shape_handle
436-
.set(Some(renderer.register_glyph_shape(&self.swf_glyph)))
436+
.replace(Some(renderer.register_glyph_shape(&self.swf_glyph)));
437437
}
438-
self.shape_handle.get().unwrap()
438+
self.shape_handle.borrow().clone().unwrap()
439439
}
440440

441441
pub fn as_shape(&self) -> Ref<'_, swf::Shape> {

0 commit comments

Comments
 (0)