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

Fix stroke widths and hairline strokes in wgpu and webgl #9981

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
render: Removed now-unused BitmapSource from RenderBackend shape methods
  • Loading branch information
Dinnerbone committed Mar 13, 2023
commit 2bb619a878dcff0d94a3a6f85964fe00dc2b6bf1
2 changes: 1 addition & 1 deletion core/src/display_object/graphic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'gc> Graphic<'gc> {
let static_data = GraphicStatic {
id: swf_shape.id,
bounds: swf_shape.shape_bounds.clone(),
render_handle: Some(context.renderer.register_shape(shape, &bitmap_source)),
render_handle: Some(context.renderer.register_shape(shape)),
shape: swf_shape,
movie,
};
Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/morph_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl MorphShapeStatic {
gc_context: context.gc_context,
};
let shape = DistilledShape::from_shape(&frame.shape, &bitmap_source, context.renderer);
let handle = context.renderer.register_shape(shape, &bitmap_source);
let handle = context.renderer.register_shape(shape);
frame.shape_handle = Some(handle);
handle
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ impl Drawing {
id: 0,
};
if let Some(handle) = self.render_handle.get() {
context.renderer.replace_shape(shape, self, handle);
context.renderer.replace_shape(shape, handle);
} else {
self.render_handle
.set(Some(context.renderer.register_shape(shape, self)));
.set(Some(context.renderer.register_shape(shape)));
}
}

Expand Down
34 changes: 10 additions & 24 deletions render/canvas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use ruffle_render::backend::null::NullBitmapSource;
use ruffle_render::backend::{
Context3D, Context3DCommand, RenderBackend, ShapeHandle, ViewportDimensions,
};
use ruffle_render::bitmap::{
Bitmap, BitmapFormat, BitmapHandle, BitmapHandleImpl, BitmapSource, SyncHandle,
};
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapHandleImpl, SyncHandle};
use ruffle_render::color_transform::ColorTransform;
use ruffle_render::commands::{CommandHandler, CommandList};
use ruffle_render::error::Error;
Expand Down Expand Up @@ -436,23 +434,14 @@ impl RenderBackend for WebCanvasRenderBackend {
}
}

fn register_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
) -> ShapeHandle {
fn register_shape(&mut self, shape: DistilledShape) -> ShapeHandle {
let handle = ShapeHandle(self.shapes.len());
let data = swf_shape_to_canvas_commands(shape, self);
self.shapes.push(data);
handle
}

fn replace_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
handle: ShapeHandle,
) {
fn replace_shape(&mut self, shape: DistilledShape, handle: ShapeHandle) {
let data = swf_shape_to_canvas_commands(shape, self);
self.shapes[handle.0] = data;
}
Expand All @@ -462,16 +451,13 @@ impl RenderBackend for WebCanvasRenderBackend {
let (fills, strokes) =
ShapeConverter::from_shape(&shape, &NullBitmapSource, self).into_commands();

self.register_shape(
DistilledShape {
fills,
strokes,
shape_bounds: shape.shape_bounds.clone(),
edge_bounds: shape.edge_bounds.clone(),
id: shape.id,
},
&NullBitmapSource,
)
self.register_shape(DistilledShape {
fills,
strokes,
shape_bounds: shape.shape_bounds.clone(),
edge_bounds: shape.edge_bounds.clone(),
id: shape.id,
})
}

fn render_offscreen(
Expand Down
15 changes: 3 additions & 12 deletions render/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod null;

use crate::bitmap::{Bitmap, BitmapHandle, BitmapSource, SyncHandle};
use crate::bitmap::{Bitmap, BitmapHandle, SyncHandle};
use crate::commands::CommandList;
use crate::error::Error;
use crate::filters::Filter;
Expand All @@ -19,17 +19,8 @@ pub trait RenderBackend: Downcast {
// Do not call this method directly - use `player.set_viewport_dimensions`,
// which will ensure that the stage is properly updated as well.
fn set_viewport_dimensions(&mut self, dimensions: ViewportDimensions);
fn register_shape(
&mut self,
shape: DistilledShape,
bitmap_source: &dyn BitmapSource,
) -> ShapeHandle;
fn replace_shape(
&mut self,
shape: DistilledShape,
bitmap_source: &dyn BitmapSource,
handle: ShapeHandle,
);
fn register_shape(&mut self, shape: DistilledShape) -> ShapeHandle;
fn replace_shape(&mut self, shape: DistilledShape, handle: ShapeHandle);
fn register_glyph_shape(&mut self, shape: &swf::Glyph) -> ShapeHandle;

/// Creates a new `RenderBackend` which renders directly
Expand Down
14 changes: 2 additions & 12 deletions render/src/backend/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,10 @@ impl RenderBackend for NullRenderer {
fn set_viewport_dimensions(&mut self, dimensions: ViewportDimensions) {
self.dimensions = dimensions;
}
fn register_shape(
&mut self,
_shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
) -> ShapeHandle {
fn register_shape(&mut self, _shape: DistilledShape) -> ShapeHandle {
ShapeHandle(0)
}
fn replace_shape(
&mut self,
_shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
_handle: ShapeHandle,
) {
}
fn replace_shape(&mut self, _shape: DistilledShape, _handle: ShapeHandle) {}
fn register_glyph_shape(&mut self, _shape: &swf::Glyph) -> ShapeHandle {
ShapeHandle(0)
}
Expand Down
17 changes: 3 additions & 14 deletions render/webgl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use ruffle_render::backend::null::NullBitmapSource;
use ruffle_render::backend::{
Context3D, Context3DCommand, RenderBackend, ShapeHandle, ViewportDimensions,
};
use ruffle_render::bitmap::{
Bitmap, BitmapFormat, BitmapHandle, BitmapHandleImpl, BitmapSource, SyncHandle,
};
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapHandleImpl, SyncHandle};
use ruffle_render::commands::{CommandHandler, CommandList};
use ruffle_render::error::Error as BitmapError;
use ruffle_render::quality::StageQuality;
Expand Down Expand Up @@ -981,11 +979,7 @@ impl RenderBackend for WebGlRenderBackend {
self.viewport_scale_factor = dimensions.scale_factor
}

fn register_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
) -> ShapeHandle {
fn register_shape(&mut self, shape: DistilledShape) -> ShapeHandle {
let handle = ShapeHandle(self.meshes.len());
match self.register_shape_internal(shape) {
Ok(mesh) => self.meshes.push(mesh),
Expand All @@ -994,12 +988,7 @@ impl RenderBackend for WebGlRenderBackend {
handle
}

fn replace_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
handle: ShapeHandle,
) {
fn replace_shape(&mut self, shape: DistilledShape, handle: ShapeHandle) {
self.delete_mesh(&self.meshes[handle.0]);
match self.register_shape_internal(shape) {
Ok(mesh) => self.meshes[handle.0] = mesh,
Expand Down
15 changes: 3 additions & 12 deletions render/wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use gc_arena::MutationContext;
use ruffle_render::backend::null::NullBitmapSource;
use ruffle_render::backend::{Context3D, Context3DCommand};
use ruffle_render::backend::{RenderBackend, ShapeHandle, ViewportDimensions};
use ruffle_render::bitmap::{Bitmap, BitmapHandle, BitmapSource, SyncHandle};
use ruffle_render::bitmap::{Bitmap, BitmapHandle, SyncHandle};
use ruffle_render::commands::CommandList;
use ruffle_render::error::Error as BitmapError;
use ruffle_render::filters::Filter;
Expand Down Expand Up @@ -373,24 +373,15 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
}

#[instrument(level = "debug", skip_all)]
fn register_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
) -> ShapeHandle {
fn register_shape(&mut self, shape: DistilledShape) -> ShapeHandle {
let handle = ShapeHandle(self.meshes.len());
let meshes = self.register_shape_internal(shape);
self.meshes.push(meshes);
handle
}

#[instrument(level = "debug", skip_all)]
fn replace_shape(
&mut self,
shape: DistilledShape,
_bitmap_source: &dyn BitmapSource,
handle: ShapeHandle,
) {
fn replace_shape(&mut self, shape: DistilledShape, handle: ShapeHandle) {
let mesh = self.register_shape_internal(shape);
self.meshes[handle.0] = mesh;
}
Expand Down