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
12 #include "mozilla/layers/SharedSurfacesMemoryReport.h"
15 class nsIHandleReportCallback
;
19 struct ImageMemoryCounter
;
20 struct SurfaceMemoryCounter
;
22 class ImageMemoryReporter final
{
25 * Initializes image related memory reporting in the compositor process when
28 static void InitForWebRender();
31 * Tears down image related memory reporting in the compositor process when
34 static void ShutdownForWebRender();
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
);
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
);
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
);
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
;
93 } // namespace mozilla
95 #endif // mozilla_image_ImageMemoryReporter_h