gfx/gl/GfxTexturesReporter.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/GfxTexturesReporter.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef GFXTEXTURESREPORTER_H_
    1.11 +#define GFXTEXTURESREPORTER_H_
    1.12 +
    1.13 +#include "nsIMemoryReporter.h"
    1.14 +#include "GLTypes.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace gl {
    1.18 +
    1.19 +class GfxTexturesReporter MOZ_FINAL : public nsIMemoryReporter
    1.20 +{
    1.21 +public:
    1.22 +    NS_DECL_ISUPPORTS
    1.23 +
    1.24 +    GfxTexturesReporter()
    1.25 +    {
    1.26 +#ifdef DEBUG
    1.27 +        // There must be only one instance of this class, due to |sAmount|
    1.28 +        // being static.  Assert this.
    1.29 +        static bool hasRun = false;
    1.30 +        MOZ_ASSERT(!hasRun);
    1.31 +        hasRun = true;
    1.32 +#endif
    1.33 +    }
    1.34 +
    1.35 +    enum MemoryUse {
    1.36 +        // when memory being allocated is reported to a memory reporter
    1.37 +        MemoryAllocated,
    1.38 +        // when memory being freed is reported to a memory reporter
    1.39 +        MemoryFreed
    1.40 +    };
    1.41 +
    1.42 +    // When memory is used/freed for tile textures, call this method to update
    1.43 +    // the value reported by this memory reporter.
    1.44 +    static void UpdateAmount(MemoryUse action, GLenum format, GLenum type,
    1.45 +                             int32_t tileWidth, int32_t tileHeight);
    1.46 +
    1.47 +    NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
    1.48 +                              nsISupports* aData)
    1.49 +    {
    1.50 +        return MOZ_COLLECT_REPORT(
    1.51 +            "gfx-textures", KIND_OTHER, UNITS_BYTES, sAmount,
    1.52 +            "Memory used for storing GL textures.");
    1.53 +    }
    1.54 +
    1.55 +private:
    1.56 +    static int64_t sAmount;
    1.57 +};
    1.58 +
    1.59 +}
    1.60 +}
    1.61 +
    1.62 +#endif // GFXTEXTURESREPORTER_H_

mercurial