зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625220 - Remove a number of Foo::from_untyped(&bar.to_untyped()) casts. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D68470 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
70311638fb
Коммит
d5ee0ec037
|
@ -1171,7 +1171,7 @@ pub enum DrawTarget {
|
|||
|
||||
impl DrawTarget {
|
||||
pub fn new_default(size: DeviceIntSize, surface_origin_is_top_left: bool) -> Self {
|
||||
let total_size = FramebufferIntSize::from_untyped(size.to_untyped());
|
||||
let total_size = device_size_as_framebuffer_size(size);
|
||||
DrawTarget::Default {
|
||||
rect: total_size.into(),
|
||||
total_size,
|
||||
|
@ -1212,15 +1212,15 @@ impl DrawTarget {
|
|||
/// Returns the dimensions of this draw-target.
|
||||
pub fn dimensions(&self) -> DeviceIntSize {
|
||||
match *self {
|
||||
DrawTarget::Default { total_size, .. } => DeviceIntSize::from_untyped(total_size.to_untyped()),
|
||||
DrawTarget::Default { total_size, .. } => total_size.cast_unit(),
|
||||
DrawTarget::Texture { dimensions, .. } => dimensions,
|
||||
DrawTarget::External { size, .. } => DeviceIntSize::from_untyped(size.to_untyped()),
|
||||
DrawTarget::External { size, .. } => size.cast_unit(),
|
||||
DrawTarget::NativeSurface { dimensions, .. } => dimensions,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_framebuffer_rect(&self, device_rect: DeviceIntRect) -> FramebufferIntRect {
|
||||
let mut fb_rect = FramebufferIntRect::from_untyped(&device_rect.to_untyped());
|
||||
let mut fb_rect = device_rect_as_framebuffer_rect(&device_rect);
|
||||
match *self {
|
||||
DrawTarget::Default { ref rect, surface_origin_is_top_left, .. } => {
|
||||
// perform a Y-flip here
|
||||
|
@ -1255,16 +1255,16 @@ impl DrawTarget {
|
|||
.unwrap_or_else(FramebufferIntRect::zero)
|
||||
}
|
||||
DrawTarget::NativeSurface { offset, .. } => {
|
||||
FramebufferIntRect::from_untyped(&scissor_rect.translate(offset.to_vector()).to_untyped())
|
||||
device_rect_as_framebuffer_rect(&scissor_rect.translate(offset.to_vector()))
|
||||
}
|
||||
DrawTarget::Texture { .. } | DrawTarget::External { .. } => {
|
||||
FramebufferIntRect::from_untyped(&scissor_rect.to_untyped())
|
||||
device_rect_as_framebuffer_rect(&scissor_rect)
|
||||
}
|
||||
}
|
||||
None => {
|
||||
FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
FramebufferIntSize::from_untyped(dimensions.to_untyped()),
|
||||
device_size_as_framebuffer_size(dimensions),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1891,7 +1891,7 @@ impl Device {
|
|||
DrawTarget::Texture { dimensions, fbo_id, with_depth, .. } => {
|
||||
let rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
FramebufferIntSize::from_untyped(dimensions.to_untyped()),
|
||||
device_size_as_framebuffer_size(dimensions),
|
||||
);
|
||||
(fbo_id, rect, with_depth)
|
||||
},
|
||||
|
@ -1901,10 +1901,7 @@ impl Device {
|
|||
DrawTarget::NativeSurface { external_fbo_id, offset, dimensions, .. } => {
|
||||
(
|
||||
FBOId(external_fbo_id),
|
||||
FramebufferIntRect::new(
|
||||
FramebufferIntPoint::from_untyped(offset.to_untyped()),
|
||||
FramebufferIntSize::from_untyped(dimensions.to_untyped()),
|
||||
),
|
||||
device_rect_as_framebuffer_rect(&DeviceIntRect::new(offset, dimensions)),
|
||||
true
|
||||
)
|
||||
}
|
||||
|
@ -2332,7 +2329,7 @@ impl Device {
|
|||
} else {
|
||||
let rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
FramebufferIntSize::from_untyped(src.get_dimensions().to_untyped()),
|
||||
device_size_as_framebuffer_size(src.get_dimensions()),
|
||||
);
|
||||
for layer in 0..src.layer_count.min(dst.layer_count) as LayerIndex {
|
||||
self.blit_render_target(
|
||||
|
|
|
@ -2395,11 +2395,11 @@ impl TileCacheInstance {
|
|||
|
||||
self.map_local_to_surface = SpaceMapper::new(
|
||||
self.spatial_node_index,
|
||||
PictureRect::from_untyped(&pic_rect.to_untyped()),
|
||||
pic_rect,
|
||||
);
|
||||
self.map_child_pic_to_surface = SpaceMapper::new(
|
||||
self.spatial_node_index,
|
||||
PictureRect::from_untyped(&pic_rect.to_untyped()),
|
||||
pic_rect,
|
||||
);
|
||||
|
||||
let pic_to_world_mapper = SpaceMapper::new_with_target(
|
||||
|
@ -2430,7 +2430,7 @@ impl TileCacheInstance {
|
|||
);
|
||||
|
||||
let clip_chain_instance = frame_state.clip_store.build_clip_chain_instance(
|
||||
LayoutRect::from_untyped(&pic_rect.to_untyped()),
|
||||
pic_rect.cast_unit(),
|
||||
&self.map_local_to_surface,
|
||||
&pic_to_world_mapper,
|
||||
frame_context.spatial_tree,
|
||||
|
@ -4562,7 +4562,7 @@ impl PicturePrimitive {
|
|||
|
||||
match self.raster_config {
|
||||
Some(ref mut raster_config) => {
|
||||
let pic_rect = PictureRect::from_untyped(&self.precise_local_rect.to_untyped());
|
||||
let pic_rect = self.precise_local_rect.cast_unit();
|
||||
|
||||
let mut device_pixel_scale = frame_state
|
||||
.surfaces[raster_config.surface_index.0]
|
||||
|
@ -4579,7 +4579,7 @@ impl PicturePrimitive {
|
|||
let mut max_offset = vec2(0.0, 0.0);
|
||||
let mut min_offset = vec2(0.0, 0.0);
|
||||
for shadow in shadows {
|
||||
let offset = shadow.offset.cast_unit();
|
||||
let offset = layout_vector_as_picture_vector(shadow.offset);
|
||||
max_offset = max_offset.max(offset);
|
||||
min_offset = min_offset.min(offset);
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ impl<F, T> SpaceMapper<F, T> where F: fmt::Debug {
|
|||
pub fn unmap(&self, rect: &Rect<f32, T>) -> Option<Rect<f32, F>> {
|
||||
match self.kind {
|
||||
CoordinateSpaceMapping::Local => {
|
||||
Some(Rect::from_untyped(&rect.to_untyped()))
|
||||
Some(rect.cast_unit())
|
||||
}
|
||||
CoordinateSpaceMapping::ScaleOffset(ref scale_offset) => {
|
||||
Some(scale_offset.unmap_rect(rect))
|
||||
|
@ -326,7 +326,7 @@ impl<F, T> SpaceMapper<F, T> where F: fmt::Debug {
|
|||
pub fn map(&self, rect: &Rect<f32, F>) -> Option<Rect<f32, T>> {
|
||||
match self.kind {
|
||||
CoordinateSpaceMapping::Local => {
|
||||
Some(Rect::from_untyped(&rect.to_untyped()))
|
||||
Some(rect.cast_unit())
|
||||
}
|
||||
CoordinateSpaceMapping::ScaleOffset(ref scale_offset) => {
|
||||
Some(scale_offset.map_rect(rect))
|
||||
|
@ -1962,7 +1962,7 @@ impl PrimitiveStore {
|
|||
// relative transforms have changed, which means we need to
|
||||
// re-map the dependencies of any child primitives.
|
||||
world_culling_rect = tile_cache.pre_update(
|
||||
PictureRect::from_untyped(&pic.estimated_local_rect.to_untyped()),
|
||||
layout_rect_as_picture_rect(&pic.estimated_local_rect),
|
||||
surface_index,
|
||||
frame_context,
|
||||
frame_state,
|
||||
|
@ -4230,7 +4230,8 @@ fn get_clipped_device_rect(
|
|||
let unclipped_raster_rect = {
|
||||
let world_rect = *unclipped * Scale::new(1.0);
|
||||
let raster_rect = world_rect * device_pixel_scale.inv();
|
||||
Rect::from_untyped(&raster_rect.to_untyped())
|
||||
|
||||
raster_rect.cast_unit()
|
||||
};
|
||||
|
||||
let unclipped_world_rect = map_to_world.map(&unclipped_raster_rect)?;
|
||||
|
|
|
@ -6054,7 +6054,7 @@ impl Renderer {
|
|||
|
||||
let texture_rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
FramebufferIntSize::from_untyped(source_rect.size.to_untyped()),
|
||||
source_rect.size.cast_unit(),
|
||||
);
|
||||
|
||||
debug_renderer.add_rect(
|
||||
|
@ -6193,7 +6193,7 @@ impl Renderer {
|
|||
device.clear_target(
|
||||
Some(tag_color),
|
||||
None,
|
||||
Some(FramebufferIntRect::from_untyped(&tag_rect.to_untyped())),
|
||||
Some(tag_rect.cast_unit()),
|
||||
);
|
||||
|
||||
// Draw the dimensions onto the tag.
|
||||
|
@ -6321,7 +6321,7 @@ impl Renderer {
|
|||
|
||||
pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>) {
|
||||
let texture = self.gpu_cache_texture.texture.as_ref().unwrap();
|
||||
let size = FramebufferIntSize::from_untyped(texture.get_dimensions().to_untyped());
|
||||
let size = device_size_as_framebuffer_size(texture.get_dimensions());
|
||||
let mut texels = vec![0; (size.width * size.height * 16) as usize];
|
||||
self.device.begin_frame();
|
||||
self.device.bind_read_target(ReadTarget::from_texture(texture, 0));
|
||||
|
@ -6858,7 +6858,7 @@ impl Renderer {
|
|||
// read from textures directly with `get_tex_image*`.
|
||||
|
||||
for layer_id in 0 .. texture.get_layer_count() {
|
||||
let rect = FramebufferIntSize::from_untyped(rect_size.to_untyped()).into();
|
||||
let rect = device_size_as_framebuffer_size(rect_size).into();
|
||||
|
||||
device.attach_read_texture(texture, layer_id);
|
||||
#[cfg(feature = "png")]
|
||||
|
|
|
@ -290,7 +290,7 @@ impl AsyncScreenshotGrabber {
|
|||
let draw_target_rect = draw_target
|
||||
.to_framebuffer_rect(DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size));
|
||||
|
||||
let read_target_rect = FramebufferIntRect::from_untyped(&read_target_rect.to_untyped());
|
||||
let read_target_rect = device_rect_as_framebuffer_rect(&read_target_rect);
|
||||
|
||||
if level == 0 && !device.surface_origin_is_top_left() {
|
||||
device.blit_render_target_invert_y(
|
||||
|
|
|
@ -299,3 +299,25 @@ impl<U> RectExt for Rect<f32, U> {
|
|||
self.max()
|
||||
}
|
||||
}
|
||||
|
||||
// A few helpers to convert to cast between coordinate spaces that are often equivalent.
|
||||
|
||||
#[inline]
|
||||
pub fn layout_rect_as_picture_rect(layout_rect: &LayoutRect) -> PictureRect {
|
||||
layout_rect.cast_unit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn layout_vector_as_picture_vector(layout_vector: LayoutVector2D) -> PictureVector2D {
|
||||
layout_vector.cast_unit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn device_size_as_framebuffer_size(framebuffer_size: DeviceIntSize) -> FramebufferIntSize {
|
||||
framebuffer_size.cast_unit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn device_rect_as_framebuffer_rect(framebuffer_rect: &DeviceIntRect) -> FramebufferIntRect {
|
||||
framebuffer_rect.cast_unit()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче