Bug 1593903 - Change RenderCompositor::SurfaceIsYFlipped() to SurfaceOriginIsTopLeft() r=gw
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 05 Nov 2019 11:02:40 +0000
changeset 500589 bed1d14f0ef889f2d2e7c29c4123ef1b2eec5b92
parent 500588 15820b3a254f818ea265c86e844afb59736a22d8
child 500590 cf5e611e9d21dd33e1be27da7ec68e057801ebc5
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1593903
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593903 - Change RenderCompositor::SurfaceIsYFlipped() to SurfaceOriginIsTopLeft() r=gw Differential Revision: https://phabricator.services.mozilla.com/D51776
gfx/webrender_bindings/RenderCompositor.h
gfx/webrender_bindings/RenderCompositorANGLE.h
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/src/bindings.rs
gfx/wr/webrender/src/debug_render.rs
gfx/wr/webrender/src/device/gl.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender/src/screen_capture.rs
--- a/gfx/webrender_bindings/RenderCompositor.h
+++ b/gfx/webrender_bindings/RenderCompositor.h
@@ -90,18 +90,18 @@ class RenderCompositor {
   virtual void AddSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aPosition,
                           wr::DeviceIntRect aClipRect) {}
 
   // Interface for partial present
   virtual bool UsePartialPresent() { return false; }
   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.
   RenderedFrameId mLatestRenderFrameId = RenderedFrameId{2};
   RenderedFrameId GetNextRenderFrameId() {
     mLatestRenderFrameId = mLatestRenderFrameId.Next();
     return mLatestRenderFrameId;
   }
--- a/gfx/webrender_bindings/RenderCompositorANGLE.h
+++ b/gfx/webrender_bindings/RenderCompositorANGLE.h
@@ -56,17 +56,17 @@ class RenderCompositorANGLE : public Ren
   bool UseDComp() const override { return !!mDCLayerTree; }
 
   bool UseTripleBuffering() const override { return mUseTripleBuffering; }
 
   LayoutDeviceIntSize GetBufferSize() override;
 
   bool IsContextLost() override;
 
-  bool SurfaceIsYFlipped() override { return true; }
+  bool SurfaceOriginIsTopLeft() override { return true; }
 
   bool ShouldUseNativeCompositor() override;
 
   // Interface for wr::Compositor
   void CompositorBeginFrame() override;
   void CompositorEndFrame() override;
   void Bind(wr::NativeSurfaceId aId, wr::DeviceIntPoint* aOffset,
             uint32_t* aFboId, wr::DeviceIntRect aDirtyRect) override;
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -80,17 +80,17 @@ class NewRenderer : public RendererEvent
             supportLowPriorityTransactions, allow_texture_swizzling,
             StaticPrefs::gfx_webrender_picture_caching() &&
                 supportPictureCaching,
 #ifdef NIGHTLY_BUILD
             StaticPrefs::gfx_webrender_start_debug_server(),
 #else
             false,
 #endif
-            compositor->gl(), compositor->SurfaceIsYFlipped(),
+            compositor->gl(), compositor->SurfaceOriginIsTopLeft(),
             aRenderThread.GetProgramCache()
                 ? aRenderThread.GetProgramCache()->Raw()
                 : nullptr,
             aRenderThread.GetShaders()
                 ? aRenderThread.GetShaders()->RawShaders()
                 : nullptr,
             aRenderThread.ThreadPool().Raw(), &WebRenderMallocSizeOf,
             &WebRenderMallocEnclosingSizeOf, (uint32_t)wr::RenderRoot::Default,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1290,17 +1290,17 @@ impl Compositor for WrCompositor {
 pub extern "C" fn wr_window_new(window_id: WrWindowId,
                                 window_width: i32,
                                 window_height: i32,
                                 support_low_priority_transactions: bool,
                                 allow_texture_swizzling: bool,
                                 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,
                                 size_of_op: VoidPtrToSizeFn,
                                 enclosing_size_of_op: VoidPtrToSizeFn,
                                 document_id: u32,
                                 compositor: *mut c_void,
                                 max_partial_present_rects: usize,
@@ -1396,17 +1396,17 @@ pub extern "C" fn wr_window_new(window_i
         sampler: Some(Box::new(SamplerCallback::new(window_id))),
         max_texture_size: Some(8192), // Moz2D doesn't like textures bigger than this
         clear_color: Some(color),
         precache_flags,
         namespace_alloc_by_client: true,
         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()
     };
 
     // Ensure the WR profiler callbacks are hooked up to the Gecko profiler.
     set_profiler_hooks(Some(&PROFILER_HOOKS));
 
     let window_size = DeviceIntSize::new(window_width, window_height);
--- a/gfx/wr/webrender/src/debug_render.rs
+++ b/gfx/wr/webrender/src/debug_render.rs
@@ -316,18 +316,18 @@ impl DebugRenderer {
         viewport_size: Option<DeviceIntSize>,
         scale: f32,
     ) {
         if let Some(viewport_size) = viewport_size {
             device.disable_depth();
             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)
             };
 
             let projection = Transform3D::ortho(
                 0.0,
                 viewport_size.width as f32 * scale,
--- a/gfx/wr/webrender/src/device/gl.rs
+++ b/gfx/wr/webrender/src/device/gl.rs
@@ -1041,30 +1041,30 @@ pub struct Device {
     requires_null_terminated_shader_source: bool,
 
     // GL extensions
     extensions: Vec<String>,
 
     /// 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.
 #[derive(Clone, Copy, Debug)]
 pub enum DrawTarget {
     /// Use the device's default draw target, with the provided dimensions,
     /// which are used to set the viewport.
     Default {
         /// Target rectangle to draw.
         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 {
         /// Size of the texture in pixels
         dimensions: DeviceIntSize,
         /// The slice within the texture array to draw to
         layer: LayerIndex,
         /// Whether to draw with the texture's associated depth target
@@ -1087,22 +1087,22 @@ pub enum DrawTarget {
     NativeSurface {
         offset: DeviceIntPoint,
         external_fbo_id: u32,
         dimensions: DeviceIntSize,
     },
 }
 
 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,
         }
     }
 
     /// Returns true if this draw target corresponds to the default framebuffer.
     pub fn is_default(&self) -> bool {
         match *self {
             DrawTarget::Default {..} => true,
             _ => false,
@@ -1139,19 +1139,19 @@ impl DrawTarget {
             DrawTarget::External { size, .. } => DeviceIntSize::from_untyped(size.to_untyped()),
             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());
         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;
                 }
             }
             DrawTarget::Texture { .. } | DrawTarget::External { .. } => (),
             DrawTarget::NativeSurface { .. } => {
                 panic!("bug: is this ever used for native surfaces?");
             }
@@ -1240,17 +1240,17 @@ impl Device {
         mut gl: Rc<dyn gl::Gl>,
         resource_override_path: Option<PathBuf>,
         upload_method: UploadMethod,
         cached_programs: Option<Rc<ProgramCache>>,
         allow_pixel_local_storage_support: bool,
         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];
         unsafe {
             gl.get_integer_v(gl::MAX_TEXTURE_SIZE, &mut max_texture_size);
             gl.get_integer_v(gl::MAX_ARRAY_TEXTURE_LAYERS, &mut max_texture_layers);
         }
 
@@ -1477,17 +1477,17 @@ impl Device {
             renderer_name,
             cached_programs,
             frame_id: GpuFrameId(0),
             extensions,
             texture_storage_usage,
             requires_null_terminated_shader_source,
             optimal_pbo_stride,
             dump_shader_source,
-            surface_is_y_flipped,
+            surface_origin_is_top_left,
         }
     }
 
     pub fn gl(&self) -> &dyn gl::Gl {
         &*self.gl
     }
 
     pub fn rc_gl(&self) -> &Rc<dyn gl::Gl> {
@@ -1505,18 +1505,18 @@ impl Device {
         self.max_texture_size = self.max_texture_size.min(size);
     }
 
     /// Returns the limit on texture dimensions (width or height).
     pub fn max_texture_size(&self) -> i32 {
         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.
     pub fn max_texture_layers(&self) -> usize {
         self.max_texture_layers as usize
     }
 
     pub fn get_capabilities(&self) -> &Capabilities {
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -1929,17 +1929,17 @@ impl Renderer {
             gl,
             options.resource_override_path.clone(),
             options.upload_method.clone(),
             options.cached_programs.take(),
             options.allow_pixel_local_storage_support,
             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();
         let swizzle_settings = device.swizzle_settings();
         let supports_dual_source_blending = match gl_type {
             gl::GlType::Gl => device.supports_extension("GL_ARB_blend_func_extended") &&
                 device.supports_extension("GL_ARB_explicit_attrib_location"),
             gl::GlType::Gles => device.supports_extension("GL_EXT_blend_func_extended"),
@@ -4246,17 +4246,17 @@ impl Renderer {
                     }
                     Entry::Occupied(mut entry) => {
                         let target = entry.get_mut();
                         target.last_access = frame_id;
                         target.fbo_id
                     }
                 };
                 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())),
                         DrawTarget::External { fbo: fbo_id, size: output_size },
                         output_size.into(),
                     );
                 } else {
                     self.device.blit_render_target(
@@ -4923,18 +4923,18 @@ impl Renderer {
 
             match pass.kind {
                 RenderPassKind::MainFramebuffer { ref main_target, .. } => {
                     if let Some(device_size) = device_size {
                         results.stats.color_target_count += 1;
 
                         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)
                         };
 
                         let projection = Transform3D::ortho(
                             offset.x,
                             offset.x + size.width,
@@ -4942,24 +4942,24 @@ impl Renderer {
                             top,
                             ORTHO_NEAR_PLANE,
                             ORTHO_FAR_PLANE,
                         );
 
                         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
                         // frame. This is determined by what the frame builder selected, and is
                         // passed to the renderer via the composite state.
                         if frame.composite_state.picture_caching_is_enabled {
                             // If we have a native OS compositor, then make use of that interface
                             // to specify how to composite each of the picture cache surfaces.
@@ -5401,17 +5401,17 @@ impl Renderer {
                 Some(RenderTargetInfo { has_depth: false }),
                 1,
             );
 
             self.zoom_debug_texture = Some(texture);
         }
 
         // 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),
             DrawTarget::from_texture(
                 self.zoom_debug_texture.as_ref().unwrap(),
                 0,
                 false,
             ),
@@ -5537,28 +5537,28 @@ impl Renderer {
                     ColorU::new(0, 0, 0, 255),
                     Some(text_rect.to_f32())
                 );
 
                 // Blit the contents of the layer. We need to invert Y because
                 // 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,
                     );
                 }
                 i += 1;
             }
         }
     }
@@ -5992,17 +5992,17 @@ pub struct RendererOptions {
     pub allow_texture_swizzling: bool,
     /// Number of batches to look back in history for adding the current
     /// transparent instance into.
     pub batch_lookback_count: usize,
     /// Start the debug server for this renderer.
     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,
 }
 
 impl Default for RendererOptions {
     fn default() -> Self {
         RendererOptions {
             device_pixel_ratio: 1.0,
@@ -6046,17 +6046,17 @@ impl Default for RendererOptions {
             allow_texture_swizzling: true,
             batch_lookback_count: DEFAULT_BATCH_LOOKBACK_COUNT,
             // For backwards compatibility we set this to true by default, so
             // that if the debugger feature is enabled, the debug server will
             // be started automatically. Users can explicitly disable this as
             // needed.
             start_debug_server: true,
             dump_shader_source: None,
-            surface_is_y_flipped: false,
+            surface_origin_is_top_left: false,
             compositor_config: CompositorConfig::default(),
         }
     }
 }
 
 pub trait DebugServer {
     fn send(&mut self, _message: String);
 }
--- a/gfx/wr/webrender/src/screen_capture.rs
+++ b/gfx/wr/webrender/src/screen_capture.rs
@@ -287,17 +287,17 @@ impl AsyncScreenshotGrabber {
 
         let draw_target = DrawTarget::from_texture(&self.scaling_textures[level], 0 as _, false);
 
         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());
 
-        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,
                 draw_target,
                 draw_target_rect,
             );
         } else {
             device.blit_render_target(