Bug 558467: Use nsIMemoryReporter to report the image surface cache memory usage. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Wed, 30 Jun 2010 15:52:13 +0200
changeset 46438 d40d82f51b58954e503d4c98a44d881833177a71
parent 46437 4498d202b84754625f2a5afad2bb37aeb05e2fb6
child 46439 73a507162b6037771148471b1093074a6ebfc212
push id14188
push userbschouten@mozilla.com
push dateWed, 30 Jun 2010 13:52:34 +0000
treeherdermozilla-central@d40d82f51b58 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs558467
milestone2.0b2pre
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 558467: Use nsIMemoryReporter to report the image surface cache memory usage. r=jrmuizel
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -70,16 +70,46 @@
 #include "gfxDWriteFonts.h"
 #include "gfxDWriteCommon.h"
 #include <dwrite.h>
 #endif
 #endif
 
 #ifdef CAIRO_HAS_D2D_SURFACE
 #include "gfxD2DSurface.h"
+
+#include "nsIMemoryReporter.h"
+#include "nsMemory.h"
+
+class D2DCacheReporter :
+    public nsIMemoryReporter
+{
+public:
+    D2DCacheReporter()
+    { }
+
+    NS_DECL_ISUPPORTS
+
+    NS_IMETHOD GetPath(char **memoryPath) {
+        *memoryPath = strdup("gfx/d2d/surfacecache");
+        return NS_OK;
+    }
+
+    NS_IMETHOD GetDescription(char **desc) {
+        *desc = strdup("Memory used by Direct2D internal surface cache.");
+        return NS_OK;
+    }
+
+    NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) {
+        *memoryUsed = cairo_d2d_get_image_surface_cache_usage();
+        return NS_OK;
+    }
+}; 
+
+NS_IMPL_ISUPPORTS1(D2DCacheReporter, nsIMemoryReporter)
 #endif
 
 #ifdef WINCE
 #include <shlwapi.h>
 
 #ifdef CAIRO_HAS_DDRAW_SURFACE
 #include "gfxDDrawSurface.h"
 #endif
@@ -133,16 +163,19 @@ gfxWindowsPlatform::gfxWindowsPlatform()
 #elif defined(WINCE)
     mRenderMode = RENDER_DDRAW_GL;
 #else
     mRenderMode = RENDER_GDI;
 #endif
 
     nsCOMPtr<nsIPrefBranch2> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
 
+#ifdef CAIRO_HAS_D2D_SURFACE
+    NS_RegisterMemoryReporter(new D2DCacheReporter());
+#endif
 #ifdef CAIRO_HAS_DWRITE_FONT
     nsresult rv;
     PRBool useDirectWrite = PR_FALSE;
 
     rv = pref->GetBoolPref(
         "gfx.font_rendering.directwrite.enabled", &useDirectWrite);
     if (NS_FAILED(rv)) {
         useDirectWrite = PR_FALSE;