Bug 1790985 - Add support for dumping inlined functions when scraping Linux system...
[gecko.git] / image / ImageMemoryReporter.h
blobab7d55c46da8950745bd5e2df4800122a095ed45
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_image_ImageMemoryReporter_h
8 #define mozilla_image_ImageMemoryReporter_h
10 #include <cstdint>
11 #include "nsString.h"
12 #include "mozilla/layers/SharedSurfacesMemoryReport.h"
14 class nsISupports;
15 class nsIHandleReportCallback;
17 namespace mozilla {
18 namespace image {
19 struct ImageMemoryCounter;
20 struct SurfaceMemoryCounter;
22 class ImageMemoryReporter final {
23 public:
24 /**
25 * Initializes image related memory reporting in the compositor process when
26 * using WebRender.
28 static void InitForWebRender();
30 /**
31 * Tears down image related memory reporting in the compositor process when
32 * using WebRender.
34 static void ShutdownForWebRender();
36 /**
37 * Report all remaining entries in the shared surface's memory report. This
38 * should be used by the content or main process to allow reporting any
39 * entries that is was unable to cross reference with the local surface cache.
40 * These are candidates for having been leaked. This should be used in
41 * conjunction with AppendSharedSurfacePrefix and/or TrimSharedSurfaces to
42 * produce the expected result.
44 static void ReportSharedSurfaces(
45 nsIHandleReportCallback* aHandleReport, nsISupports* aData,
46 const layers::SharedSurfacesMemoryReport& aSharedSurfaces);
48 /**
49 * Adjust the path prefix for a surface to include any additional metadata for
50 * the shared surface, if any. It will also remove any corresponding entries
51 * in the given memory report.
53 static void AppendSharedSurfacePrefix(
54 nsACString& aPathPrefix, const SurfaceMemoryCounter& aCounter,
55 layers::SharedSurfacesMemoryReport& aSharedSurfaces);
57 /**
58 * Remove all entries in the memory report for the given set of surfaces for
59 * an image. This is useful when we aren't reporting on a particular image
60 * because it isn't notable.
62 static void TrimSharedSurfaces(
63 const ImageMemoryCounter& aCounter,
64 layers::SharedSurfacesMemoryReport& aSharedSurfaces);
66 private:
67 /**
68 * Report all remaining entries in the shared surface's memory report.
70 * aIsForCompositor controls how to interpret what remains in the report. If
71 * true, this should mirror exactly what is currently in
72 * SharedSurfacesParent's cache. This will report entries that are currently
73 * mapped into the compositor process. If false, then we are in a content or
74 * main process, and it should have removed entries that also exist in its
75 * local surface cache -- thus any remaining entries are those that are
76 * candidates for leaks.
78 static void ReportSharedSurfaces(
79 nsIHandleReportCallback* aHandleReport, nsISupports* aData,
80 bool aIsForCompositor,
81 const layers::SharedSurfacesMemoryReport& aSharedSurfaces);
83 static void ReportSharedSurface(
84 nsIHandleReportCallback* aHandleReport, nsISupports* aData,
85 bool aIsForCompositor, uint64_t aExternalId,
86 const layers::SharedSurfacesMemoryReport::SurfaceEntry& aEntry);
88 class WebRenderReporter;
89 static WebRenderReporter* sWrReporter;
92 } // namespace image
93 } // namespace mozilla
95 #endif // mozilla_image_ImageMemoryReporter_h