Bug 1544374 - Make FilterOp not copy. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D27480

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Silva 2019-04-16 07:43:04 +00:00
Родитель 80259dac21
Коммит bd2c8b86cd
6 изменённых файлов: 26 добавлений и 19 удалений

Просмотреть файл

@ -2064,9 +2064,9 @@ pub extern "C" fn wr_dp_push_stacking_context(
debug_assert!(unsafe { !is_in_render_thread() });
let c_filters = unsafe { make_slice(filters, filter_count) };
let mut filters : Vec<FilterOp> = c_filters.iter().map(|c_filter| {
*c_filter
}).collect();
let mut filters : Vec<FilterOp> = c_filters.iter()
.map(|c_filter| { c_filter.clone() })
.collect();
let c_filter_datas = unsafe { make_slice(filter_datas, filter_datas_count) };
let r_filter_datas : Vec<FilterData> = c_filter_datas.iter().map(|c_filter_data| {

Просмотреть файл

@ -1255,7 +1255,7 @@ impl AlphaBatchBuilder {
}
}
}
PictureCompositeMode::Filter(filter) => {
PictureCompositeMode::Filter(ref filter) => {
let surface = ctx.surfaces[raster_config.surface_index.0]
.surface
.as_ref()

Просмотреть файл

@ -1501,7 +1501,7 @@ impl<'a> DisplayListFlattener<'a> {
let leaf_pic_index = PictureIndex(self.prim_store.pictures
.alloc()
.init(PicturePrimitive::new_image(
leaf_composite_mode,
leaf_composite_mode.clone(),
leaf_context_3d,
stacking_context.pipeline_id,
leaf_output_pipeline_id,
@ -1609,13 +1609,13 @@ impl<'a> DisplayListFlattener<'a> {
PictureCompositeMode::ComponentTransferFilter(handle)
}
}
_ => PictureCompositeMode::Filter(filter),
_ => PictureCompositeMode::Filter(filter.clone()),
});
let filter_pic_index = PictureIndex(self.prim_store.pictures
.alloc()
.init(PicturePrimitive::new_image(
composite_mode,
composite_mode.clone(),
Picture3DContext::Out,
stacking_context.pipeline_id,
None,
@ -1669,7 +1669,7 @@ impl<'a> DisplayListFlattener<'a> {
let blend_pic_index = PictureIndex(self.prim_store.pictures
.alloc()
.init(PicturePrimitive::new_image(
composite_mode,
composite_mode.clone(),
Picture3DContext::Out,
stacking_context.pipeline_id,
None,
@ -2026,7 +2026,7 @@ impl<'a> DisplayListFlattener<'a> {
// parent picture, which avoids an intermediate surface and blur.
let blur_filter = FilterOp::Blur(std_deviation).sanitize();
let composite_mode = PictureCompositeMode::Filter(blur_filter);
let composite_mode_key = Some(composite_mode).into();
let composite_mode_key = Some(composite_mode.clone()).into();
// Pass through configuration information about whether WR should
// do the bounding rect inflation for text shadows.

Просмотреть файл

@ -1877,7 +1877,7 @@ bitflags! {
/// Specifies how this Picture should be composited
/// onto the target it belongs to.
#[allow(dead_code)]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "capture", derive(Serialize))]
pub enum PictureCompositeMode {
/// Apply CSS mix-blend-mode effect.
@ -2624,7 +2624,7 @@ impl PicturePrimitive {
// See if this picture actually needs a surface for compositing.
let actual_composite_mode = match self.requested_composite_mode {
Some(PictureCompositeMode::Filter(filter)) if filter.is_noop() => None,
Some(PictureCompositeMode::Filter(ref filter)) if filter.is_noop() => None,
Some(PictureCompositeMode::Blit(reason)) if reason == BlitReason::CLIP => {
// If the only reason a picture has requested a surface is due to the clip
// chain node, we might choose to skip drawing a surface, and instead apply
@ -2671,7 +2671,7 @@ impl PicturePrimitive {
None
}
}
mode => mode,
ref mode => mode.clone(),
};
if let Some(composite_mode) = actual_composite_mode {
@ -3120,8 +3120,8 @@ impl PicturePrimitive {
frame_state.surfaces[surface_index.0].tasks.push(render_task_id);
PictureSurface::RenderTask(render_task_id)
}
PictureCompositeMode::Filter(filter) => {
if let FilterOp::ColorMatrix(m) = filter {
PictureCompositeMode::Filter(ref filter) => {
if let FilterOp::ColorMatrix(m) = *filter {
if let Some(mut request) = frame_state.gpu_cache.request(&mut self.extra_gpu_data_handle) {
for i in 0..5 {
request.push([m[i*4], m[i*4+1], m[i*4+2], m[i*4+3]]);

Просмотреть файл

@ -626,7 +626,7 @@ pub enum MixBlendMode {
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub enum FilterOp {
/// Filter that does no transformation of the colors, needed for
/// debug purposes only.
@ -650,7 +650,7 @@ pub enum FilterOp {
impl FilterOp {
/// Ensure that the parameters for a filter operation
/// are sensible.
pub fn sanitize(self) -> FilterOp {
pub fn sanitize(&self) -> FilterOp {
match self {
FilterOp::Blur(radius) => {
let radius = radius.min(MAX_BLUR_RADIUS);
@ -658,9 +658,9 @@ impl FilterOp {
}
FilterOp::DropShadow(offset, radius, color) => {
let radius = radius.min(MAX_BLUR_RADIUS);
FilterOp::DropShadow(offset, radius, color)
FilterOp::DropShadow(*offset, radius, *color)
}
filter => filter,
filter => filter.clone(),
}
}
}

Просмотреть файл

@ -37,13 +37,20 @@ const FIRST_SPATIAL_NODE_INDEX: usize = 2;
const FIRST_CLIP_NODE_INDEX: usize = 1;
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ItemRange<T> {
start: usize,
length: usize,
_boo: PhantomData<T>,
}
impl<T> Copy for ItemRange<T> {}
impl<T> Clone for ItemRange<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Default for ItemRange<T> {
fn default() -> Self {
ItemRange {