michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFXTEXTURESREPORTER_H_ michael@0: #define GFXTEXTURESREPORTER_H_ michael@0: michael@0: #include "nsIMemoryReporter.h" michael@0: #include "GLTypes.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GfxTexturesReporter MOZ_FINAL : public nsIMemoryReporter michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: GfxTexturesReporter() michael@0: { michael@0: #ifdef DEBUG michael@0: // There must be only one instance of this class, due to |sAmount| michael@0: // being static. Assert this. michael@0: static bool hasRun = false; michael@0: MOZ_ASSERT(!hasRun); michael@0: hasRun = true; michael@0: #endif michael@0: } michael@0: michael@0: enum MemoryUse { michael@0: // when memory being allocated is reported to a memory reporter michael@0: MemoryAllocated, michael@0: // when memory being freed is reported to a memory reporter michael@0: MemoryFreed michael@0: }; michael@0: michael@0: // When memory is used/freed for tile textures, call this method to update michael@0: // the value reported by this memory reporter. michael@0: static void UpdateAmount(MemoryUse action, GLenum format, GLenum type, michael@0: int32_t tileWidth, int32_t tileHeight); michael@0: michael@0: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, michael@0: nsISupports* aData) michael@0: { michael@0: return MOZ_COLLECT_REPORT( michael@0: "gfx-textures", KIND_OTHER, UNITS_BYTES, sAmount, michael@0: "Memory used for storing GL textures."); michael@0: } michael@0: michael@0: private: michael@0: static int64_t sAmount; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // GFXTEXTURESREPORTER_H_