mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 603885, part 3: Allow allocating gfxSharedImageSurface with unsafe Shmem. r=joe
This commit is contained in:
parent
3070bf00d3
commit
7e89a7975d
@ -76,14 +76,16 @@ public:
|
||||
gfxImageFormat aFormat,
|
||||
SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC)
|
||||
{
|
||||
mSize = aSize;
|
||||
mFormat = aFormat;
|
||||
mStride = ComputeStride();
|
||||
if (!aAllocator->AllocShmem(GetAlignedSize(),
|
||||
aShmType, &mShmem))
|
||||
return false;
|
||||
return Init<ShmemAllocator, false>(aAllocator, aSize, aFormat, aShmType);
|
||||
}
|
||||
|
||||
return InitSurface(PR_TRUE);
|
||||
template<class ShmemAllocator>
|
||||
bool InitUnsafe(ShmemAllocator *aAllocator,
|
||||
const gfxIntSize& aSize,
|
||||
gfxImageFormat aFormat,
|
||||
SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC)
|
||||
{
|
||||
return Init<ShmemAllocator, true>(aAllocator, aSize, aFormat, aShmType);
|
||||
}
|
||||
|
||||
/* Gives Shmem data, which can be passed to IPDL interfaces */
|
||||
@ -93,6 +95,28 @@ public:
|
||||
static PRBool IsSharedImage(gfxASurface *aSurface);
|
||||
|
||||
private:
|
||||
template<class ShmemAllocator, bool Unsafe>
|
||||
bool Init(ShmemAllocator *aAllocator,
|
||||
const gfxIntSize& aSize,
|
||||
gfxImageFormat aFormat,
|
||||
SharedMemory::SharedMemoryType aShmType)
|
||||
{
|
||||
mSize = aSize;
|
||||
mFormat = aFormat;
|
||||
mStride = ComputeStride();
|
||||
if (!Unsafe) {
|
||||
if (!aAllocator->AllocShmem(GetAlignedSize(),
|
||||
aShmType, &mShmem))
|
||||
return false;
|
||||
} else {
|
||||
if (!aAllocator->AllocUnsafeShmem(GetAlignedSize(),
|
||||
aShmType, &mShmem))
|
||||
return false;
|
||||
}
|
||||
|
||||
return InitSurface(PR_TRUE);
|
||||
}
|
||||
|
||||
size_t GetAlignedSize();
|
||||
bool InitSurface(PRBool aUpdateShmemInfo);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user