Commit c3d94ae2 authored by Markus Stange's avatar Markus Stange
Browse files

Bug 1574592 - Add CompositorWidget::GetOpaqueWidgetRegion. r=mattwoodrow

This lets LayerManagerComposite and RendererOGL set the correct opaque region
on the native layer.

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

--HG--
extra : moz-landing-system : lando
parent 222be5a8
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -252,6 +252,24 @@ class CompositorWidget {
   */
  virtual already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing();

#ifdef XP_MACOSX
  /**
   * Return the opaque region of the widget. This is racy and can only be used
   * on macOS, where the widget works around the raciness.
   * Bug 1576491 tracks fixing this properly.
   * The problem with this method is that it can return values "from the future"
   * - the compositor might be working on frame N but the widget will return its
   * opaque region from frame N + 1.
   * It is believed that this won't lead to visible glitches on macOS due to the
   * SuspendAsyncCATransactions call when the vibrant region changes or when the
   * window resizes. Whenever the compositor uses an opaque region that's a
   * frame ahead, the result it renders won't be shown on the screen; instead,
   * the next composite will happen with the correct display list, and that's
   * what's shown on the screen once the FlushRendering call completes.
   */
  virtual LayoutDeviceIntRegion GetOpaqueWidgetRegion() { return {}; }
#endif

  /**
   * Observe or unobserve vsync.
   */
+6 −0
Original line number Diff line number Diff line
@@ -110,6 +110,12 @@ uintptr_t InProcessCompositorWidget::GetWidgetKey() {

nsIWidget* InProcessCompositorWidget::RealWidget() { return mWidget; }

#ifdef XP_MACOSX
LayoutDeviceIntRegion InProcessCompositorWidget::GetOpaqueWidgetRegion() {
  return mWidget->GetOpaqueWidgetRegion();
}
#endif

void InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
  if (RefPtr<CompositorVsyncDispatcher> cvd =
          mWidget->GetCompositorVsyncDispatcher()) {
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ class InProcessCompositorWidget : public CompositorWidget {
  virtual bool InitCompositor(layers::Compositor* aCompositor) override;
  virtual LayoutDeviceIntSize GetClientSize() override;
  virtual uint32_t GetGLFrameBufferFormat() override;
#ifdef XP_MACOSX
  virtual LayoutDeviceIntRegion GetOpaqueWidgetRegion() override;
#endif
  virtual void ObserveVsync(VsyncObserver* aObserver) override;
  virtual uintptr_t GetWidgetKey() override;

+2 −0
Original line number Diff line number Diff line
@@ -568,6 +568,8 @@ class nsChildView final : public nsBaseWidget {

  virtual LayoutDeviceIntPoint GetClientOffset() override;

  virtual LayoutDeviceIntRegion GetOpaqueWidgetRegion() override;

  void DispatchAPZWheelInputEvent(mozilla::InputData& aEvent, bool aCanTriggerSwipe);
  nsEventStatus DispatchAPZInputEvent(mozilla::InputData& aEvent);

+5 −0
Original line number Diff line number Diff line
@@ -1590,6 +1590,11 @@ LayoutDeviceIntPoint nsChildView::WidgetToScreenOffset() {
  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0, 0));
}

LayoutDeviceIntRegion nsChildView::GetOpaqueWidgetRegion() {
  auto opaqueRegion = mOpaqueRegion.Lock();
  return *opaqueRegion;
}

nsresult nsChildView::SetTitle(const nsAString& title) {
  // child views don't have titles
  return NS_OK;
Loading