mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 959089 - Part 2: Use the new protocol to do buffer allocation. r=nical
This commit is contained in:
parent
414e3aaca9
commit
aca898b7e3
@ -29,6 +29,7 @@
|
||||
#include "mozilla/ipc/TestShellChild.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "mozilla/layers/PCompositorChild.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -688,6 +689,13 @@ ContentChild::AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
|
||||
return CompositorChild::Create(aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
PSharedBufferManagerChild*
|
||||
ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
{
|
||||
return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
PImageBridgeChild*
|
||||
ContentChild::AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
|
@ -89,6 +89,11 @@ public:
|
||||
PCompositorChild*
|
||||
AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
||||
PSharedBufferManagerChild*
|
||||
AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
||||
PImageBridgeChild*
|
||||
AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
@ -1595,6 +1596,10 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
DebugOnly<bool> opened = PSharedBufferManager::Open(this);
|
||||
MOZ_ASSERT(opened);
|
||||
#endif
|
||||
|
||||
if (aSendRegisteredChrome) {
|
||||
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
||||
@ -2192,6 +2197,13 @@ ContentParent::AllocPBackgroundParent(Transport* aTransport,
|
||||
return BackgroundParent::Alloc(this, aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
PSharedBufferManagerParent*
|
||||
ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
{
|
||||
return SharedBufferManagerParent::Create(aTransport, aOtherProcess);
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvGetProcessAttributes(uint64_t* aId,
|
||||
bool* aIsForApp, bool* aIsForBrowser)
|
||||
|
@ -47,6 +47,7 @@ class PJavaScriptParent;
|
||||
|
||||
namespace layers {
|
||||
class PCompositorParent;
|
||||
class PSharedBufferManagerParent;
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
@ -327,6 +328,9 @@ private:
|
||||
AllocPImageBridgeParent(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
||||
PSharedBufferManagerParent*
|
||||
AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
PBackgroundParent*
|
||||
AllocPBackgroundParent(Transport* aTransport, ProcessId aOtherProcess)
|
||||
MOZ_OVERRIDE;
|
||||
|
@ -21,6 +21,7 @@ include protocol PImageBridge;
|
||||
include protocol PIndexedDB;
|
||||
include protocol PMemoryReportRequest;
|
||||
include protocol PNecko;
|
||||
include protocol PSharedBufferManager;
|
||||
include protocol PSms;
|
||||
include protocol PSpeechSynthesis;
|
||||
include protocol PStorage;
|
||||
@ -263,6 +264,7 @@ struct PrefSetting {
|
||||
intr protocol PContent
|
||||
{
|
||||
parent opens PCompositor;
|
||||
parent opens PSharedBufferManager;
|
||||
parent opens PImageBridge;
|
||||
child opens PBackground;
|
||||
|
||||
|
@ -81,6 +81,10 @@ public:
|
||||
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS = 0x7FA30C04,
|
||||
};
|
||||
|
||||
enum {
|
||||
GRALLOC_SW_UAGE = android::GraphicBuffer::USAGE_SOFTWARE_MASK,
|
||||
};
|
||||
|
||||
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
|
||||
|
||||
android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
|
||||
@ -98,6 +102,11 @@ public:
|
||||
return static_cast<uint8_t*>(GetNativeBuffer());
|
||||
}
|
||||
|
||||
int GetUsage()
|
||||
{
|
||||
return (static_cast<ANativeWindowBuffer*>(GetNativeBuffer()))->usage;
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<GrallocTextureClientOGL> mTextureClient;
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/ContentHost.h" // for ContentHostBase
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/Atomics.h" // for PrimitiveIntrinsics
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "ShadowLayerUtils.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete[], etc
|
||||
#include "nsAutoPtr.h" // for nsRefPtr, getter_AddRefs, etc
|
||||
@ -308,5 +309,20 @@ ISurfaceAllocator::ShrinkShmemSectionHeap()
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ISurfaceAllocator::AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat,
|
||||
uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
return SharedBufferManagerChild::GetSingleton()->AllocGrallocBuffer(aSize, aFormat, aUsage, aHandle);
|
||||
}
|
||||
|
||||
void
|
||||
ISurfaceAllocator::DeallocGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
SharedBufferManagerChild::GetSingleton()->DeallocGrallocBuffer(*aHandle);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -46,7 +46,6 @@ class DataSourceSurface;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class PGrallocBufferChild;
|
||||
class MaybeMagicGrallocBufferHandle;
|
||||
class MemoryTextureClient;
|
||||
class MemoryTextureHost;
|
||||
@ -155,18 +154,12 @@ public:
|
||||
virtual void DestroySharedSurface(SurfaceDescriptor* aSurface);
|
||||
|
||||
// method that does the actual allocation work
|
||||
virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
bool AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat,
|
||||
uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
MaybeMagicGrallocBufferHandle* aHandle);
|
||||
|
||||
virtual void DeallocGrallocBuffer(PGrallocBufferChild* aChild)
|
||||
{
|
||||
NS_RUNTIMEABORT("should not be called");
|
||||
}
|
||||
void DeallocGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle);
|
||||
|
||||
virtual bool IPCOpen() const { return true; }
|
||||
virtual bool IsSameProcess() const = 0;
|
||||
|
@ -52,7 +52,6 @@ class Shmem;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class PGrallocBufferChild;
|
||||
typedef std::vector<CompositableOperation> OpVector;
|
||||
|
||||
struct CompositableTransaction
|
||||
@ -204,44 +203,6 @@ static void CreateImageClientSync(RefPtr<ImageClient>* result,
|
||||
barrier->NotifyAll();
|
||||
}
|
||||
|
||||
|
||||
struct GrallocParam {
|
||||
IntSize size;
|
||||
uint32_t format;
|
||||
uint32_t usage;
|
||||
MaybeMagicGrallocBufferHandle* handle;
|
||||
PGrallocBufferChild** child;
|
||||
|
||||
GrallocParam(const IntSize& aSize,
|
||||
const uint32_t& aFormat,
|
||||
const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle,
|
||||
PGrallocBufferChild** aChild)
|
||||
: size(aSize)
|
||||
, format(aFormat)
|
||||
, usage(aUsage)
|
||||
, handle(aHandle)
|
||||
, child(aChild)
|
||||
{}
|
||||
};
|
||||
|
||||
// dispatched function
|
||||
static void AllocGrallocBufferSync(const GrallocParam& aParam,
|
||||
Monitor* aBarrier,
|
||||
bool* aDone)
|
||||
{
|
||||
MonitorAutoLock autoMon(*aBarrier);
|
||||
|
||||
sImageBridgeChildSingleton->AllocGrallocBufferNow(aParam.size,
|
||||
aParam.format,
|
||||
aParam.usage,
|
||||
aParam.handle,
|
||||
aParam.child);
|
||||
*aDone = true;
|
||||
aBarrier->NotifyAll();
|
||||
}
|
||||
|
||||
// dispatched function
|
||||
static void ConnectImageBridge(ImageBridgeChild * child, ImageBridgeParent * parent)
|
||||
{
|
||||
MessageLoop *parentMsgLoop = parent->GetMessageLoop();
|
||||
@ -655,30 +616,6 @@ ImageBridgeChild::CreateImageClientNow(CompositableType aType)
|
||||
return client.forget();
|
||||
}
|
||||
|
||||
PGrallocBufferChild*
|
||||
ImageBridgeChild::AllocPGrallocBufferChild(const IntSize&, const uint32_t&, const uint32_t&,
|
||||
MaybeMagicGrallocBufferHandle*)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
return GrallocBufferActor::Create();
|
||||
#else
|
||||
NS_RUNTIMEABORT("No gralloc buffers for you");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
delete actor;
|
||||
return true;
|
||||
#else
|
||||
NS_RUNTIMEABORT("Um, how did we get here?");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeChild::AllocUnsafeShmem(size_t aSize,
|
||||
ipc::SharedMemory::SharedMemoryType aType,
|
||||
@ -800,99 +737,6 @@ ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
|
||||
}
|
||||
}
|
||||
|
||||
PGrallocBufferChild*
|
||||
ImageBridgeChild::AllocGrallocBuffer(const IntSize& aSize,
|
||||
uint32_t aFormat,
|
||||
uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
if (InImageBridgeChildThread()) {
|
||||
PGrallocBufferChild* child = nullptr;
|
||||
ImageBridgeChild::AllocGrallocBufferNow(aSize, aFormat, aUsage, aHandle, &child);
|
||||
return child;
|
||||
}
|
||||
|
||||
Monitor barrier("AllocGrallocBuffer Lock");
|
||||
MonitorAutoLock autoMon(barrier);
|
||||
bool done = false;
|
||||
PGrallocBufferChild* child = nullptr;
|
||||
|
||||
GetMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&AllocGrallocBufferSync,
|
||||
GrallocParam(aSize, aFormat, aUsage, aHandle, &child), &barrier, &done));
|
||||
|
||||
while (!done) {
|
||||
barrier.Wait();
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::AllocGrallocBufferNow(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat, uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle,
|
||||
PGrallocBufferChild** aChild)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
*aChild = SendPGrallocBufferConstructor(aSize,
|
||||
aFormat,
|
||||
aUsage,
|
||||
aHandle);
|
||||
#else
|
||||
NS_RUNTIMEABORT("not implemented");
|
||||
aChild = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ProxyDeallocGrallocBufferNow(ISurfaceAllocator* aAllocator,
|
||||
PGrallocBufferChild* aChild,
|
||||
ReentrantMonitor* aBarrier,
|
||||
bool* aDone)
|
||||
{
|
||||
MOZ_ASSERT(aChild);
|
||||
MOZ_ASSERT(aDone);
|
||||
MOZ_ASSERT(aBarrier);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
PGrallocBufferChild::Send__delete__(aChild);
|
||||
#else
|
||||
NS_RUNTIMEABORT("not implemented");
|
||||
#endif
|
||||
|
||||
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
||||
*aDone = true;
|
||||
aBarrier->NotifyAll();
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::DeallocGrallocBuffer(PGrallocBufferChild* aChild)
|
||||
{
|
||||
MOZ_ASSERT(aChild);
|
||||
if (InImageBridgeChildThread()) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
PGrallocBufferChild::Send__delete__(aChild);
|
||||
#else
|
||||
NS_RUNTIMEABORT("not implemented");
|
||||
#endif
|
||||
} else {
|
||||
ReentrantMonitor barrier("AllocatorProxy Dealloc");
|
||||
ReentrantMonitorAutoEnter autoMon(barrier);
|
||||
|
||||
bool done = false;
|
||||
GetMessageLoop()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(&ProxyDeallocGrallocBufferNow,
|
||||
this,
|
||||
aChild,
|
||||
&barrier,
|
||||
&done));
|
||||
while (!done) {
|
||||
barrier.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
ImageBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
||||
const TextureFlags&)
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureIdentifier, etc
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferChild
|
||||
#include "mozilla/layers/PImageBridgeChild.h"
|
||||
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
@ -187,13 +186,6 @@ public:
|
||||
*/
|
||||
~ImageBridgeChild();
|
||||
|
||||
virtual PGrallocBufferChild*
|
||||
AllocPGrallocBufferChild(const gfx::IntSize&, const uint32_t&, const uint32_t&,
|
||||
MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTextureChild*
|
||||
AllocPTextureChild(const SurfaceDescriptor& aSharedData, const TextureFlags& aFlags) MOZ_OVERRIDE;
|
||||
|
||||
@ -310,10 +302,6 @@ public:
|
||||
|
||||
virtual bool IsSameProcess() const MOZ_OVERRIDE;
|
||||
|
||||
void AllocGrallocBufferNow(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat, uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle,
|
||||
PGrallocBufferChild** aChild);
|
||||
protected:
|
||||
ImageBridgeChild();
|
||||
bool DispatchAllocShmemInternal(size_t aSize,
|
||||
@ -322,13 +310,6 @@ protected:
|
||||
bool aUnsafe);
|
||||
|
||||
CompositableTransaction* mTxn;
|
||||
|
||||
// ISurfaceAllocator
|
||||
virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat, uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle) MOZ_OVERRIDE;
|
||||
|
||||
virtual void DeallocGrallocBuffer(PGrallocBufferChild* aChild) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // layers
|
||||
|
@ -40,8 +40,6 @@ using namespace mozilla::gfx;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class PGrallocBufferParent;
|
||||
|
||||
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport)
|
||||
: mMessageLoop(aLoop)
|
||||
, mTransport(aTransport)
|
||||
@ -161,32 +159,6 @@ static uint64_t GenImageContainerID() {
|
||||
return sNextImageID;
|
||||
}
|
||||
|
||||
PGrallocBufferParent*
|
||||
ImageBridgeParent::AllocPGrallocBufferParent(const IntSize& aSize,
|
||||
const uint32_t& aFormat,
|
||||
const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aOutHandle)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
return GrallocBufferActor::Create(aSize, aFormat, aUsage, aOutHandle);
|
||||
#else
|
||||
NS_RUNTIMEABORT("No gralloc buffers for you");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeParent::DeallocPGrallocBufferParent(PGrallocBufferParent* actor)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
delete actor;
|
||||
return true;
|
||||
#else
|
||||
NS_RUNTIMEABORT("Um, how did we get here?");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
PCompositableParent*
|
||||
ImageBridgeParent::AllocPCompositableParent(const TextureInfo& aInfo,
|
||||
uint64_t* aID)
|
||||
|
@ -20,6 +20,10 @@
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
class Shmem;
|
||||
@ -49,13 +53,6 @@ public:
|
||||
static PImageBridgeParent*
|
||||
Create(Transport* aTransport, ProcessId aOtherProcess);
|
||||
|
||||
virtual PGrallocBufferParent*
|
||||
AllocPGrallocBufferParent(const IntSize&, const uint32_t&, const uint32_t&,
|
||||
MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
// PImageBridge
|
||||
virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply) MOZ_OVERRIDE;
|
||||
virtual bool RecvUpdateNoSwap(const EditArray& aEdits) MOZ_OVERRIDE;
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "LayerTransactionChild.h"
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableChild
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferChild
|
||||
#include "mozilla/layers/PCompositableChild.h" // for PCompositableChild
|
||||
#include "mozilla/layers/PLayerChild.h" // for PLayerChild
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
@ -18,7 +17,6 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class PGrallocBufferChild;
|
||||
|
||||
void
|
||||
LayerTransactionChild::Destroy()
|
||||
@ -29,31 +27,6 @@ LayerTransactionChild::Destroy()
|
||||
// WARNING: |this| has gone to the great heap in the sky
|
||||
}
|
||||
|
||||
PGrallocBufferChild*
|
||||
LayerTransactionChild::AllocPGrallocBufferChild(const IntSize&,
|
||||
const uint32_t&,
|
||||
const uint32_t&,
|
||||
MaybeMagicGrallocBufferHandle*)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
return GrallocBufferActor::Create();
|
||||
#else
|
||||
NS_RUNTIMEABORT("No gralloc buffers for you");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
LayerTransactionChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
delete actor;
|
||||
return true;
|
||||
#else
|
||||
NS_RUNTIMEABORT("Um, how did we get here?");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
PLayerChild*
|
||||
LayerTransactionChild::AllocPLayerChild()
|
||||
|
@ -43,13 +43,6 @@ protected:
|
||||
{}
|
||||
~LayerTransactionChild() { }
|
||||
|
||||
virtual PGrallocBufferChild*
|
||||
AllocPGrallocBufferChild(const IntSize&,
|
||||
const uint32_t&, const uint32_t&,
|
||||
MaybeMagicGrallocBufferHandle*) MOZ_OVERRIDE;
|
||||
virtual bool
|
||||
DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PLayerChild* AllocPLayerChild() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPLayerChild(PLayerChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -740,33 +740,6 @@ LayerTransactionParent::RecvForceComposite()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PGrallocBufferParent*
|
||||
LayerTransactionParent::AllocPGrallocBufferParent(const IntSize& aSize,
|
||||
const uint32_t& aFormat,
|
||||
const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aOutHandle)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
return GrallocBufferActor::Create(aSize, aFormat, aUsage, aOutHandle);
|
||||
#else
|
||||
NS_RUNTIMEABORT("No gralloc buffers for you");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
LayerTransactionParent::DeallocPGrallocBufferParent(PGrallocBufferParent* actor)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
delete actor;
|
||||
return true;
|
||||
#else
|
||||
NS_RUNTIMEABORT("Um, how did we get here?");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
PLayerParent*
|
||||
LayerTransactionParent::AllocPLayerParent()
|
||||
{
|
||||
|
@ -103,13 +103,6 @@ protected:
|
||||
virtual bool RecvSetAsyncScrollOffset(PLayerParent* aLayer,
|
||||
const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE;
|
||||
|
||||
virtual PGrallocBufferParent*
|
||||
AllocPGrallocBufferParent(const IntSize& aSize,
|
||||
const uint32_t& aFormat, const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aOutHandle) MOZ_OVERRIDE;
|
||||
virtual bool
|
||||
DeallocPGrallocBufferParent(PGrallocBufferParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PLayerParent* AllocPLayerParent() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPLayerParent(PLayerParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
include LayersSurfaces;
|
||||
include protocol PCompositable;
|
||||
include protocol PCompositor;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PLayer;
|
||||
include protocol PRenderFrame;
|
||||
include protocol PTexture;
|
||||
|
@ -2,14 +2,12 @@
|
||||
* 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 protocol PGrallocBuffer;
|
||||
|
||||
|
||||
using struct gfxPoint from "gfxPoint.h";
|
||||
using struct nsIntRect from "nsRect.h";
|
||||
using nsIntRegion from "nsRegion.h";
|
||||
using struct nsIntSize from "nsSize.h";
|
||||
using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h";
|
||||
using struct mozilla::layers::GrallocBufferRef from "gfxipc/ShadowLayerUtils.h";
|
||||
using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
|
||||
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
|
||||
@ -25,6 +23,7 @@ namespace layers {
|
||||
|
||||
union MaybeMagicGrallocBufferHandle {
|
||||
MagicGrallocBufferHandle;
|
||||
GrallocBufferRef;
|
||||
null_t;
|
||||
};
|
||||
|
||||
@ -58,7 +57,7 @@ struct SharedTextureDescriptor {
|
||||
};
|
||||
|
||||
struct NewSurfaceDescriptorGralloc {
|
||||
PGrallocBuffer buffer;
|
||||
MaybeMagicGrallocBufferHandle buffer;
|
||||
/**
|
||||
* android::GraphicBuffer has a size information. But there are cases
|
||||
* that GraphicBuffer's size and actual video's size are different.
|
||||
|
@ -6,7 +6,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include LayersSurfaces;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PLayerTransaction;
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
include "nsRegion.h";
|
||||
|
@ -1,30 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=8 et :
|
||||
*/
|
||||
/* 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 protocol PCompositor;
|
||||
include protocol PImageBridge;
|
||||
include protocol PLayerTransaction;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* This is a trivial protocol that's used to track gralloc buffers
|
||||
* across thread contexts. A live PGrallocBuffer actor always
|
||||
* corresponds 1:1 to a pre-shared gralloc buffer (sharing is done by
|
||||
* the PGrallocBuffer constructor).
|
||||
*/
|
||||
async protocol PGrallocBuffer {
|
||||
manager PImageBridge or PLayerTransaction;
|
||||
|
||||
/** Gralloc buffers can be "owned" by either parent or child. */
|
||||
both:
|
||||
async __delete__();
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
@ -5,8 +5,8 @@
|
||||
|
||||
include LayersSurfaces;
|
||||
include LayersMessages;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PCompositable;
|
||||
include protocol PLayer;
|
||||
include protocol PTexture;
|
||||
include ProtocolTypes;
|
||||
|
||||
@ -26,7 +26,6 @@ namespace layers {
|
||||
intr protocol PImageBridge
|
||||
{
|
||||
manages PCompositable;
|
||||
manages PGrallocBuffer;
|
||||
manages PTexture;
|
||||
|
||||
parent:
|
||||
@ -34,14 +33,6 @@ parent:
|
||||
sync Update(CompositableOperation[] ops) returns (EditReply[] reply);
|
||||
async UpdateNoSwap(CompositableOperation[] ops);
|
||||
|
||||
// Allocates a gralloc buffer that may not suitable to use with
|
||||
// gfxImageSurface but allows hardware decoder to write to the
|
||||
// buffer directly. The format is a enum defined in
|
||||
// system/graphics.h and the usage is the GraphicBuffer usage
|
||||
// flag. See GraphicBuffer.h and gralloc.h.
|
||||
sync PGrallocBuffer(IntSize size, uint32_t format, uint32_t usage)
|
||||
returns (MaybeMagicGrallocBufferHandle handle);
|
||||
|
||||
// First step of the destruction sequence. This puts all the ImageContainerParents
|
||||
// in a state in which they can't send asynchronous messages to their child
|
||||
// counterpart so as to not race with the upcomming __delete__ message.
|
||||
|
@ -9,7 +9,6 @@ include LayersSurfaces;
|
||||
include LayersMessages;
|
||||
include protocol PCompositable;
|
||||
include protocol PCompositor;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PLayer;
|
||||
include protocol PRenderFrame;
|
||||
include protocol PTexture;
|
||||
@ -40,39 +39,9 @@ sync protocol PLayerTransaction {
|
||||
manager PRenderFrame or PCompositor;
|
||||
manages PLayer;
|
||||
manages PCompositable;
|
||||
manages PGrallocBuffer;
|
||||
manages PTexture;
|
||||
|
||||
parent:
|
||||
/**
|
||||
* Only the parent side has privileges to allocate the buffer.
|
||||
* Allocation may fail (pmem is a scarce resource), and if so null_t
|
||||
* is returned.
|
||||
*
|
||||
* |format| is an Android PixelFormat (see PixelFormat.h)
|
||||
*
|
||||
* commonly used PixelFormats are:
|
||||
* PIXEL_FORMAT_RGBA_8888
|
||||
* PIXEL_FORMAT_RGBX_8888
|
||||
* PIXEL_FORMAT_BGRA_8888
|
||||
*
|
||||
* Note that SurfaceDescriptorGralloc has a "isRBSwapped" boolean
|
||||
* that can treat the R/B bytes as swapped when they are rendered
|
||||
* to the screen, to help with matching the native pixel format
|
||||
* of other rendering engines.
|
||||
*
|
||||
* |usage| is a USAGE_* mask (see GraphicBuffer.h)
|
||||
*
|
||||
* commonly used USAGE flags are:
|
||||
* USAGE_SW_READ_OFTEN | USAGE_SW_WRITE_OFTEN | USAGE_HW_TEXTURE
|
||||
* - used for software rendering to a buffer which the compositor
|
||||
* treats as a texture
|
||||
* USAGE_HW_RENDER | USAGE_HW_TEXTURE
|
||||
* - used for GL rendering to a buffer which the compositor
|
||||
* treats as a texture
|
||||
*/
|
||||
sync PGrallocBuffer(IntSize size, uint32_t format, uint32_t usage)
|
||||
returns (MaybeMagicGrallocBufferHandle handle);
|
||||
async PLayer();
|
||||
async PCompositable(TextureInfo aTextureInfo);
|
||||
async PTexture(SurfaceDescriptor aSharedData, TextureFlags aTextureFlags);
|
||||
|
@ -8,7 +8,6 @@
|
||||
include LayersSurfaces;
|
||||
include protocol PLayerTransaction;
|
||||
include protocol PImageBridge;
|
||||
include protocol PGrallocBuffer;
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
|
||||
|
@ -38,6 +38,10 @@ namespace mozilla { namespace layers {
|
||||
struct MagicGrallocBufferHandle {
|
||||
bool operator==(const MagicGrallocBufferHandle&) const { return false; }
|
||||
};
|
||||
|
||||
struct GrallocBufferRef {
|
||||
bool operator==(const GrallocBufferRef&) const { return false; }
|
||||
};
|
||||
} }
|
||||
#endif
|
||||
|
||||
@ -82,6 +86,13 @@ struct ParamTraits<mozilla::layers::MagicGrallocBufferHandle> {
|
||||
static void Write(Message*, const paramType&) {}
|
||||
static bool Read(const Message*, void**, paramType*) { return false; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::GrallocBufferRef> {
|
||||
typedef mozilla::layers::GrallocBufferRef paramType;
|
||||
static void Write(Message*, const paramType&) {}
|
||||
static bool Read(const Message*, void**, paramType*) { return false; }
|
||||
};
|
||||
#endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORGRALLOC)
|
||||
|
||||
template <>
|
||||
|
@ -8,13 +8,13 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/layers/PGrallocBufferChild.h"
|
||||
#include "mozilla/layers/PGrallocBufferParent.h"
|
||||
#include "mozilla/layers/LayerTransactionChild.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
@ -39,6 +39,28 @@ using namespace mozilla::gl;
|
||||
|
||||
namespace IPC {
|
||||
|
||||
void
|
||||
ParamTraits<GrallocBufferRef>::Write(Message* aMsg,
|
||||
const paramType& aParam)
|
||||
{
|
||||
aMsg->WriteInt(aParam.mOwner);
|
||||
aMsg->WriteInt32(aParam.mKey);
|
||||
}
|
||||
|
||||
bool
|
||||
ParamTraits<GrallocBufferRef>::Read(const Message* aMsg, void** aIter,
|
||||
paramType* aParam)
|
||||
{
|
||||
int owner;
|
||||
int index;
|
||||
if (!aMsg->ReadInt(aIter, &owner) ||
|
||||
!aMsg->ReadInt32(aIter, &index))
|
||||
return false;
|
||||
aParam->mOwner = owner;
|
||||
aParam->mKey = index;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ParamTraits<MagicGrallocBufferHandle>::Write(Message* aMsg,
|
||||
const paramType& aParam)
|
||||
@ -70,7 +92,8 @@ ParamTraits<MagicGrallocBufferHandle>::Write(Message* aMsg,
|
||||
#else
|
||||
flattenable->flatten(data, nbytes, fds, nfds);
|
||||
#endif
|
||||
|
||||
aMsg->WriteInt(aParam.mRef.mOwner);
|
||||
aMsg->WriteInt32(aParam.mRef.mKey);
|
||||
aMsg->WriteSize(nbytes);
|
||||
aMsg->WriteSize(nfds);
|
||||
|
||||
@ -90,15 +113,19 @@ ParamTraits<MagicGrallocBufferHandle>::Read(const Message* aMsg,
|
||||
size_t nbytes;
|
||||
size_t nfds;
|
||||
const char* data;
|
||||
int owner;
|
||||
int index;
|
||||
|
||||
if (!aMsg->ReadSize(aIter, &nbytes) ||
|
||||
if (!aMsg->ReadInt(aIter, &owner) ||
|
||||
!aMsg->ReadInt32(aIter, &index) ||
|
||||
!aMsg->ReadSize(aIter, &nbytes) ||
|
||||
!aMsg->ReadSize(aIter, &nfds) ||
|
||||
!aMsg->ReadBytes(aIter, &data, nbytes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int fds[nfds];
|
||||
|
||||
bool sameProcess = (XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
FileDescriptor fd;
|
||||
if (!aMsg->ReadFileDescriptor(aIter, &fd)) {
|
||||
@ -109,36 +136,51 @@ ParamTraits<MagicGrallocBufferHandle>::Read(const Message* aMsg,
|
||||
// SCM_RIGHTS doesn't dup the fd. That's surprising, but we just
|
||||
// deal with it here. NB: only the "default" (master) process can
|
||||
// alloc gralloc buffers.
|
||||
bool sameProcess = (XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
int dupFd = sameProcess ? dup(fd.fd) : fd.fd;
|
||||
int dupFd = sameProcess && index < 0 ? dup(fd.fd) : fd.fd;
|
||||
fds[n] = dupFd;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> buffer(new GraphicBuffer());
|
||||
aResult->mRef.mOwner = owner;
|
||||
aResult->mRef.mKey = index;
|
||||
if (sameProcess)
|
||||
aResult->mGraphicBuffer = SharedBufferManagerParent::GetGraphicBuffer(aResult->mRef);
|
||||
else {
|
||||
aResult->mGraphicBuffer = SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(index);
|
||||
if (index >= 0 && aResult->mGraphicBuffer == nullptr) {
|
||||
//Only newly created GraphicBuffer should deserialize
|
||||
#if ANDROID_VERSION >= 19
|
||||
// Make a copy of "data" and "fds" for unflatten() to avoid casting problem
|
||||
void const *pdata = (void const *)data;
|
||||
int const *pfds = fds;
|
||||
|
||||
if (NO_ERROR == buffer->unflatten(pdata, nbytes, pfds, nfds)) {
|
||||
sp<GraphicBuffer> flattenable(new GraphicBuffer());
|
||||
const void* datap = (const void*)data;
|
||||
const int* fdsp = &fds[0];
|
||||
if (NO_ERROR == flattenable->unflatten(datap, nbytes, fdsp, nfds)) {
|
||||
aResult->mGraphicBuffer = flattenable;
|
||||
}
|
||||
#else
|
||||
sp<GraphicBuffer> buffer(new GraphicBuffer());
|
||||
Flattenable *flattenable = buffer.get();
|
||||
|
||||
if (NO_ERROR == flattenable->unflatten(data, nbytes, fds, nfds)) {
|
||||
#endif
|
||||
aResult->mGraphicBuffer = buffer;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (aResult->mGraphicBuffer == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
MagicGrallocBufferHandle::MagicGrallocBufferHandle(const sp<GraphicBuffer>& aGraphicBuffer)
|
||||
MagicGrallocBufferHandle::MagicGrallocBufferHandle(const sp<GraphicBuffer>& aGraphicBuffer, GrallocBufferRef ref)
|
||||
: mGraphicBuffer(aGraphicBuffer)
|
||||
, mRef(ref)
|
||||
{
|
||||
}
|
||||
|
||||
@ -213,122 +255,6 @@ ContentTypeFromPixelFormat(android::PixelFormat aFormat)
|
||||
return gfxASurface::ContentFromFormat(ImageFormatForPixelFormat(aFormat));
|
||||
}
|
||||
|
||||
class GrallocReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
{
|
||||
friend class GrallocBufferActor;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
GrallocReporter()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// There must be only one instance of this class, due to |sAmount|
|
||||
// being static. Assert this.
|
||||
static bool hasRun = false;
|
||||
MOZ_ASSERT(!hasRun);
|
||||
hasRun = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"gralloc", KIND_OTHER, UNITS_BYTES, sAmount,
|
||||
"Special RAM that can be shared between processes and directly accessed by "
|
||||
"both the CPU and GPU. Gralloc memory is usually a relatively precious "
|
||||
"resource, with much less available than generic RAM. When it's exhausted, "
|
||||
"graphics performance can suffer. This value can be incorrect because of race "
|
||||
"conditions.");
|
||||
}
|
||||
|
||||
private:
|
||||
static int64_t sAmount;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(GrallocReporter, nsIMemoryReporter)
|
||||
|
||||
int64_t GrallocReporter::sAmount = 0;
|
||||
|
||||
void InitGralloc() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
RegisterStrongMemoryReporter(new GrallocReporter());
|
||||
}
|
||||
|
||||
GrallocBufferActor::GrallocBufferActor()
|
||||
: mAllocBytes(0)
|
||||
, mTextureHost(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
GrallocBufferActor::~GrallocBufferActor()
|
||||
{
|
||||
if (mAllocBytes > 0) {
|
||||
GrallocReporter::sAmount -= mAllocBytes;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ PGrallocBufferParent*
|
||||
GrallocBufferActor::Create(const gfx::IntSize& aSize,
|
||||
const uint32_t& aFormat,
|
||||
const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aOutHandle)
|
||||
{
|
||||
PROFILER_LABEL("GrallocBufferActor", "Create");
|
||||
GrallocBufferActor* actor = new GrallocBufferActor();
|
||||
*aOutHandle = null_t();
|
||||
uint32_t format = aFormat;
|
||||
uint32_t usage = aUsage;
|
||||
|
||||
if (format == 0 || usage == 0) {
|
||||
printf_stderr("GrallocBufferActor::Create -- format and usage must be non-zero");
|
||||
return actor;
|
||||
}
|
||||
|
||||
// If the requested size is too big (i.e. exceeds the commonly used max GL texture size)
|
||||
// then we risk OOMing the parent process. It's better to just deny the allocation and
|
||||
// kill the child process, which is what the following code does.
|
||||
// TODO: actually use GL_MAX_TEXTURE_SIZE instead of hardcoding 4096
|
||||
if (aSize.width > 4096 || aSize.height > 4096) {
|
||||
printf_stderr("GrallocBufferActor::Create -- requested gralloc buffer is too big. Killing child instead.");
|
||||
delete actor;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> buffer(new GraphicBuffer(aSize.width, aSize.height, format, usage));
|
||||
if (buffer->initCheck() != OK)
|
||||
return actor;
|
||||
|
||||
size_t bpp = BytesPerPixelForPixelFormat(format);
|
||||
actor->mAllocBytes = aSize.width * aSize.height * bpp;
|
||||
GrallocReporter::sAmount += actor->mAllocBytes;
|
||||
|
||||
actor->mGraphicBuffer = buffer;
|
||||
*aOutHandle = MagicGrallocBufferHandle(buffer);
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
void GrallocBufferActor::ActorDestroy(ActorDestroyReason)
|
||||
{
|
||||
// Used only for hacky fix for bug 966446.
|
||||
if (mTextureHost) {
|
||||
mTextureHost->ForgetBufferActor();
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void GrallocBufferActor::AddTextureHost(TextureHost* aTextureHost)
|
||||
{
|
||||
mTextureHost = aTextureHost;
|
||||
}
|
||||
|
||||
void GrallocBufferActor::RemoveTextureHost()
|
||||
{
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
LayerManagerComposite::SupportsDirectTexturing()
|
||||
{
|
||||
@ -341,50 +267,34 @@ LayerManagerComposite::PlatformSyncBeforeReplyUpdate()
|
||||
// Nothing to be done for gralloc.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Child process
|
||||
|
||||
/*static*/ PGrallocBufferChild*
|
||||
GrallocBufferActor::Create()
|
||||
{
|
||||
return new GrallocBufferActor();
|
||||
}
|
||||
|
||||
void
|
||||
GrallocBufferActor::InitFromHandle(const MagicGrallocBufferHandle& aHandle)
|
||||
{
|
||||
MOZ_ASSERT(!mGraphicBuffer.get());
|
||||
MOZ_ASSERT(aHandle.mGraphicBuffer.get());
|
||||
|
||||
mGraphicBuffer = aHandle.mGraphicBuffer;
|
||||
}
|
||||
|
||||
PGrallocBufferChild*
|
||||
ShadowLayerForwarder::AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat,
|
||||
uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle)
|
||||
{
|
||||
if (!mShadowManager->IPCOpen()) {
|
||||
return nullptr;
|
||||
}
|
||||
return mShadowManager->SendPGrallocBufferConstructor(aSize, aFormat, aUsage, aHandle);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::DeallocGrallocBuffer(PGrallocBufferChild* aChild)
|
||||
{
|
||||
MOZ_ASSERT(aChild);
|
||||
PGrallocBufferChild::Send__delete__(aChild);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Both processes
|
||||
|
||||
android::GraphicBuffer*
|
||||
GrallocBufferActor::GetGraphicBuffer()
|
||||
/*static*/ sp<GraphicBuffer>
|
||||
GetGraphicBufferFrom(MaybeMagicGrallocBufferHandle aHandle)
|
||||
{
|
||||
return mGraphicBuffer.get();
|
||||
if (aHandle.type() != MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) {
|
||||
if (aHandle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
return SharedBufferManagerParent::GetGraphicBuffer(aHandle.get_GrallocBufferRef());
|
||||
}
|
||||
return SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(aHandle.get_GrallocBufferRef().mKey);
|
||||
}
|
||||
} else {
|
||||
MagicGrallocBufferHandle realHandle = aHandle.get_MagicGrallocBufferHandle();
|
||||
return realHandle.mGraphicBuffer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
android::sp<android::GraphicBuffer>
|
||||
GetGraphicBufferFromDesc(SurfaceDescriptor aDesc)
|
||||
{
|
||||
MaybeMagicGrallocBufferHandle handle;
|
||||
if (aDesc.type() == SurfaceDescriptor::TNewSurfaceDescriptorGralloc) {
|
||||
handle = aDesc.get_NewSurfaceDescriptorGralloc().buffer();
|
||||
}
|
||||
return GetGraphicBufferFrom(handle);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
|
@ -11,9 +11,8 @@
|
||||
#include <unistd.h>
|
||||
#include <ui/GraphicBuffer.h>
|
||||
|
||||
#include "base/process.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/layers/PGrallocBufferChild.h"
|
||||
#include "mozilla/layers/PGrallocBufferParent.h"
|
||||
|
||||
#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
#define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
|
||||
@ -22,8 +21,24 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class MaybeMagicGrallocBufferHandle;
|
||||
class SurfaceDescriptor;
|
||||
class TextureHost;
|
||||
|
||||
struct GrallocBufferRef {
|
||||
base::ProcessId mOwner;
|
||||
int mKey;
|
||||
|
||||
GrallocBufferRef()
|
||||
: mOwner(0)
|
||||
, mKey(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool operator== (const GrallocBufferRef rhs) const{
|
||||
return mOwner == rhs.mOwner && mKey == rhs.mKey;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* This class exists to share the underlying GraphicBuffer resources
|
||||
* from one thread context to another. This requires going through
|
||||
@ -34,11 +49,9 @@ class TextureHost;
|
||||
*/
|
||||
struct MagicGrallocBufferHandle {
|
||||
typedef android::GraphicBuffer GraphicBuffer;
|
||||
MagicGrallocBufferHandle() {}
|
||||
|
||||
MagicGrallocBufferHandle()
|
||||
{ }
|
||||
|
||||
MagicGrallocBufferHandle(const android::sp<GraphicBuffer>& aGraphicBuffer);
|
||||
MagicGrallocBufferHandle(const android::sp<GraphicBuffer>& aGraphicBuffer, GrallocBufferRef ref);
|
||||
|
||||
// Default copy ctor and operator= are OK
|
||||
|
||||
@ -47,58 +60,15 @@ struct MagicGrallocBufferHandle {
|
||||
}
|
||||
|
||||
android::sp<GraphicBuffer> mGraphicBuffer;
|
||||
GrallocBufferRef mRef;
|
||||
};
|
||||
|
||||
/**
|
||||
* GrallocBufferActor is an "IPC wrapper" for an underlying
|
||||
* GraphicBuffer (pmem region). It allows us to cheaply and
|
||||
* conveniently share gralloc handles between processes.
|
||||
* Util function to find GraphicBuffer from SurfaceDescriptor, caller of this function should check origin
|
||||
* to make sure not corrupt others buffer
|
||||
*/
|
||||
class GrallocBufferActor : public PGrallocBufferChild
|
||||
, public PGrallocBufferParent
|
||||
{
|
||||
friend class ShadowLayerForwarder;
|
||||
friend class LayerManagerComposite;
|
||||
friend class ImageBridgeChild;
|
||||
typedef android::GraphicBuffer GraphicBuffer;
|
||||
|
||||
public:
|
||||
virtual ~GrallocBufferActor();
|
||||
|
||||
static PGrallocBufferParent*
|
||||
Create(const gfx::IntSize& aSize,
|
||||
const uint32_t& aFormat,
|
||||
const uint32_t& aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aOutHandle);
|
||||
|
||||
static PGrallocBufferChild*
|
||||
Create();
|
||||
|
||||
// used only for hacky fix in gecko 23 for bug 862324
|
||||
// see bug 865908 about fixing this.
|
||||
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
void AddTextureHost(TextureHost* aTextureHost);
|
||||
void RemoveTextureHost();
|
||||
|
||||
android::GraphicBuffer* GetGraphicBuffer();
|
||||
|
||||
void InitFromHandle(const MagicGrallocBufferHandle& aHandle);
|
||||
|
||||
private:
|
||||
GrallocBufferActor();
|
||||
|
||||
android::sp<GraphicBuffer> mGraphicBuffer;
|
||||
|
||||
// This value stores the number of bytes allocated in this
|
||||
// BufferActor. This will be used for the memory reporter.
|
||||
size_t mAllocBytes;
|
||||
|
||||
// Used only for hacky fix for bug 966446.
|
||||
TextureHost* mTextureHost;
|
||||
|
||||
friend class ISurfaceAllocator;
|
||||
};
|
||||
android::sp<android::GraphicBuffer> GetGraphicBufferFrom(MaybeMagicGrallocBufferHandle aHandle);
|
||||
android::sp<android::GraphicBuffer> GetGraphicBufferFromDesc(SurfaceDescriptor aDesc);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
@ -113,6 +83,14 @@ struct ParamTraits<mozilla::layers::MagicGrallocBufferHandle> {
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::layers::GrallocBufferRef> {
|
||||
typedef mozilla::layers::GrallocBufferRef paramType;
|
||||
static void Write(Message* aMsg, const paramType& aParam);
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult);
|
||||
};
|
||||
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_layers_ShadowLayerUtilsGralloc_h
|
||||
|
@ -376,16 +376,6 @@ protected:
|
||||
|
||||
RefPtr<LayerTransactionChild> mShadowManager;
|
||||
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
// from ISurfaceAllocator
|
||||
virtual PGrallocBufferChild* AllocGrallocBuffer(const gfx::IntSize& aSize,
|
||||
uint32_t aFormat,
|
||||
uint32_t aUsage,
|
||||
MaybeMagicGrallocBufferHandle* aHandle) MOZ_OVERRIDE;
|
||||
|
||||
virtual void DeallocGrallocBuffer(PGrallocBufferChild* aChild) MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
Transaction* mTxn;
|
||||
|
@ -297,7 +297,7 @@ void
|
||||
SharedBufferManagerChild::DeallocGrallocBufferNow(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer)
|
||||
{
|
||||
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
NS_ASSERTION(aBuffer.type() == mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle, "We shouldn't trying to do IPC with real buffer");
|
||||
NS_ASSERTION(aBuffer.type() != mozilla::layers::MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle, "We shouldn't trying to do IPC with real buffer");
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mBufferMutex);
|
||||
|
@ -176,7 +176,7 @@ bool SharedBufferManagerParent::RecvDropGrallocBuffer(const mozilla::layers::May
|
||||
int bufferKey = handle.get_GrallocBufferRef().mKey;
|
||||
sp<GraphicBuffer> buf = GetGraphicBuffer(bufferKey);
|
||||
MutexAutoLock lock(mBuffersMutex);
|
||||
NS_ASSERTION(mBuffers.count(bufferKey) == 0, "How can you drop others buffer");
|
||||
NS_ASSERTION(mBuffers.count(bufferKey) == 1, "How can you drop others buffer");
|
||||
mBuffers.erase(bufferKey);
|
||||
|
||||
int bpp = 0;
|
||||
@ -226,7 +226,7 @@ void SharedBufferManagerParent::DropGrallocBufferImpl(mozilla::layers::SurfaceDe
|
||||
key = handle.get_MagicGrallocBufferHandle().mRef.mKey;
|
||||
|
||||
NS_ASSERTION(key != -1, "Invalid buffer key");
|
||||
NS_ASSERTION(mBuffers.count(key) == 0, "How can you drop others buffer");
|
||||
NS_ASSERTION(mBuffers.count(key) == 1, "How can you drop others buffer");
|
||||
mBuffers.erase(key);
|
||||
SendDropGrallocBuffer(handle);
|
||||
#endif
|
||||
@ -240,7 +240,7 @@ MessageLoop* SharedBufferManagerParent::GetMessageLoop()
|
||||
SharedBufferManagerParent* SharedBufferManagerParent::GetInstance(ProcessId id)
|
||||
{
|
||||
MonitorAutoLock lock(*sManagerMonitor.get());
|
||||
NS_ASSERTION(sManagers.count(id) == 0, "No BufferManager for the process");
|
||||
NS_ASSERTION(sManagers.count(id) == 1, "No BufferManager for the process");
|
||||
return sManagers[id];
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ android::sp<android::GraphicBuffer>
|
||||
SharedBufferManagerParent::GetGraphicBuffer(int key)
|
||||
{
|
||||
MutexAutoLock lock(mBuffersMutex);
|
||||
NS_ASSERTION(mBuffers.count(key) == 0, "No such buffer, or the buffer is belongs to other session");
|
||||
NS_ASSERTION(mBuffers.count(key) == 1, "No such buffer, or the buffer is belongs to other session");
|
||||
return mBuffers[key];
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,8 @@ EXPORTS.mozilla.layers += [
|
||||
'ipc/LayerTransactionParent.h',
|
||||
'ipc/ShadowLayers.h',
|
||||
'ipc/ShadowLayersManager.h',
|
||||
'ipc/SharedBufferManagerChild.h',
|
||||
'ipc/SharedBufferManagerParent.h',
|
||||
'ipc/SharedPlanarYCbCrImage.h',
|
||||
'ipc/SharedRGBImage.h',
|
||||
'LayersTypes.h',
|
||||
@ -282,6 +284,8 @@ UNIFIED_SOURCES += [
|
||||
'ipc/ShadowLayerChild.cpp',
|
||||
'ipc/ShadowLayerParent.cpp',
|
||||
'ipc/ShadowLayers.cpp',
|
||||
'ipc/SharedBufferManagerChild.cpp',
|
||||
'ipc/SharedBufferManagerParent.cpp',
|
||||
'ipc/SharedPlanarYCbCrImage.cpp',
|
||||
'ipc/SharedRGBImage.cpp',
|
||||
'LayerScope.cpp',
|
||||
@ -327,10 +331,10 @@ IPDL_SOURCES = [
|
||||
'ipc/LayersSurfaces.ipdlh',
|
||||
'ipc/PCompositable.ipdl',
|
||||
'ipc/PCompositor.ipdl',
|
||||
'ipc/PGrallocBuffer.ipdl',
|
||||
'ipc/PImageBridge.ipdl',
|
||||
'ipc/PLayer.ipdl',
|
||||
'ipc/PLayerTransaction.ipdl',
|
||||
'ipc/PSharedBufferManager.ipdl',
|
||||
'ipc/PTexture.ipdl',
|
||||
]
|
||||
|
||||
|
@ -20,8 +20,8 @@ using namespace android;
|
||||
|
||||
class GrallocTextureClientData : public TextureClientData {
|
||||
public:
|
||||
GrallocTextureClientData(GrallocBufferActor* aActor)
|
||||
: mGrallocActor(aActor)
|
||||
GrallocTextureClientData(MaybeMagicGrallocBufferHandle aDesc)
|
||||
: mGrallocHandle(aDesc)
|
||||
{
|
||||
MOZ_COUNT_CTOR(GrallocTextureClientData);
|
||||
}
|
||||
@ -29,37 +29,34 @@ public:
|
||||
~GrallocTextureClientData()
|
||||
{
|
||||
MOZ_COUNT_DTOR(GrallocTextureClientData);
|
||||
MOZ_ASSERT(!mGrallocActor);
|
||||
}
|
||||
|
||||
virtual void DeallocateSharedData(ISurfaceAllocator* allocator) MOZ_OVERRIDE
|
||||
{
|
||||
allocator->DeallocGrallocBuffer(mGrallocActor);
|
||||
mGrallocActor = nullptr;
|
||||
allocator->DeallocGrallocBuffer(&mGrallocHandle);
|
||||
}
|
||||
|
||||
private:
|
||||
GrallocBufferActor* mGrallocActor;
|
||||
MaybeMagicGrallocBufferHandle mGrallocHandle;
|
||||
};
|
||||
|
||||
TextureClientData*
|
||||
GrallocTextureClientOGL::DropTextureData()
|
||||
{
|
||||
TextureClientData* result = new GrallocTextureClientData(mGrallocActor);
|
||||
mGrallocActor = nullptr;
|
||||
mGraphicBuffer = nullptr;
|
||||
TextureClientData* result = new GrallocTextureClientData(mGrallocHandle);
|
||||
return result;
|
||||
}
|
||||
|
||||
GrallocTextureClientOGL::GrallocTextureClientOGL(GrallocBufferActor* aActor,
|
||||
GrallocTextureClientOGL::GrallocTextureClientOGL(MaybeMagicGrallocBufferHandle buffer,
|
||||
gfx::IntSize aSize,
|
||||
gfx::BackendType aMoz2dBackend,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureClient(nullptr, gfx::SurfaceFormat::UNKNOWN, aMoz2dBackend, aFlags)
|
||||
, mGrallocHandle(buffer)
|
||||
, mMappedBuffer(nullptr)
|
||||
, mMediaBuffer(nullptr)
|
||||
{
|
||||
InitWith(aActor, aSize);
|
||||
InitWith(buffer, aSize);
|
||||
MOZ_COUNT_CTOR(GrallocTextureClientOGL);
|
||||
}
|
||||
|
||||
@ -79,18 +76,17 @@ GrallocTextureClientOGL::~GrallocTextureClientOGL()
|
||||
MOZ_COUNT_DTOR(GrallocTextureClientOGL);
|
||||
if (ShouldDeallocateInDestructor()) {
|
||||
ISurfaceAllocator* allocator = GetAllocator();
|
||||
allocator->DeallocGrallocBuffer(mGrallocActor);
|
||||
allocator->DeallocGrallocBuffer(&mGrallocHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GrallocTextureClientOGL::InitWith(GrallocBufferActor* aActor, gfx::IntSize aSize)
|
||||
GrallocTextureClientOGL::InitWith(MaybeMagicGrallocBufferHandle aHandle, gfx::IntSize aSize)
|
||||
{
|
||||
MOZ_ASSERT(aActor);
|
||||
MOZ_ASSERT(!IsAllocated());
|
||||
MOZ_ASSERT(IsValid());
|
||||
mGrallocActor = aActor;
|
||||
mGraphicBuffer = aActor->GetGraphicBuffer();
|
||||
mGrallocHandle = aHandle;
|
||||
mGraphicBuffer = GetGraphicBufferFrom(aHandle);
|
||||
mSize = aSize;
|
||||
}
|
||||
|
||||
@ -102,7 +98,7 @@ GrallocTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||
return false;
|
||||
}
|
||||
|
||||
aOutDescriptor = NewSurfaceDescriptorGralloc(nullptr, mGrallocActor, mSize);
|
||||
aOutDescriptor = NewSurfaceDescriptorGralloc(mGrallocHandle, mSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -305,18 +301,16 @@ GrallocTextureClientOGL::AllocateGralloc(gfx::IntSize aSize,
|
||||
ISurfaceAllocator* allocator = GetAllocator();
|
||||
|
||||
MaybeMagicGrallocBufferHandle handle;
|
||||
PGrallocBufferChild* actor =
|
||||
bool allocateResult =
|
||||
allocator->AllocGrallocBuffer(aSize,
|
||||
aAndroidFormat,
|
||||
aUsage,
|
||||
&handle);
|
||||
if (!actor) {
|
||||
if (!allocateResult) {
|
||||
return false;
|
||||
}
|
||||
GrallocBufferActor* gba = static_cast<GrallocBufferActor*>(actor);
|
||||
gba->InitFromHandle(handle.get_MagicGrallocBufferHandle());
|
||||
|
||||
sp<GraphicBuffer> graphicBuffer = gba->GetGraphicBuffer();
|
||||
sp<GraphicBuffer> graphicBuffer = GetGraphicBufferFrom(handle);
|
||||
if (!graphicBuffer.get()) {
|
||||
return false;
|
||||
}
|
||||
@ -325,7 +319,7 @@ GrallocTextureClientOGL::AllocateGralloc(gfx::IntSize aSize,
|
||||
return false;
|
||||
}
|
||||
|
||||
mGrallocActor = gba;
|
||||
mGrallocHandle = handle;
|
||||
mGraphicBuffer = graphicBuffer;
|
||||
mSize = aSize;
|
||||
return true;
|
||||
|
@ -37,7 +37,7 @@ namespace layers {
|
||||
class GrallocTextureClientOGL : public BufferTextureClient
|
||||
{
|
||||
public:
|
||||
GrallocTextureClientOGL(GrallocBufferActor* aActor,
|
||||
GrallocTextureClientOGL(MaybeMagicGrallocBufferHandle buffer,
|
||||
gfx::IntSize aSize,
|
||||
gfx::BackendType aMoz2dBackend,
|
||||
TextureFlags aFlags = TextureFlags::DEFAULT);
|
||||
@ -66,7 +66,7 @@ public:
|
||||
|
||||
virtual void WaitReleaseFence() MOZ_OVERRIDE;
|
||||
|
||||
void InitWith(GrallocBufferActor* aActor, gfx::IntSize aSize);
|
||||
void InitWith(MaybeMagicGrallocBufferHandle aDesc, gfx::IntSize aSize);
|
||||
|
||||
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }
|
||||
|
||||
@ -120,7 +120,7 @@ protected:
|
||||
/**
|
||||
* Unfortunately, until bug 879681 is fixed we need to use a GrallocBufferActor.
|
||||
*/
|
||||
GrallocBufferActor* mGrallocActor;
|
||||
MaybeMagicGrallocBufferHandle mGrallocHandle;
|
||||
|
||||
android::sp<android::GraphicBuffer> mGraphicBuffer;
|
||||
|
||||
|
@ -3,12 +3,14 @@
|
||||
* 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 "base/process.h"
|
||||
#include "GLContext.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include "GrallocImages.h" // for GrallocImage
|
||||
#include "mozilla/layers/GrallocTextureHost.h"
|
||||
#include "mozilla/layers/CompositorOGL.h"
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "EGLImageHelpers.h"
|
||||
#include "GLReadTexImageHelper.h"
|
||||
|
||||
@ -276,23 +278,18 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
|
||||
const NewSurfaceDescriptorGralloc& aDescriptor)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
android::GraphicBuffer* graphicBuffer = nullptr;
|
||||
gfx::SurfaceFormat format = gfx::SurfaceFormat::UNKNOWN;
|
||||
mGrallocHandle = aDescriptor;
|
||||
|
||||
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
|
||||
if (!graphicBuffer) {
|
||||
NS_RUNTIMEABORT("Invalid SurfaceDescriptor passed in");
|
||||
}
|
||||
|
||||
mSize = aDescriptor.size();
|
||||
mGrallocActor =
|
||||
static_cast<GrallocBufferActor*>(aDescriptor.bufferParent());
|
||||
|
||||
if (mGrallocActor) {
|
||||
mGrallocActor->AddTextureHost(this);
|
||||
graphicBuffer = mGrallocActor->GetGraphicBuffer();
|
||||
}
|
||||
|
||||
if (graphicBuffer) {
|
||||
format =
|
||||
gfx::SurfaceFormat format =
|
||||
SurfaceFormatForAndroidPixelFormat(graphicBuffer->getPixelFormat(),
|
||||
aFlags);
|
||||
}
|
||||
aFlags & TextureFlags::RB_SWAPPED);
|
||||
|
||||
mTextureSource = new GrallocTextureSourceOGL(nullptr,
|
||||
graphicBuffer,
|
||||
format);
|
||||
@ -301,10 +298,6 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
|
||||
GrallocTextureHostOGL::~GrallocTextureHostOGL()
|
||||
{
|
||||
mTextureSource = nullptr;
|
||||
if (mGrallocActor) {
|
||||
mGrallocActor->RemoveTextureHost();
|
||||
mGrallocActor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -347,8 +340,17 @@ GrallocTextureHostOGL::DeallocateSharedData()
|
||||
if (mTextureSource) {
|
||||
mTextureSource->ForgetBuffer();
|
||||
}
|
||||
if (mGrallocActor) {
|
||||
PGrallocBufferParent::Send__delete__(mGrallocActor);
|
||||
if (mGrallocHandle.buffer().type() != SurfaceDescriptor::Tnull_t) {
|
||||
MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
|
||||
base::ProcessId owner;
|
||||
if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
|
||||
owner = handle.get_GrallocBufferRef().mOwner;
|
||||
}
|
||||
else {
|
||||
owner = handle.get_MagicGrallocBufferHandle().mRef.mOwner;
|
||||
}
|
||||
|
||||
SharedBufferManagerParent::GetInstance(owner)->DropGrallocBuffer(mGrallocHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,14 +125,8 @@ public:
|
||||
|
||||
virtual const char* Name() MOZ_OVERRIDE { return "GrallocTextureHostOGL"; }
|
||||
|
||||
// Forget buffer actor. Used only for hacky fix for bug 966446.
|
||||
virtual void ForgetBufferActor()
|
||||
{
|
||||
mGrallocActor = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
GrallocBufferActor* mGrallocActor;
|
||||
NewSurfaceDescriptorGralloc mGrallocHandle;
|
||||
RefPtr<GrallocTextureSourceOGL> mTextureSource;
|
||||
gfx::IntSize mSize; // See comment in textureClientOGL.h
|
||||
};
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/SharedBufferManagerChild.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
|
||||
|
||||
#include "prlog.h"
|
||||
@ -375,6 +376,9 @@ gfxPlatform::Init()
|
||||
if (gfxPrefs::AsyncVideoEnabled()) {
|
||||
ImageBridgeChild::StartUp();
|
||||
}
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
SharedBufferManagerChild::StartUp();
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
@ -496,7 +500,9 @@ gfxPlatform::Shutdown()
|
||||
// This will block this thread untill the ImageBridge protocol is completely
|
||||
// deleted.
|
||||
ImageBridgeChild::ShutDown();
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
SharedBufferManagerChild::ShutDown();
|
||||
#endif
|
||||
CompositorParent::ShutDown();
|
||||
|
||||
delete gGfxPlatformPrefsLock;
|
||||
|
@ -7,6 +7,8 @@
|
||||
include protocol PContent;
|
||||
include protocol PBrowser;
|
||||
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h";
|
||||
using mozilla::hal::FlashMode from "mozilla/HalTypes.h";
|
||||
using mozilla::hal::LightType from "mozilla/HalTypes.h";
|
||||
|
@ -30,7 +30,7 @@ class FileDescriptorSet : public base::RefCountedThreadSafe<FileDescriptorSet> {
|
||||
// In debugging mode, it's a fatal error to try and add more than this number
|
||||
// of descriptors to a FileDescriptorSet.
|
||||
enum {
|
||||
MAX_DESCRIPTORS_PER_MESSAGE = 4
|
||||
MAX_DESCRIPTORS_PER_MESSAGE = 7
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user