Bug 831193 (part 12) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in gfxWindowsPlatform.cpp. r=jmuizelaar.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 17 Jan 2013 16:45:11 -0800
changeset 144675 b9bce0abddbd8807c6ca0e1d239e7dd232128adf
parent 144674 5680c6a6162f521c4545d14a111c8d26c29742c9
child 144676 6e610d6a19955de6338451c4d59ace987e9b31ab
push id25171
push useremorley@mozilla.com
push dateWed, 28 Aug 2013 15:20:13 +0000
treeherdermozilla-central@f280351a238f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs831193
milestone26.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 831193 (part 12) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in gfxWindowsPlatform.cpp. r=jmuizelaar.
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set ts=8 sts=4 et sw=4 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Util.h"
 
 #include "gfxWindowsPlatform.h"
 
 #include "gfxImageSurface.h"
@@ -67,23 +68,29 @@ using namespace mozilla;
 #ifdef CAIRO_HAS_D2D_SURFACE
 
 static const char *kFeatureLevelPref =
   "gfx.direct3d.last_used_feature_level_idx";
 static const int kSupportedFeatureLevels[] =
   { D3D10_FEATURE_LEVEL_10_1, D3D10_FEATURE_LEVEL_10_0,
     D3D10_FEATURE_LEVEL_9_3 };
 
-NS_MEMORY_REPORTER_IMPLEMENT(
-    D2DCache,
-    "gfx-d2d-surfacecache",
-    KIND_OTHER,
-    UNITS_BYTES,
-    cairo_d2d_get_image_surface_cache_usage,
-    "Memory used by the Direct2D internal surface cache.")
+class GfxD2DSurfaceCacheReporter MOZ_FINAL : public MemoryReporterBase
+{
+public:
+    GfxD2DSurfaceCacheReporter()
+      : MemoryReporterBase("gfx-d2d-surface-cache", KIND_OTHER, UNITS_BYTES,
+"Memory used by the Direct2D internal surface cache.")
+    {}
+private:
+    int64_t Amount() MOZ_OVERRIDE
+    {
+        return cairo_d2d_get_image_surface_cache_usage();
+    }
+};
 
 namespace
 {
 
 bool OncePreferenceDirect2DDisabled()
 {
   static int preferenceValue = -1;
   if (preferenceValue < 0) {
@@ -96,65 +103,63 @@ bool OncePreferenceDirect2DForceEnabled(
 {
   static int preferenceValue = -1;
   if (preferenceValue < 0) {
     preferenceValue = Preferences::GetBool("gfx.direct2d.force-enabled", false);
   }
   return !!preferenceValue;
 }
 
-int64_t GetD2DSurfaceVramUsage() {
-  cairo_device_t *device =
-      gfxWindowsPlatform::GetPlatform()->GetD2DDevice();
-  if (device) {
-      return cairo_d2d_get_surface_vram_usage(device);
-  }
-  return 0;
-}
-
 } // anonymous namespace
 
-NS_MEMORY_REPORTER_IMPLEMENT(
-    D2DVram,
-    "gfx-d2d-surfacevram",
-    KIND_OTHER,
-    UNITS_BYTES,
-    GetD2DSurfaceVramUsage,
-    "Video memory used by D2D surfaces.")
+class GfxD2DSurfaceVramReporter MOZ_FINAL : public MemoryReporterBase
+{
+public:
+    GfxD2DSurfaceVramReporter()
+      : MemoryReporterBase("gfx-d2d-surface-vram", KIND_OTHER, UNITS_BYTES,
+                           "Video memory used by D2D surfaces.")
+    {}
+private:
+    int64_t Amount() MOZ_OVERRIDE {
+      cairo_device_t *device =
+          gfxWindowsPlatform::GetPlatform()->GetD2DDevice();
+      return device ? cairo_d2d_get_surface_vram_usage(device) : 0;
+    }
+};
 
 #endif
 
-namespace
+class GfxD2DVramDrawTargetReporter MOZ_FINAL : public MemoryReporterBase
 {
-
-int64_t GetD2DVRAMUsageDrawTarget() {
-    return mozilla::gfx::Factory::GetD2DVRAMUsageDrawTarget();
-}
-
-int64_t GetD2DVRAMUsageSourceSurface() {
-    return mozilla::gfx::Factory::GetD2DVRAMUsageSourceSurface();
-}
-
-} // anonymous namespace
+public:
+    GfxD2DVramDrawTargetReporter()
+      : MemoryReporterBase("gfx-d2d-vram-draw-target", KIND_OTHER, UNITS_BYTES,
+                           "Video memory used by D2D DrawTargets.")
+    {}
+private:
+    int64_t Amount() MOZ_OVERRIDE
+    {
+        return Factory::GetD2DVRAMUsageDrawTarget();
+    }
+};
 
-NS_MEMORY_REPORTER_IMPLEMENT(
-    D2DVRAMDT,
-    "gfx-d2d-vram-drawtarget",
-    KIND_OTHER,
-    UNITS_BYTES,
-    GetD2DVRAMUsageDrawTarget,
-    "Video memory used by D2D DrawTargets.")
-
-NS_MEMORY_REPORTER_IMPLEMENT(
-    D2DVRAMSS,
-    "gfx-d2d-vram-sourcesurface",
-    KIND_OTHER,
-    UNITS_BYTES,
-    GetD2DVRAMUsageSourceSurface,
-    "Video memory used by D2D SourceSurfaces.")
+class GfxD2DVramSourceSurfaceReporter MOZ_FINAL : public MemoryReporterBase
+{
+public:
+    GfxD2DVramSourceSurfaceReporter()
+      : MemoryReporterBase("gfx-d2d-vram-source-surface",
+                           KIND_OTHER, UNITS_BYTES,
+                           "Video memory used by D2D SourceSurfaces.")
+    {}
+private:
+    int64_t Amount() MOZ_OVERRIDE
+    {
+        return Factory::GetD2DVRAMUsageSourceSurface();
+    }
+};
 
 #define GFX_USE_CLEARTYPE_ALWAYS "gfx.font_rendering.cleartype.always_use_for_content"
 #define GFX_DOWNLOADABLE_FONTS_USE_CLEARTYPE "gfx.font_rendering.cleartype.use_for_downloadable_fonts"
 
 #define GFX_CLEARTYPE_PARAMS           "gfx.font_rendering.cleartype_params."
 #define GFX_CLEARTYPE_PARAMS_GAMMA     "gfx.font_rendering.cleartype_params.gamma"
 #define GFX_CLEARTYPE_PARAMS_CONTRAST  "gfx.font_rendering.cleartype_params.enhanced_contrast"
 #define GFX_CLEARTYPE_PARAMS_LEVEL     "gfx.font_rendering.cleartype_params.cleartype_level"
@@ -366,22 +371,22 @@ gfxWindowsPlatform::gfxWindowsPlatform()
     /* 
      * Initialize COM 
      */ 
     CoInitialize(nullptr); 
 
     mScreenDC = GetDC(nullptr);
 
 #ifdef CAIRO_HAS_D2D_SURFACE
-    NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DCache));
-    NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVram));
+    NS_RegisterMemoryReporter(new GfxD2DSurfaceCacheReporter());
+    NS_RegisterMemoryReporter(new GfxD2DSurfaceVramReporter());
     mD2DDevice = nullptr;
 #endif
-    NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMDT));
-    NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMSS));
+    NS_RegisterMemoryReporter(new GfxD2DVramDrawTargetReporter());
+    NS_RegisterMemoryReporter(new GfxD2DVramSourceSurfaceReporter());
 
     UpdateRenderMode();
 
     mGPUAdapterMultiReporter = new GPUAdapterMultiReporter();
     NS_RegisterMemoryMultiReporter(mGPUAdapterMultiReporter);
 }
 
 gfxWindowsPlatform::~gfxWindowsPlatform()