Bug 936964 (part 6) - Rename WebGLMemoryReporterWrapper as WebGLMemoryTracker. r=bjacob.

--HG--
rename : content/canvas/src/WebGLMemoryReporterWrapper.h => content/canvas/src/WebGLMemoryTracker.h
extra : rebase_source : 7a215cf3dbcf0b78f8ab823828360dd0cfba26d3
This commit is contained in:
Nicholas Nethercote 2013-11-25 16:03:38 -08:00
Родитель 10c5872ca0
Коммит 4c33114408
4 изменённых файлов: 33 добавлений и 33 удалений

Просмотреть файл

@ -10,7 +10,7 @@
#include "WebGLContextUtils.h" #include "WebGLContextUtils.h"
#include "WebGLBuffer.h" #include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h" #include "WebGLVertexAttribData.h"
#include "WebGLMemoryReporterWrapper.h" #include "WebGLMemoryTracker.h"
#include "WebGLFramebuffer.h" #include "WebGLFramebuffer.h"
#include "WebGLVertexArray.h" #include "WebGLVertexArray.h"
#include "WebGLQuery.h" #include "WebGLQuery.h"
@ -178,7 +178,7 @@ WebGLContext::WebGLContext()
mPixelStorePackAlignment = 4; mPixelStorePackAlignment = 4;
mPixelStoreUnpackAlignment = 4; mPixelStoreUnpackAlignment = 4;
WebGLMemoryReporterWrapper::AddWebGLContext(this); WebGLMemoryTracker::AddWebGLContext(this);
mAllowRestore = true; mAllowRestore = true;
mContextLossTimerRunning = false; mContextLossTimerRunning = false;
@ -212,7 +212,7 @@ WebGLContext::WebGLContext()
WebGLContext::~WebGLContext() WebGLContext::~WebGLContext()
{ {
DestroyResourcesAndContext(); DestroyResourcesAndContext();
WebGLMemoryReporterWrapper::RemoveWebGLContext(this); WebGLMemoryTracker::RemoveWebGLContext(this);
TerminateContextLossTimer(); TerminateContextLossTimer();
mContextRestorer = nullptr; mContextRestorer = nullptr;
} }
@ -669,8 +669,8 @@ void WebGLContext::LoseOldestWebGLContextIfLimitExceeded()
// when choosing which one to lose first. // when choosing which one to lose first.
UpdateLastUseIndex(); UpdateLastUseIndex();
WebGLMemoryReporterWrapper::ContextsArrayType &contexts WebGLMemoryTracker::ContextsArrayType &contexts
= WebGLMemoryReporterWrapper::Contexts(); = WebGLMemoryTracker::Contexts();
// quick exit path, should cover a majority of cases // quick exit path, should cover a majority of cases
if (contexts.Length() <= kMaxWebGLContextsPerPrincipal) { if (contexts.Length() <= kMaxWebGLContextsPerPrincipal) {

Просмотреть файл

@ -122,7 +122,7 @@ class WebGLContext :
{ {
friend class WebGLContextUserData; friend class WebGLContextUserData;
friend class WebGLMemoryPressureObserver; friend class WebGLMemoryPressureObserver;
friend class WebGLMemoryReporterWrapper; friend class WebGLMemoryTracker;
friend class WebGLExtensionLoseContext; friend class WebGLExtensionLoseContext;
friend class WebGLExtensionCompressedTextureS3TC; friend class WebGLExtensionCompressedTextureS3TC;
friend class WebGLExtensionCompressedTextureATC; friend class WebGLExtensionCompressedTextureATC;

Просмотреть файл

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h" #include "WebGLContext.h"
#include "WebGLMemoryReporterWrapper.h" #include "WebGLMemoryTracker.h"
#include "nsIMemoryReporter.h" #include "nsIMemoryReporter.h"
using namespace mozilla; using namespace mozilla;
@ -37,7 +37,7 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-texture-memory", REPORT("webgl-texture-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetTextureMemoryUsed(), WebGLMemoryTracker::GetTextureMemoryUsed(),
"Memory used by WebGL textures.The OpenGL" "Memory used by WebGL textures.The OpenGL"
" implementation is free to store these textures in either video" " implementation is free to store these textures in either video"
" memory or main memory. This measurement is only a lower bound," " memory or main memory. This measurement is only a lower bound,"
@ -46,12 +46,12 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-texture-count", REPORT("webgl-texture-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetTextureCount(), WebGLMemoryTracker::GetTextureCount(),
"Number of WebGL textures."); "Number of WebGL textures.");
REPORT("webgl-buffer-memory", REPORT("webgl-buffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferMemoryUsed(), WebGLMemoryTracker::GetBufferMemoryUsed(),
"Memory used by WebGL buffers. The OpenGL" "Memory used by WebGL buffers. The OpenGL"
" implementation is free to store these buffers in either video" " implementation is free to store these buffers in either video"
" memory or main memory. This measurement is only a lower bound," " memory or main memory. This measurement is only a lower bound,"
@ -60,7 +60,7 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("explicit/webgl/buffer-cache-memory", REPORT("explicit/webgl/buffer-cache-memory",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed(), WebGLMemoryTracker::GetBufferCacheMemoryUsed(),
"Memory used by WebGL buffer caches. The WebGL" "Memory used by WebGL buffer caches. The WebGL"
" implementation caches the contents of element array buffers" " implementation caches the contents of element array buffers"
" only.This adds up with the webgl-buffer-memory value, but" " only.This adds up with the webgl-buffer-memory value, but"
@ -69,12 +69,12 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-buffer-count", REPORT("webgl-buffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetBufferCount(), WebGLMemoryTracker::GetBufferCount(),
"Number of WebGL buffers."); "Number of WebGL buffers.");
REPORT("webgl-renderbuffer-memory", REPORT("webgl-renderbuffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetRenderbufferMemoryUsed(), WebGLMemoryTracker::GetRenderbufferMemoryUsed(),
"Memory used by WebGL renderbuffers. The OpenGL" "Memory used by WebGL renderbuffers. The OpenGL"
" implementation is free to store these renderbuffers in either" " implementation is free to store these renderbuffers in either"
" video memory or main memory. This measurement is only a lower" " video memory or main memory. This measurement is only a lower"
@ -83,23 +83,23 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT("webgl-renderbuffer-count", REPORT("webgl-renderbuffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetRenderbufferCount(), WebGLMemoryTracker::GetRenderbufferCount(),
"Number of WebGL renderbuffers."); "Number of WebGL renderbuffers.");
REPORT("explicit/webgl/shader", REPORT("explicit/webgl/shader",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetShaderSize(), WebGLMemoryTracker::GetShaderSize(),
"Combined size of WebGL shader ASCII sources and translation" "Combined size of WebGL shader ASCII sources and translation"
" logs cached on the heap."); " logs cached on the heap.");
REPORT("webgl-shader-count", REPORT("webgl-shader-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetShaderCount(), WebGLMemoryTracker::GetShaderCount(),
"Number of WebGL shaders."); "Number of WebGL shaders.");
REPORT("webgl-context-count", REPORT("webgl-context-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetContextCount(), WebGLMemoryTracker::GetContextCount(),
"Number of WebGL contexts."); "Number of WebGL contexts.");
#undef REPORT #undef REPORT
@ -107,25 +107,25 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
return NS_OK; return NS_OK;
} }
NS_IMPL_ISUPPORTS1(WebGLMemoryReporterWrapper, nsISupports) NS_IMPL_ISUPPORTS1(WebGLMemoryTracker, nsISupports)
StaticRefPtr<WebGLMemoryReporterWrapper> WebGLMemoryReporterWrapper::sUniqueInstance; StaticRefPtr<WebGLMemoryTracker> WebGLMemoryTracker::sUniqueInstance;
WebGLMemoryReporterWrapper* WebGLMemoryReporterWrapper::UniqueInstance() WebGLMemoryTracker* WebGLMemoryTracker::UniqueInstance()
{ {
if (!sUniqueInstance) { if (!sUniqueInstance) {
sUniqueInstance = new WebGLMemoryReporterWrapper; sUniqueInstance = new WebGLMemoryTracker;
} }
return sUniqueInstance; return sUniqueInstance;
} }
WebGLMemoryReporterWrapper::WebGLMemoryReporterWrapper() WebGLMemoryTracker::WebGLMemoryTracker()
{ {
mReporter = new WebGLMemoryReporter; mReporter = new WebGLMemoryReporter;
NS_RegisterMemoryReporter(mReporter); NS_RegisterMemoryReporter(mReporter);
} }
WebGLMemoryReporterWrapper::~WebGLMemoryReporterWrapper() WebGLMemoryTracker::~WebGLMemoryTracker()
{ {
NS_UnregisterMemoryReporter(mReporter); NS_UnregisterMemoryReporter(mReporter);
} }
@ -133,7 +133,7 @@ WebGLMemoryReporterWrapper::~WebGLMemoryReporterWrapper()
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLBufferMallocSizeOf) NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLBufferMallocSizeOf)
int64_t int64_t
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() { WebGLMemoryTracker::GetBufferCacheMemoryUsed() {
const ContextsArrayType & contexts = Contexts(); const ContextsArrayType & contexts = Contexts();
int64_t result = 0; int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) { for(size_t i = 0; i < contexts.Length(); ++i) {
@ -151,7 +151,7 @@ WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() {
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLShaderMallocSizeOf) NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLShaderMallocSizeOf)
int64_t int64_t
WebGLMemoryReporterWrapper::GetShaderSize() { WebGLMemoryTracker::GetShaderSize() {
const ContextsArrayType & contexts = Contexts(); const ContextsArrayType & contexts = Contexts();
int64_t result = 0; int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) { for(size_t i = 0; i < contexts.Length(); ++i) {

Просмотреть файл

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WEBGLMEMORYREPORTERWRAPPER_H_ #ifndef WEBGLMEMORYTRACKER_H_
#define WEBGLMEMORYREPORTERWRAPPER_H_ #define WEBGLMEMORYTRACKER_H_
#include "WebGLContext.h" #include "WebGLContext.h"
#include "WebGLBuffer.h" #include "WebGLBuffer.h"
@ -18,23 +18,23 @@
namespace mozilla { namespace mozilla {
class WebGLMemoryReporterWrapper : public nsISupports class WebGLMemoryTracker : public nsISupports
{ {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
WebGLMemoryReporterWrapper(); WebGLMemoryTracker();
virtual ~WebGLMemoryReporterWrapper(); virtual ~WebGLMemoryTracker();
static StaticRefPtr<WebGLMemoryReporterWrapper> sUniqueInstance; static StaticRefPtr<WebGLMemoryTracker> sUniqueInstance;
// here we store plain pointers, not RefPtrs: we don't want the // here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryReporterWrapper unique instance to keep alive all // WebGLMemoryTracker unique instance to keep alive all
// WebGLContexts ever created. // WebGLContexts ever created.
typedef nsTArray<const WebGLContext*> ContextsArrayType; typedef nsTArray<const WebGLContext*> ContextsArrayType;
ContextsArrayType mContexts; ContextsArrayType mContexts;
nsCOMPtr<nsIMemoryReporter> mReporter; nsCOMPtr<nsIMemoryReporter> mReporter;
static WebGLMemoryReporterWrapper* UniqueInstance(); static WebGLMemoryTracker* UniqueInstance();
static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; } static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; }