Global Metrics

path: .metrics.halstead.level
old: 0.0613931523022432
new: 0.08333333333333333

path: .metrics.halstead.n2
old: 104.0
new: 95.0

path: .metrics.halstead.estimated_program_length
old: 734.8994784916838
new: 682.7396417255678

path: .metrics.halstead.time
old: 3958.338799938864
new: 1668.2144895270665

path: .metrics.halstead.difficulty
old: 16.28846153846154
new: 12.0

path: .metrics.halstead.volume
old: 4374.268142553456
new: 2502.3217342905996

path: .metrics.halstead.length
old: 639.0
new: 369.0

path: .metrics.halstead.effort
old: 71250.09839889956
new: 30027.860811487197

path: .metrics.halstead.purity_ratio
old: 1.1500774311293955
new: 1.850242931505604

path: .metrics.halstead.n1
old: 11.0
new: 15.0

path: .metrics.halstead.bugs
old: 0.5728871190776945
new: 0.3220290182457067

path: .metrics.halstead.N2
old: 308.0
new: 152.0

path: .metrics.halstead.vocabulary
old: 115.0
new: 110.0

path: .metrics.halstead.N1
old: 331.0
new: 217.0

path: .metrics.cyclomatic.average
old: 1.0
new: 1.022222222222222

path: .metrics.cyclomatic.sum
old: 7.0
new: 46.0

path: .metrics.loc.blank
old: 55.0
new: 37.0

path: .metrics.loc.lloc
old: 0.0
new: 15.0

path: .metrics.loc.cloc
old: 265.0
new: 142.0

path: .metrics.loc.ploc
old: 148.0
new: 109.0

path: .metrics.loc.sloc
old: 468.0
new: 288.0

path: .metrics.nargs.sum
old: 0.0
new: 7.0

path: .metrics.nargs.average
old: null
new: 0.3888888888888889

path: .metrics.mi.mi_sei
old: 8.751214712986432
new: 13.644773284776852

path: .metrics.mi.mi_visual_studio
old: 15.3161650234107
new: 16.368522806468064

path: .metrics.mi.mi_original
old: 26.190642190032293
new: 27.99017399906039

path: .metrics.cognitive.sum
old: 0.0
new: 1.0

path: .metrics.cognitive.average
old: null
new: 0.05555555555555555

path: .metrics.nom.functions
old: 0.0
new: 18.0

path: .metrics.nom.total
old: 0.0
new: 18.0

path: .metrics.nexits.average
old: null
new: 0.7777777777777778

path: .metrics.nexits.sum
old: 0.0
new: 14.0

Spaces Data

Minimal test - lines (22, 286)

path: .spaces[2].metrics.nargs.average
old: null
new: 0.3888888888888889

path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 7.0

path: .spaces[2].metrics.cognitive.average
old: null
new: 0.05555555555555555

path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 1.0

path: .spaces[2].metrics.halstead.level
old: null
new: 0.08095238095238094

path: .spaces[2].metrics.halstead.N2
old: 1.0
new: 140.0

path: .spaces[2].metrics.halstead.vocabulary
old: 1.0
new: 100.0

path: .spaces[2].metrics.halstead.n1
old: 0.0
new: 15.0

path: .spaces[2].metrics.halstead.effort
old: 0.0
new: 29135.2634675121

path: .spaces[2].metrics.halstead.bugs
old: 0.0
new: 0.31561529772713237

path: .spaces[2].metrics.halstead.N1
old: 0.0
new: 215.0

path: .spaces[2].metrics.halstead.estimated_program_length
old: null
new: 603.4015885058324

path: .spaces[2].metrics.halstead.purity_ratio
old: null
new: 1.6997227845234717

path: .spaces[2].metrics.halstead.time
old: 0.0
new: 1618.6257481951168

path: .spaces[2].metrics.halstead.difficulty
old: 0.0
new: 12.352941176470589

path: .spaces[2].metrics.halstead.n2
old: 1.0
new: 85.0

path: .spaces[2].metrics.halstead.volume
old: 0.0
new: 2358.568947370027

path: .spaces[2].metrics.halstead.length
old: 1.0
new: 355.0

path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 1.0238095238095235

path: .spaces[2].metrics.cyclomatic.sum
old: 1.0
new: 43.0

path: .spaces[2].metrics.nom.total
old: 0.0
new: 18.0

path: .spaces[2].metrics.nom.functions
old: 0.0
new: 18.0

path: .spaces[2].metrics.loc.ploc
old: 1.0
new: 95.0

path: .spaces[2].metrics.loc.sloc
old: 1.0
new: 265.0

path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 138.0

path: .spaces[2].metrics.loc.blank
old: 0.0
new: 32.0

path: .spaces[2].metrics.loc.lloc
old: 0.0
new: 15.0

path: .spaces[2].metrics.nexits.average
old: null
new: 0.7777777777777778

path: .spaces[2].metrics.nexits.sum
old: 0.0
new: 14.0

path: .spaces[2].metrics.mi.mi_original
old: null
new: 30.336163072525295

path: .spaces[2].metrics.mi.mi_sei
old: null
new: 17.403495482185676

path: .spaces[2].metrics.mi.mi_visual_studio
old: null
new: 17.740446241242864

Code

namespace mozilla {
class VsyncObserver;
namespace gl {
class GLContext;
}  // namespace gl
namespace layers {
class Compositor;
class LayerManager;
class LayerManagerComposite;
class NativeLayerRoot;
}  // namespace layers
namespace gfx {
class DrawTarget;
class SourceSurface;
}  // namespace gfx
namespace widget {

class WinCompositorWidget;
class GtkCompositorWidget;
class AndroidCompositorWidget;
class CompositorWidgetInitData;

// Gecko widgets usually need to communicate with the CompositorWidget with
// platform-specific messages (for example to update the window size or
// transparency). This functionality is controlled through a "host". Since
// this functionality is platform-dependent, it is only forward declared
// here.
class PlatformCompositorWidgetDelegate;

// Headless mode uses its own, singular CompositorWidget implementation.
class HeadlessCompositorWidget;

class CompositorWidgetDelegate {
 public:
  virtual PlatformCompositorWidgetDelegate* AsPlatformSpecificDelegate() {
    return nullptr;
  }

  virtual HeadlessCompositorWidget* AsHeadlessCompositorWidget() {
    return nullptr;
  }
};

// Platforms that support out-of-process widgets.
#if defined(XP_WIN) || defined(MOZ_X11)
// CompositorWidgetParent should implement CompositorWidget and
// PCompositorWidgetParent.
class CompositorWidgetParent;

// CompositorWidgetChild should implement CompositorWidgetDelegate and
// PCompositorWidgetChild.
class CompositorWidgetChild;

#  define MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
#endif

class WidgetRenderingContext {
 public:
#if defined(XP_MACOSX)
  gl::GLContext* mGL = nullptr;
#endif
};

/**
 * Access to a widget from the compositor is restricted to these methods.
 */
class CompositorWidget {
 public:
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::widget::CompositorWidget)

  /**
   * Create an in-process compositor widget. aWidget may be ignored if the
   * platform does not require it.
   */
  static RefPtr CreateLocal(
      const CompositorWidgetInitData& aInitData,
      const layers::CompositorOptions& aOptions, nsIWidget* aWidget);

  /**
   * Called before rendering using OMTC. Returns false when the widget is
   * not ready to be rendered (for example while the window is closed).
   *
   * Always called from the compositing thread, which may be the main-thread if
   * OMTC is not enabled.
   */
  virtual bool PreRender(WidgetRenderingContext* aContext) { return true; }

  /**
   * Called after rendering using OMTC. Not called when rendering was
   * cancelled by a negative return value from PreRender.
   *
   * Always called from the compositing thread, which may be the main-thread if
   * OMTC is not enabled.
   */
  virtual void PostRender(WidgetRenderingContext* aContext) {}

  /**
   * Called before the first composite. If the result is non-null, one or more
   * native layers will be placed on the window and used for compositing.
   * When native layers are used, StartRemoteDrawing(InRegion) and
   * EndRemoteDrawing(InRegion) will not be called.
   */
  virtual RefPtr GetNativeLayerRoot() {
    return nullptr;
  }

  /**
   * Return a DrawTarget for the window which can be composited into.
   *
   * Only called if GetNativeLayerRoot() returns nullptr.
   * Called by BasicCompositor on the compositor thread for OMTC drawing
   * before each composition (unless there's a native layer root).
   *
   * The window may specify its buffer mode. If unspecified, it is assumed
   * to require double-buffering.
   */
  virtual already_AddRefed StartRemoteDrawing();
  virtual already_AddRefed StartRemoteDrawingInRegion(
      const LayoutDeviceIntRegion& aInvalidRegion,
      layers::BufferMode* aBufferMode) {
    return StartRemoteDrawing();
  }

  /**
   * Ensure that what was painted into the DrawTarget returned from
   * StartRemoteDrawing reaches the screen.
   *
   * Called by BasicCompositor on the compositor thread for OMTC drawing
   * after each composition for which StartRemoteDrawing(InRegion) was called.
   */
  virtual void EndRemoteDrawing() {}
  virtual void EndRemoteDrawingInRegion(
      gfx::DrawTarget* aDrawTarget,
      const LayoutDeviceIntRegion& aInvalidRegion) {
    EndRemoteDrawing();
  }

  /**
   * Return true when it is better to defer EndRemoteDrawing().
   *
   * Called by BasicCompositor on the compositor thread for OMTC drawing
   * after each composition.
   */
  virtual bool NeedsToDeferEndRemoteDrawing() { return false; }

  /**
   * Some widgets (namely Gtk) may need clean up underlying surface
   * before painting to draw transparent objects correctly. Return
   * the transparent region where this clearing is required.
   */
  virtual LayoutDeviceIntRegion GetTransparentRegion();

  /**
   * Called when shutting down the LayerManager to clean-up any cached
   * resources.
   *
   * Always called from the compositing thread.
   */
  virtual void CleanupWindowEffects() {}

  /**
   * A hook for the widget to prepare a Compositor, during the latter's
   * initialization.
   *
   * If this method returns true, it means that the widget will be able to
   * present frames from the compoositor.
   *
   * Returning false will cause the compositor's initialization to fail, and
   * a different compositor backend will be used (if any).
   */
  virtual bool InitCompositor(layers::Compositor* aCompositor) { return true; }

  /**
   * Return the size of the drawable area of the widget.
   */
  virtual LayoutDeviceIntSize GetClientSize() = 0;

  /**
   * Return the internal format of the default framebuffer for this
   * widget.
   */
  virtual uint32_t GetGLFrameBufferFormat();

  /*
   * Access the underlying nsIWidget. This method will be removed when the
   * compositor no longer depends on nsIWidget on any platform.
   */
  virtual nsIWidget* RealWidget() = 0;

  /**
   * Clean up any resources used by Start/EndRemoteDrawing.
   *
   * Called by BasicCompositor on the compositor thread for OMTC drawing
   * when the compositor is destroyed.
   */
  virtual void CleanupRemoteDrawing();

  /**
   * Return a key that can represent the widget object round-trip across the
   * CompositorBridge channel. This only needs to be implemented on GTK and
   * Windows.
   *
   * The key must be the nsIWidget pointer cast to a uintptr_t. See
   * CompositorBridgeChild::RecvHideAllPlugins and
   * CompositorBridgeParent::SendHideAllPlugins.
   */
  virtual uintptr_t GetWidgetKey() { return 0; }

  /**
   * Create a backbuffer for the software compositor.
   */
  virtual already_AddRefed GetBackBufferDrawTarget(
      gfx::DrawTarget* aScreenTarget, const gfx::IntRect& aRect,
      bool* aOutIsCleared);

  /**
   * Ensure end of composition to back buffer.
   *
   * Called by BasicCompositor on the compositor thread for OMTC drawing
   * after each composition to back buffer.
   */
  virtual already_AddRefed EndBackBufferDrawing();

  /**
   * Observe or unobserve vsync.
   */
  virtual void ObserveVsync(VsyncObserver* aObserver) = 0;

  /**
   * Get the compositor options for the compositor associated with this
   * CompositorWidget.
   */
  const layers::CompositorOptions& GetCompositorOptions() { return mOptions; }

  /**
   * Return true if the window is hidden and should not be composited.
   */
  virtual bool IsHidden() const { return false; }

  /**
   * This is only used by out-of-process compositors.
   */
  virtual RefPtr GetVsyncObserver() const;

  virtual WinCompositorWidget* AsWindows() { return nullptr; }
  virtual GtkCompositorWidget* AsX11() { return nullptr; }
  virtual AndroidCompositorWidget* AsAndroid() { return nullptr; }

  /**
   * Return the platform-specific delegate for the widget, if any.
   */
  virtual CompositorWidgetDelegate* AsDelegate() { return nullptr; }

 protected:
  explicit CompositorWidget(const layers::CompositorOptions& aOptions);
  virtual ~CompositorWidget();

  // Back buffer of BasicCompositor
  RefPtr mLastBackBuffer;

  layers::CompositorOptions mOptions;
};

}  // namespace widget
}  // namespace mozilla