mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 915940. Memory reporter for memory image surfaces. r=njn,mattwoodrow
This commit is contained in:
parent
0a67c29188
commit
ddb224cd5c
@ -211,6 +211,7 @@ MemoryTextureClient::Allocate(uint32_t aSize)
|
||||
{
|
||||
MOZ_ASSERT(!mBuffer);
|
||||
mBuffer = new uint8_t[aSize];
|
||||
GfxHeapTexturesReporter::OnAlloc(mBuffer);
|
||||
mBufSize = aSize;
|
||||
return true;
|
||||
}
|
||||
@ -228,9 +229,10 @@ MemoryTextureClient::MemoryTextureClient(CompositableClient* aCompositable,
|
||||
MemoryTextureClient::~MemoryTextureClient()
|
||||
{
|
||||
MOZ_COUNT_DTOR(MemoryTextureClient);
|
||||
if (ShouldDeallocateInDestructor()) {
|
||||
if (ShouldDeallocateInDestructor() && mBuffer) {
|
||||
// if the buffer has never been shared we must deallocate it or ir would
|
||||
// leak.
|
||||
GfxHeapTexturesReporter::OnFree(mBuffer);
|
||||
delete mBuffer;
|
||||
}
|
||||
}
|
||||
|
@ -535,6 +535,9 @@ MemoryTextureHost::~MemoryTextureHost()
|
||||
void
|
||||
MemoryTextureHost::DeallocateSharedData()
|
||||
{
|
||||
if (mBuffer) {
|
||||
GfxHeapTexturesReporter::OnFree(mBuffer);
|
||||
}
|
||||
delete[] mBuffer;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ using namespace mozilla::ipc;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
mozilla::Atomic<int32_t> GfxHeapTexturesReporter::sAmount;
|
||||
|
||||
SharedMemory::SharedMemoryType OptimalShmemType()
|
||||
{
|
||||
return SharedMemory::TYPE_BASIC;
|
||||
@ -88,6 +90,7 @@ ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize,
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
GfxHeapTexturesReporter::OnAlloc(data);
|
||||
#ifdef XP_MACOSX
|
||||
// Workaround a bug in Quartz where drawing an a8 surface to another a8
|
||||
// surface with OPERATOR_SOURCE still requires the destination to be clear.
|
||||
@ -134,7 +137,8 @@ ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface)
|
||||
case SurfaceDescriptor::TSurfaceDescriptorD3D10:
|
||||
break;
|
||||
case SurfaceDescriptor::TMemoryImage:
|
||||
delete [] (unsigned char *)aSurface->get_MemoryImage().data();
|
||||
GfxHeapTexturesReporter::OnFree((uint8_t*)aSurface->get_MemoryImage().data());
|
||||
delete [] (uint8_t*)aSurface->get_MemoryImage().data();
|
||||
break;
|
||||
case SurfaceDescriptor::Tnull_t:
|
||||
case SurfaceDescriptor::T__None:
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "gfxASurface.h" // for gfxASurface, etc
|
||||
#include "gfxPoint.h" // for gfxIntSize
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "nsIMemoryReporter.h" // for MemoryUniReporter
|
||||
#include "mozilla/Atomics.h" // for Atomic
|
||||
|
||||
/*
|
||||
* FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
|
||||
@ -25,6 +27,8 @@
|
||||
|
||||
class gfxASurface;
|
||||
class gfxSharedImageSurface;
|
||||
class MemoryTextureClient;
|
||||
class MemoryTextureHost;
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
@ -133,6 +137,38 @@ protected:
|
||||
~ISurfaceAllocator() {}
|
||||
};
|
||||
|
||||
class GfxHeapTexturesReporter MOZ_FINAL : public mozilla::MemoryUniReporter
|
||||
{
|
||||
public:
|
||||
GfxHeapTexturesReporter()
|
||||
: MemoryUniReporter("explicit/gfx/heap-textures", KIND_HEAP, UNITS_BYTES,
|
||||
"Heap memory shared between threads by texture clients and hosts.")
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// There must be only one instance of this class, due to |sAmount|
|
||||
// being static.
|
||||
static bool hasRun = false;
|
||||
MOZ_ASSERT(!hasRun);
|
||||
hasRun = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void OnAlloc(void* aPointer)
|
||||
{
|
||||
sAmount += MallocSizeOfOnAlloc(aPointer);
|
||||
}
|
||||
|
||||
static void OnFree(void* aPointer)
|
||||
{
|
||||
sAmount -= MallocSizeOfOnFree(aPointer);
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t Amount() MOZ_OVERRIDE { return sAmount; }
|
||||
|
||||
static mozilla::Atomic<int32_t> sAmount;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxHeapTexturesReporter
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prenv.h"
|
||||
@ -441,6 +442,8 @@ gfxPlatform::Init()
|
||||
false);
|
||||
|
||||
CreateCMSOutputProfile();
|
||||
|
||||
NS_RegisterMemoryReporter(new GfxHeapTexturesReporter());
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user