Global Metrics

path: .metrics.nexits.sum
old: 1.0
new: 13.0

path: .metrics.nexits.average
old: 1.0
new: 0.8666666666666667

path: .metrics.nargs.average
old: 0.0
new: 1.3333333333333333

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

path: .metrics.cyclomatic.sum
old: 2.0
new: 53.0

path: .metrics.halstead.purity_ratio
old: 1.944234353490973
new: 1.1520124007995094

path: .metrics.halstead.estimated_program_length
old: 13.60964047443681
new: 812.1687425636541

path: .metrics.halstead.vocabulary
old: 7.0
new: 124.0

path: .metrics.halstead.length
old: 7.0
new: 705.0

path: .metrics.halstead.level
old: 0.4
new: 0.09011857707509882

path: .metrics.halstead.N2
old: 2.0
new: 253.0

path: .metrics.halstead.volume
old: 19.651484454403228
new: 4902.708398822747

path: .metrics.halstead.n1
old: 5.0
new: 10.0

path: .metrics.halstead.difficulty
old: 2.5
new: 11.096491228070176

path: .metrics.halstead.time
old: 2.7293728408893374
new: 3022.381152295699

path: .metrics.halstead.effort
old: 49.12871113600807
new: 54402.86074132258

path: .metrics.halstead.N1
old: 5.0
new: 452.0

path: .metrics.halstead.bugs
old: 0.004471319041702271
new: 0.4785859046094203

path: .metrics.halstead.n2
old: 2.0
new: 114.0

path: .metrics.mi.mi_original
old: 132.59563637273845
new: 31.2333655331973

path: .metrics.mi.mi_sei
old: 115.79785476526216
new: -3.8575473358899792

path: .metrics.mi.mi_visual_studio
old: 77.54130782031488
new: 18.26512604280544

path: .metrics.nom.total
old: 1.0
new: 15.0

path: .metrics.nom.functions
old: 1.0
new: 15.0

path: .metrics.loc.blank
old: 0.0
new: 19.0

path: .metrics.loc.cloc
old: 0.0
new: 14.0

path: .metrics.loc.ploc
old: 4.0
new: 139.0

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

path: .metrics.loc.sloc
old: 4.0
new: 172.0

Spaces Data

Minimal test - lines (27, 170)

path: .spaces[0].metrics.mi.mi_original
old: 132.82563637273847
new: 34.59484198666132

path: .spaces[0].metrics.mi.mi_sei
old: 116.0278547652622
new: -6.2622908107657675

path: .spaces[0].metrics.mi.mi_visual_studio
old: 77.67581074429151
new: 20.23090174658557

path: .spaces[0].metrics.nom.total
old: 1.0
new: 15.0

path: .spaces[0].metrics.nom.functions
old: 1.0
new: 15.0

path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 52.0

path: .spaces[0].metrics.halstead.time
old: 2.7293728408893374
new: 2697.629183044905

path: .spaces[0].metrics.halstead.difficulty
old: 2.5
new: 10.398058252427184

path: .spaces[0].metrics.halstead.length
old: 7.0
new: 686.0

path: .spaces[0].metrics.halstead.N2
old: 2.0
new: 238.0

path: .spaces[0].metrics.halstead.level
old: 0.4
new: 0.096171802054155

path: .spaces[0].metrics.halstead.vocabulary
old: 7.0
new: 112.0

path: .spaces[0].metrics.halstead.effort
old: 49.12871113600807
new: 48557.32529480829

path: .spaces[0].metrics.halstead.estimated_program_length
old: 13.60964047443681
new: 717.2388793128523

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.944234353490973
new: 1.0455377249458488

path: .spaces[0].metrics.halstead.n2
old: 2.0
new: 103.0

path: .spaces[0].metrics.halstead.N1
old: 5.0
new: 448.0

path: .spaces[0].metrics.halstead.n1
old: 5.0
new: 9.0

path: .spaces[0].metrics.halstead.volume
old: 19.651484454403228
new: 4669.845476531516

path: .spaces[0].metrics.halstead.bugs
old: 0.004471319041702271
new: 0.4436582714499318

path: .spaces[0].metrics.nargs.average
old: 0.0
new: 1.3333333333333333

path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 20.0

path: .spaces[0].metrics.nexits.average
old: 1.0
new: 0.8666666666666667

path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 13.0

path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 5.0

path: .spaces[0].metrics.loc.blank
old: 0.0
new: 16.0

path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 15.0

path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 144.0

path: .spaces[0].metrics.loc.ploc
old: 4.0
new: 123.0

Code

namespace mozilla {
namespace widget {

typedef struct gbm_device* (*CreateDeviceFunc)(int);
typedef struct gbm_bo* (*CreateFunc)(struct gbm_device*, uint32_t, uint32_t,
                                     uint32_t, uint32_t);
typedef struct gbm_bo* (*CreateWithModifiersFunc)(struct gbm_device*, uint32_t,
                                                  uint32_t, uint32_t,
                                                  const uint64_t*,
                                                  const unsigned int);
typedef uint64_t (*GetModifierFunc)(struct gbm_bo*);
typedef uint32_t (*GetStrideFunc)(struct gbm_bo*);
typedef int (*GetFdFunc)(struct gbm_bo*);
typedef void (*DestroyFunc)(struct gbm_bo*);
typedef void* (*MapFunc)(struct gbm_bo*, uint32_t, uint32_t, uint32_t, uint32_t,
                         uint32_t, uint32_t*, void**);
typedef void (*UnmapFunc)(struct gbm_bo*, void*);
typedef int (*GetPlaneCountFunc)(struct gbm_bo*);
typedef union gbm_bo_handle (*GetHandleForPlaneFunc)(struct gbm_bo*, int);
typedef uint32_t (*GetStrideForPlaneFunc)(struct gbm_bo*, int);
typedef uint32_t (*GetOffsetFunc)(struct gbm_bo*, int);
typedef int (*DeviceIsFormatSupportedFunc)(struct gbm_device*, uint32_t,
                                           uint32_t);
typedef int (*DrmPrimeHandleToFDFunc)(int, uint32_t, uint32_t, int*);

class nsGbmLib {
 public:
  static bool Load();
  static bool IsLoaded();
  static bool IsAvailable();
  static bool IsModifierAvailable();

  static struct gbm_device* CreateDevice(int fd) { return sCreateDevice(fd); };
  static struct gbm_bo* Create(struct gbm_device* gbm, uint32_t width,
                               uint32_t height, uint32_t format,
                               uint32_t flags) {
    return sCreate(gbm, width, height, format, flags);
  }
  static void Destroy(struct gbm_bo* bo) { sDestroy(bo); }
  static uint32_t GetStride(struct gbm_bo* bo) { return sGetStride(bo); }
  static int GetFd(struct gbm_bo* bo) { return sGetFd(bo); }
  static void* Map(struct gbm_bo* bo, uint32_t x, uint32_t y, uint32_t width,
                   uint32_t height, uint32_t flags, uint32_t* stride,
                   void** map_data) {
    return sMap(bo, x, y, width, height, flags, stride, map_data);
  }
  static void Unmap(struct gbm_bo* bo, void* map_data) { sUnmap(bo, map_data); }
  static struct gbm_bo* CreateWithModifiers(struct gbm_device* gbm,
                                            uint32_t width, uint32_t height,
                                            uint32_t format,
                                            const uint64_t* modifiers,
                                            const unsigned int count) {
    return sCreateWithModifiers(gbm, width, height, format, modifiers, count);
  }
  static uint64_t GetModifier(struct gbm_bo* bo) { return sGetModifier(bo); }
  static int GetPlaneCount(struct gbm_bo* bo) { return sGetPlaneCount(bo); }
  static union gbm_bo_handle GetHandleForPlane(struct gbm_bo* bo, int plane) {
    return sGetHandleForPlane(bo, plane);
  }
  static uint32_t GetStrideForPlane(struct gbm_bo* bo, int plane) {
    return sGetStrideForPlane(bo, plane);
  }
  static uint32_t GetOffset(struct gbm_bo* bo, int plane) {
    return sGetOffset(bo, plane);
  }
  static int DeviceIsFormatSupported(struct gbm_device* gbm, uint32_t format,
                                     uint32_t usage) {
    return sDeviceIsFormatSupported(gbm, format, usage);
  }

  static int DrmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags,
                                int* prime_fd) {
    return sDrmPrimeHandleToFD(fd, handle, flags, prime_fd);
  }

 private:
  static CreateDeviceFunc sCreateDevice;
  static CreateFunc sCreate;
  static CreateWithModifiersFunc sCreateWithModifiers;
  static GetModifierFunc sGetModifier;
  static GetStrideFunc sGetStride;
  static GetFdFunc sGetFd;
  static DestroyFunc sDestroy;
  static MapFunc sMap;
  static UnmapFunc sUnmap;
  static GetPlaneCountFunc sGetPlaneCount;
  static GetHandleForPlaneFunc sGetHandleForPlane;
  static GetStrideForPlaneFunc sGetStrideForPlane;
  static GetOffsetFunc sGetOffset;
  static DeviceIsFormatSupportedFunc sDeviceIsFormatSupported;
  static DrmPrimeHandleToFDFunc sDrmPrimeHandleToFD;

  static void* sGbmLibHandle;
  static void* sXf86DrmLibHandle;
  static bool sLibLoaded;
};

struct GbmFormat {
  bool mIsSupported;
  bool mHasAlpha;
  int mFormat;
  uint64_t* mModifiers;
  int mModifiersCount;
};

class nsDMABufDevice {
 public:
  nsDMABufDevice();
  ~nsDMABufDevice();

  gbm_device* GetGbmDevice();
  // Returns -1 if we fails to gbm device file descriptor.
  int GetGbmDeviceFd();

  // Use dmabuf for WebRender general web content
  bool IsDMABufTexturesEnabled();
  // Use dmabuf for VA-API video playback
  bool IsDMABufVAAPIEnabled();
  // Use dmabuf for WebGL content
  bool IsDMABufWebGLEnabled();

  GbmFormat* GetGbmFormat(bool aHasAlpha);
  GbmFormat* GetExactGbmFormat(int aFormat);
  void ResetFormatsModifiers();
  void AddFormatModifier(bool aHasAlpha, int aFormat, uint32_t mModifierHi,
                         uint32_t mModifierLo);

 private:
  bool IsDMABufEnabled();
  bool Configure();

  void* mRegistry;

  GbmFormat mXRGBFormat;
  GbmFormat mARGBFormat;

  gbm_device* mGbmDevice;
  int mGbmFd;
};

nsDMABufDevice* GetDMABufDevice();

}  // namespace widget
}  // namespace mozilla