Bug 1593903 - Change RenderCompositor::SurfaceIsYFlipped() to SurfaceOriginIsTopLeft() r=gw

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2019-11-05 11:02:40 +00:00
Родитель c2512e1c97
Коммит 85db2de6eb
8 изменённых файлов: 31 добавлений и 31 удалений

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

@ -95,8 +95,8 @@ class RenderCompositor {
virtual bool RequestFullRender() { return false; }
virtual uint32_t GetMaxPartialPresentRects() { return 0; }
// Whether the surface contents are flipped vertically
virtual bool SurfaceIsYFlipped() { return false; }
// Whether the surface origin is top-left.
virtual bool SurfaceOriginIsTopLeft() { return false; }
protected:
// We default this to 2, so that mLatestRenderFrameId.Prev() is always valid.

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

@ -61,7 +61,7 @@ class RenderCompositorANGLE : public RenderCompositor {
bool IsContextLost() override;
bool SurfaceIsYFlipped() override { return true; }
bool SurfaceOriginIsTopLeft() override { return true; }
bool ShouldUseNativeCompositor() override;

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

@ -85,7 +85,7 @@ class NewRenderer : public RendererEvent {
#else
false,
#endif
compositor->gl(), compositor->SurfaceIsYFlipped(),
compositor->gl(), compositor->SurfaceOriginIsTopLeft(),
aRenderThread.GetProgramCache()
? aRenderThread.GetProgramCache()->Raw()
: nullptr,

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

@ -1295,7 +1295,7 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
enable_picture_caching: bool,
start_debug_server: bool,
gl_context: *mut c_void,
surface_is_y_flipped: bool,
surface_origin_is_top_left: bool,
program_cache: Option<&mut WrProgramCache>,
shaders: Option<&mut WrShaders>,
thread_pool: *mut WrThreadPool,
@ -1401,7 +1401,7 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
enable_picture_caching,
allow_pixel_local_storage_support: false,
start_debug_server,
surface_is_y_flipped,
surface_origin_is_top_left,
compositor_config,
..Default::default()
};

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

@ -321,8 +321,8 @@ impl DebugRenderer {
device.set_blend(true);
device.set_blend_mode_premultiplied_alpha();
let surface_is_y_flipped = device.surface_is_y_flipped();
let (bottom, top) = if surface_is_y_flipped {
let surface_origin_is_top_left = device.surface_origin_is_top_left();
let (bottom, top) = if surface_origin_is_top_left {
(0.0, viewport_size.height as f32 * scale)
} else {
(viewport_size.height as f32 * scale, 0.0)

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

@ -1046,7 +1046,7 @@ pub struct Device {
/// Dumps the source of the shader with the given name
dump_shader_source: Option<String>,
surface_is_y_flipped: bool,
surface_origin_is_top_left: bool,
}
/// Contains the parameters necessary to bind a draw target.
@ -1059,7 +1059,7 @@ pub enum DrawTarget {
rect: FramebufferIntRect,
/// Total size of the target.
total_size: FramebufferIntSize,
surface_is_y_flipped: bool,
surface_origin_is_top_left: bool,
},
/// Use the provided texture.
Texture {
@ -1092,12 +1092,12 @@ pub enum DrawTarget {
}
impl DrawTarget {
pub fn new_default(size: DeviceIntSize, surface_is_y_flipped: bool) -> Self {
pub fn new_default(size: DeviceIntSize, surface_origin_is_top_left: bool) -> Self {
let total_size = FramebufferIntSize::from_untyped(size.to_untyped());
DrawTarget::Default {
rect: total_size.into(),
total_size,
surface_is_y_flipped,
surface_origin_is_top_left,
}
}
@ -1144,9 +1144,9 @@ impl DrawTarget {
pub fn to_framebuffer_rect(&self, device_rect: DeviceIntRect) -> FramebufferIntRect {
let mut fb_rect = FramebufferIntRect::from_untyped(&device_rect.to_untyped());
match *self {
DrawTarget::Default { ref rect, surface_is_y_flipped, .. } => {
DrawTarget::Default { ref rect, surface_origin_is_top_left, .. } => {
// perform a Y-flip here
if !surface_is_y_flipped {
if !surface_origin_is_top_left {
fb_rect.origin.y = rect.origin.y + rect.size.height - fb_rect.origin.y - fb_rect.size.height;
fb_rect.origin.x += rect.origin.x;
}
@ -1245,7 +1245,7 @@ impl Device {
allow_texture_storage_support: bool,
allow_texture_swizzling: bool,
dump_shader_source: Option<String>,
surface_is_y_flipped: bool,
surface_origin_is_top_left: bool,
) -> Device {
let mut max_texture_size = [0];
let mut max_texture_layers = [0];
@ -1482,7 +1482,7 @@ impl Device {
requires_null_terminated_shader_source,
optimal_pbo_stride,
dump_shader_source,
surface_is_y_flipped,
surface_origin_is_top_left,
}
}
@ -1510,8 +1510,8 @@ impl Device {
self.max_texture_size
}
pub fn surface_is_y_flipped(&self) -> bool {
self.surface_is_y_flipped
pub fn surface_origin_is_top_left(&self) -> bool {
self.surface_origin_is_top_left
}
/// Returns the limit on texture array layers.

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

@ -1934,7 +1934,7 @@ impl Renderer {
options.allow_texture_storage_support,
options.allow_texture_swizzling,
options.dump_shader_source.take(),
options.surface_is_y_flipped,
options.surface_origin_is_top_left,
);
let color_cache_formats = device.preferred_color_formats();
@ -4251,7 +4251,7 @@ impl Renderer {
}
};
let (src_rect, _) = render_tasks[output.task_id].get_target_rect();
if !self.device.surface_is_y_flipped() {
if !self.device.surface_origin_is_top_left() {
self.device.blit_render_target_invert_y(
draw_target.into(),
draw_target.to_framebuffer_rect(src_rect.translate(-content_origin.to_vector())),
@ -4928,8 +4928,8 @@ impl Renderer {
let offset = frame.content_origin.to_f32();
let size = frame.device_rect.size.to_f32();
let surface_is_y_flipped = self.device.surface_is_y_flipped();
let (bottom, top) = if surface_is_y_flipped {
let surface_origin_is_top_left = self.device.surface_origin_is_top_left();
let (bottom, top) = if surface_origin_is_top_left {
(offset.y, offset.y + size.height)
} else {
(offset.y + size.height, offset.y)
@ -4947,14 +4947,14 @@ impl Renderer {
let fb_scale = Scale::<_, _, FramebufferPixel>::new(1i32);
let mut fb_rect = frame.device_rect * fb_scale;
if !surface_is_y_flipped {
if !surface_origin_is_top_left {
fb_rect.origin.y = device_size.height - fb_rect.origin.y - fb_rect.size.height;
}
let draw_target = DrawTarget::Default {
rect: fb_rect,
total_size: device_size * fb_scale,
surface_is_y_flipped,
surface_origin_is_top_left,
};
// Picture caching can be enabled / disabled dynamically from frame to
@ -5406,7 +5406,7 @@ impl Renderer {
}
// Copy frame buffer into the zoom texture
let read_target = DrawTarget::new_default(device_size, self.device.surface_is_y_flipped());
let read_target = DrawTarget::new_default(device_size, self.device.surface_origin_is_top_left());
self.device.blit_render_target(
read_target.into(),
read_target.to_framebuffer_rect(source_rect),
@ -5542,18 +5542,18 @@ impl Renderer {
// we're blitting from a texture to the main framebuffer, which
// use different conventions.
let dest_rect = rect(x, y + tag_height, size, size);
if !device.surface_is_y_flipped() {
if !device.surface_origin_is_top_left() {
device.blit_render_target_invert_y(
ReadTarget::from_texture(texture, layer),
src_rect,
DrawTarget::new_default(device_size, device.surface_is_y_flipped()),
DrawTarget::new_default(device_size, device.surface_origin_is_top_left()),
FramebufferIntRect::from_untyped(&dest_rect),
);
} else {
device.blit_render_target(
ReadTarget::from_texture(texture, layer),
src_rect,
DrawTarget::new_default(device_size, device.surface_is_y_flipped()),
DrawTarget::new_default(device_size, device.surface_origin_is_top_left()),
FramebufferIntRect::from_untyped(&dest_rect),
TextureFilter::Linear,
);
@ -5997,7 +5997,7 @@ pub struct RendererOptions {
pub start_debug_server: bool,
/// Output the source of the shader with the given name.
pub dump_shader_source: Option<String>,
pub surface_is_y_flipped: bool,
pub surface_origin_is_top_left: bool,
/// The configuration options defining how WR composites the final scene.
pub compositor_config: CompositorConfig,
}
@ -6051,7 +6051,7 @@ impl Default for RendererOptions {
// needed.
start_debug_server: true,
dump_shader_source: None,
surface_is_y_flipped: false,
surface_origin_is_top_left: false,
compositor_config: CompositorConfig::default(),
}
}

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

@ -292,7 +292,7 @@ impl AsyncScreenshotGrabber {
let read_target_rect = FramebufferIntRect::from_untyped(&read_target_rect.to_untyped());
if level == 0 && !device.surface_is_y_flipped() {
if level == 0 && !device.surface_origin_is_top_left() {
device.blit_render_target_invert_y(
read_target,
read_target_rect,