2013-09-07 06:13:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "GfxTexturesReporter.h"
|
|
|
|
|
2016-02-03 23:24:47 +03:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(GfxTexturesReporter, nsIMemoryReporter)
|
2013-12-08 10:09:10 +04:00
|
|
|
|
2016-01-27 00:03:37 +03:00
|
|
|
Atomic<size_t> GfxTexturesReporter::sAmount(0);
|
2016-02-11 00:03:32 +03:00
|
|
|
Atomic<size_t> GfxTexturesReporter::sPeakAmount(0);
|
2016-01-27 00:03:37 +03:00
|
|
|
Atomic<size_t> GfxTexturesReporter::sTileWasteAmount(0);
|
2013-09-07 06:13:37 +04:00
|
|
|
|
|
|
|
/* static */ void
|
2016-01-27 00:03:37 +03:00
|
|
|
GfxTexturesReporter::UpdateAmount(MemoryUse action, size_t amount)
|
2013-09-07 06:13:37 +04:00
|
|
|
{
|
|
|
|
if (action == MemoryFreed) {
|
2016-01-27 00:03:37 +03:00
|
|
|
MOZ_RELEASE_ASSERT(amount <= sAmount);
|
|
|
|
sAmount -= amount;
|
2013-09-07 06:13:37 +04:00
|
|
|
} else {
|
2016-01-27 00:03:37 +03:00
|
|
|
sAmount += amount;
|
2016-02-11 00:03:32 +03:00
|
|
|
if (sAmount > sPeakAmount) {
|
|
|
|
sPeakAmount.exchange(sAmount);
|
|
|
|
}
|
2013-09-07 06:13:37 +04:00
|
|
|
}
|
2016-02-03 23:24:47 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
CrashReporter::AnnotateTexturesSize(sAmount);
|
|
|
|
#endif
|
2013-09-07 06:13:37 +04:00
|
|
|
}
|