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/. */
9 #include "nsExceptionHandler.h"
10 #include "GfxTexturesReporter.h"
11 #include "mozilla/StaticPrefs_gfx.h"
13 using namespace mozilla::gl
;
15 NS_IMPL_ISUPPORTS(GfxTexturesReporter
, nsIMemoryReporter
)
17 mozilla::Atomic
<size_t> GfxTexturesReporter::sAmount(0);
18 mozilla::Atomic
<size_t> GfxTexturesReporter::sPeakAmount(0);
19 mozilla::Atomic
<size_t> GfxTexturesReporter::sTileWasteAmount(0);
21 static std::string
FormatBytes(size_t amount
) {
22 std::stringstream stream
;
49 stream
<< val
<< " " << unit
;
54 void GfxTexturesReporter::UpdateAmount(MemoryUse action
, size_t amount
) {
55 if (action
== MemoryFreed
) {
58 "GFX: Current texture usage greater than update amount.");
61 if (StaticPrefs::gfx_logging_texture_usage_enabled_AtStartup()) {
62 printf_stderr("Current texture usage: %s\n",
63 FormatBytes(sAmount
).c_str());
67 if (sAmount
> sPeakAmount
) {
68 sPeakAmount
.exchange(sAmount
);
69 if (StaticPrefs::gfx_logging_peak_texture_usage_enabled_AtStartup()) {
70 printf_stderr("Peak texture usage: %s\n",
71 FormatBytes(sPeakAmount
).c_str());
76 CrashReporter::AnnotateTexturesSize(sAmount
);