Merge m-c to b2g-inbound.
[gecko.git] / gfx / gl / GfxTexturesReporter.h
blob9ba04f02702e15304dcef12a2b2d7a86ec07f4a5
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/. */
7 #ifndef GFXTEXTURESREPORTER_H_
8 #define GFXTEXTURESREPORTER_H_
10 #include "nsIMemoryReporter.h"
11 #include "GLTypes.h"
13 namespace mozilla {
14 namespace gl {
16 class GfxTexturesReporter MOZ_FINAL : public MemoryUniReporter
18 public:
19 GfxTexturesReporter()
20 : MemoryUniReporter("gfx-textures", KIND_OTHER, UNITS_BYTES,
21 "Memory used for storing GL textures.")
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
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
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 uint16_t tileSize);
44 private:
45 int64_t Amount() MOZ_OVERRIDE { return sAmount; }
47 static int64_t sAmount;
53 #endif // GFXTEXTURESREPORTER_H_