core: Don't invalidate when setting filters to the same value
This commit is contained in:
parent
eb72cfb498
commit
f03b6307a8
|
@ -36,6 +36,14 @@ impl ShaderObject for ObjectWrapper {
|
|||
fn clone_box(&self) -> Box<dyn ShaderObject> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn equals(&self, other: &dyn ShaderObject) -> bool {
|
||||
if let Some(other_wrapper) = other.downcast_ref::<ObjectWrapper>() {
|
||||
self.root.as_ptr() == other_wrapper.root.as_ptr()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for ObjectWrapper {
|
||||
|
|
|
@ -505,9 +505,14 @@ impl<'gc> DisplayObjectBase<'gc> {
|
|||
self.filters.clone()
|
||||
}
|
||||
|
||||
fn set_filters(&mut self, filters: Vec<Filter>) {
|
||||
fn set_filters(&mut self, filters: Vec<Filter>) -> bool {
|
||||
if filters != self.filters {
|
||||
self.filters = filters;
|
||||
self.recheck_cache_as_bitmap();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn alpha(&self) -> f64 {
|
||||
|
@ -1477,9 +1482,10 @@ pub trait TDisplayObject<'gc>:
|
|||
}
|
||||
|
||||
fn set_filters(&self, gc_context: &Mutation<'gc>, filters: Vec<Filter>) {
|
||||
self.base_mut(gc_context).set_filters(filters);
|
||||
if self.base_mut(gc_context).set_filters(filters) {
|
||||
self.invalidate_cached_bitmap(gc_context);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the dot-syntax path to this display object, e.g. `_level0.foo.clip`
|
||||
fn path(&self) -> WString {
|
||||
|
|
|
@ -123,11 +123,21 @@ pub trait Texture: Downcast + Debug {
|
|||
}
|
||||
impl_downcast!(Texture);
|
||||
|
||||
pub trait RawTexture: Downcast + Debug {}
|
||||
pub trait RawTexture: Downcast + Debug {
|
||||
fn equals(&self, other: &dyn RawTexture) -> bool;
|
||||
}
|
||||
impl_downcast!(RawTexture);
|
||||
|
||||
#[cfg(feature = "wgpu")]
|
||||
impl RawTexture for wgpu::Texture {}
|
||||
impl RawTexture for wgpu::Texture {
|
||||
fn equals(&self, other: &dyn RawTexture) -> bool {
|
||||
if let Some(other_texture) = other.downcast_ref::<wgpu::Texture>() {
|
||||
std::ptr::eq(self, other_texture)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Context3DTextureFormat {
|
||||
|
|
|
@ -12,6 +12,12 @@ use crate::matrix::Matrix;
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct BitmapHandle(pub Arc<dyn BitmapHandleImpl>);
|
||||
|
||||
impl PartialEq for BitmapHandle {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BitmapHandleImpl: Downcast + Debug {}
|
||||
impl_downcast!(BitmapHandleImpl);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use downcast_rs::{impl_downcast, Downcast};
|
|||
use std::fmt::Debug;
|
||||
use swf::{Color, Rectangle, Twips};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Filter {
|
||||
BevelFilter(swf::BevelFilter),
|
||||
BlurFilter(swf::BlurFilter),
|
||||
|
@ -35,8 +35,22 @@ pub struct ShaderFilter<'a> {
|
|||
pub shader_args: Vec<PixelBenderShaderArgument<'a>>,
|
||||
}
|
||||
|
||||
impl<'gc> PartialEq for ShaderFilter<'gc> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.bottom_extension == other.bottom_extension
|
||||
&& self.left_extension == other.left_extension
|
||||
&& self.right_extension == other.right_extension
|
||||
&& self.top_extension == other.top_extension
|
||||
&& self.shader_object.equals(other.shader_object.as_ref())
|
||||
&& self.shader == other.shader
|
||||
&& self.shader_args == other.shader_args
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ShaderObject: Downcast + Debug {
|
||||
fn clone_box(&self) -> Box<dyn ShaderObject>;
|
||||
|
||||
fn equals(&self, other: &dyn ShaderObject) -> bool;
|
||||
}
|
||||
impl_downcast!(ShaderObject);
|
||||
|
||||
|
@ -132,7 +146,7 @@ pub enum DisplacementMapFilterMode {
|
|||
Wrap,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DisplacementMapFilter {
|
||||
pub color: Color,
|
||||
pub component_x: u8,
|
||||
|
|
|
@ -22,6 +22,12 @@ pub const OUT_COORD_NAME: &str = "_OutCoord";
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct PixelBenderShaderHandle(pub Arc<dyn PixelBenderShaderImpl>);
|
||||
|
||||
impl PartialEq for PixelBenderShaderHandle {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PixelBenderShaderImpl: Downcast + Debug {
|
||||
fn parsed_shader(&self) -> &PixelBenderShader;
|
||||
}
|
||||
|
@ -249,7 +255,7 @@ pub enum Operation {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PixelBenderShaderArgument<'a> {
|
||||
ImageInput {
|
||||
index: u8,
|
||||
|
@ -273,6 +279,18 @@ pub enum ImageInputTexture<'a> {
|
|||
TextureRef(&'a dyn RawTexture),
|
||||
}
|
||||
|
||||
impl PartialEq for ImageInputTexture<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Self::Bitmap(self_bitmap), Self::Bitmap(other_bitmap)) => self_bitmap == other_bitmap,
|
||||
(Self::TextureRef(self_texture), Self::TextureRef(other_texture)) => {
|
||||
self_texture.equals(*other_texture)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BitmapHandle> for ImageInputTexture<'_> {
|
||||
fn from(b: BitmapHandle) -> Self {
|
||||
ImageInputTexture::Bitmap(b)
|
||||
|
|
Loading…
Reference in New Issue