gfx/gl/GfxTexturesReporter.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:58e5adef94eb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 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/. */
6
7 #ifndef GFXTEXTURESREPORTER_H_
8 #define GFXTEXTURESREPORTER_H_
9
10 #include "nsIMemoryReporter.h"
11 #include "GLTypes.h"
12
13 namespace mozilla {
14 namespace gl {
15
16 class GfxTexturesReporter MOZ_FINAL : public nsIMemoryReporter
17 {
18 public:
19 NS_DECL_ISUPPORTS
20
21 GfxTexturesReporter()
22 {
23 #ifdef DEBUG
24 // There must be only one instance of this class, due to |sAmount|
25 // being static. Assert this.
26 static bool hasRun = false;
27 MOZ_ASSERT(!hasRun);
28 hasRun = true;
29 #endif
30 }
31
32 enum MemoryUse {
33 // when memory being allocated is reported to a memory reporter
34 MemoryAllocated,
35 // when memory being freed is reported to a memory reporter
36 MemoryFreed
37 };
38
39 // When memory is used/freed for tile textures, call this method to update
40 // the value reported by this memory reporter.
41 static void UpdateAmount(MemoryUse action, GLenum format, GLenum type,
42 int32_t tileWidth, int32_t tileHeight);
43
44 NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
45 nsISupports* aData)
46 {
47 return MOZ_COLLECT_REPORT(
48 "gfx-textures", KIND_OTHER, UNITS_BYTES, sAmount,
49 "Memory used for storing GL textures.");
50 }
51
52 private:
53 static int64_t sAmount;
54 };
55
56 }
57 }
58
59 #endif // GFXTEXTURESREPORTER_H_

mercurial