Global Metrics

path: .metrics.mi.mi_sei
old: -8.116368371432578
new: 26.501227169321144

path: .metrics.mi.mi_original
old: 21.59257555464083
new: 53.50731651657553

path: .metrics.mi.mi_visual_studio
old: 12.627237166456624
new: 31.29082837226639

path: .metrics.loc.lloc
old: 111.0
new: 22.0

path: .metrics.loc.cloc
old: 53.0
new: 9.0

path: .metrics.loc.ploc
old: 179.0
new: 70.0

path: .metrics.loc.blank
old: 43.0
new: 14.0

path: .metrics.loc.sloc
old: 275.0
new: 93.0

path: .metrics.cognitive.sum
old: 21.0
new: 9.0

path: .metrics.cognitive.average
old: 1.5
new: 1.125

path: .metrics.cyclomatic.average
old: 3.2666666666666666
new: 1.6363636363636365

path: .metrics.cyclomatic.sum
old: 49.0
new: 18.0

path: .metrics.halstead.N2
old: 481.0
new: 132.0

path: .metrics.halstead.difficulty
old: 37.774869109947645
new: 20.794520547945204

path: .metrics.halstead.time
old: 18174.21910011699
new: 2495.1896263006593

path: .metrics.halstead.estimated_program_length
old: 1594.4956240230836
new: 555.8991177875525

path: .metrics.halstead.level
old: 0.026472626472626472
new: 0.04808959156785244

path: .metrics.halstead.n1
old: 30.0
new: 23.0

path: .metrics.halstead.length
old: 1112.0
new: 328.0

path: .metrics.halstead.bugs
old: 1.5825748326444524
new: 0.42117519551186305

path: .metrics.halstead.vocabulary
old: 221.0
new: 96.0

path: .metrics.halstead.purity_ratio
old: 1.4338989424668018
new: 1.6948143834986358

path: .metrics.halstead.n2
old: 191.0
new: 73.0

path: .metrics.halstead.volume
old: 8660.147646043271
new: 2159.8677002365393

path: .metrics.halstead.N1
old: 631.0
new: 196.0

path: .metrics.halstead.effort
old: 327135.9438021058
new: 44913.41327341187

path: .metrics.nargs.average
old: 1.7857142857142858
new: 0.875

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

path: .metrics.nexits.average
old: 1.5714285714285714
new: 0.875

path: .metrics.nexits.sum
old: 22.0
new: 7.0

path: .metrics.nom.total
old: 14.0
new: 8.0

path: .metrics.nom.functions
old: 14.0
new: 8.0

Spaces Data

Minimal test - lines (10, 93)

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

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

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

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

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

path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.7

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

path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 84.0

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

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

path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 68.0

path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 9.0

path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 1.125

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

path: .spaces[0].metrics.mi.mi_visual_studio
old: 90.80912574437468
new: 32.42224645332833

path: .spaces[0].metrics.mi.mi_original
old: 155.2836050228807
new: 55.44204143519144

path: .spaces[0].metrics.mi.mi_sei
old: 148.4278547652622
new: 20.44631791108505

Code

namespace mozilla {
namespace widget {

AndroidCompositorWidget::AndroidCompositorWidget(
    const layers::CompositorOptions& aOptions, nsBaseWidget* aWidget)
    : InProcessCompositorWidget(aOptions, aWidget),
      mNativeWindow(nullptr),
      mFormat(WINDOW_FORMAT_RGBA_8888) {}

AndroidCompositorWidget::~AndroidCompositorWidget() {
  if (mNativeWindow) {
    ANativeWindow_release(mNativeWindow);
  }
}

already_AddRefed
AndroidCompositorWidget::StartRemoteDrawingInRegion(
    const LayoutDeviceIntRegion& aInvalidRegion,
    layers::BufferMode* aBufferMode) {
  if (!mNativeWindow) {
    EGLNativeWindowType window = GetEGLNativeWindow();
    JNIEnv* const env = jni::GetEnvForThread();
    mNativeWindow =
        ANativeWindow_fromSurface(env, reinterpret_cast(window));
    if (mNativeWindow) {
      mFormat = ANativeWindow_getFormat(mNativeWindow);
      ANativeWindow_acquire(mNativeWindow);
    } else {
      return nullptr;
    }
  }

  if (mFormat != WINDOW_FORMAT_RGBA_8888 &&
      mFormat != WINDOW_FORMAT_RGBX_8888) {
    gfxCriticalNoteOnce << "Non supported format: " << mFormat;
    return nullptr;
  }

  // XXX Handle inOutDirtyBounds
  if (ANativeWindow_lock(mNativeWindow, &mBuffer, nullptr) != 0) {
    return nullptr;
  }

  const int bpp = 4;
  gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
  if (mFormat == WINDOW_FORMAT_RGBX_8888) {
    format = gfx::SurfaceFormat::B8G8R8X8;
  }

  RefPtr dt = gfx::Factory::CreateDrawTargetForData(
      gfx::BackendType::SKIA, static_cast(mBuffer.bits),
      gfx::IntSize(mBuffer.width, mBuffer.height), mBuffer.stride * bpp, format,
      true);

  return dt.forget();
}

void AndroidCompositorWidget::EndRemoteDrawingInRegion(
    gfx::DrawTarget* aDrawTarget, const LayoutDeviceIntRegion& aInvalidRegion) {
  // XXX Needs convert BGRA to RGBA. RGBA is not supported by sw-wr
  const int bpp = 4;
  gfxUtils::ConvertBGRAtoRGBA((uint8_t*)mBuffer.bits,
                              mBuffer.stride * mBuffer.height * bpp);
  ANativeWindow_unlockAndPost(mNativeWindow);
}

EGLNativeWindowType AndroidCompositorWidget::GetEGLNativeWindow() {
  return (EGLNativeWindowType)mWidget->GetNativeData(NS_JAVA_SURFACE);
}

EGLNativeWindowType AndroidCompositorWidget::GetPresentationEGLSurface() {
  return (EGLNativeWindowType)mWidget->GetNativeData(NS_PRESENTATION_SURFACE);
}

void AndroidCompositorWidget::SetPresentationEGLSurface(EGLSurface aVal) {
  mWidget->SetNativeData(NS_PRESENTATION_SURFACE, (uintptr_t)aVal);
}

ANativeWindow* AndroidCompositorWidget::GetPresentationANativeWindow() {
  return (ANativeWindow*)mWidget->GetNativeData(NS_PRESENTATION_WINDOW);
}

}  // namespace widget
}  // namespace mozilla