2012-07-13 19:38:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "base/thread.h"
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
#include "CompositorParent.h" // for CompositorParent::CompositorLoop
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "ImageBridgeChild.h"
|
2012-07-13 19:38:09 +00:00
|
|
|
#include "ImageBridgeParent.h"
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "gfxSharedImageSurface.h"
|
2012-08-17 10:56:55 +00:00
|
|
|
#include "mozilla/Monitor.h"
|
2012-07-13 19:38:09 +00:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
#include "mozilla/layers/CompositableClient.h"
|
|
|
|
#include "mozilla/layers/TextureChild.h"
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
#include "mozilla/layers/TextureClient.h"
|
|
|
|
#include "mozilla/layers/ImageClient.h"
|
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2012-07-13 19:38:09 +00:00
|
|
|
|
|
|
|
using namespace base;
|
2012-08-29 12:24:48 +00:00
|
|
|
using namespace mozilla::ipc;
|
2012-07-13 19:38:09 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
typedef std::vector<CompositableOperation> OpVector;
|
|
|
|
|
|
|
|
struct CompositableTransaction
|
|
|
|
{
|
|
|
|
CompositableTransaction()
|
|
|
|
: mSwapRequired(false)
|
|
|
|
, mFinished(true)
|
|
|
|
{}
|
|
|
|
~CompositableTransaction()
|
|
|
|
{
|
|
|
|
End();
|
|
|
|
}
|
|
|
|
bool Finished() const
|
|
|
|
{
|
|
|
|
return mFinished;
|
|
|
|
}
|
|
|
|
void Begin()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mFinished);
|
|
|
|
mFinished = false;
|
|
|
|
}
|
|
|
|
void End()
|
|
|
|
{
|
|
|
|
mFinished = true;
|
|
|
|
mSwapRequired = false;
|
|
|
|
mOperations.clear();
|
|
|
|
}
|
|
|
|
bool IsEmpty() const
|
|
|
|
{
|
|
|
|
return mOperations.empty();
|
|
|
|
}
|
|
|
|
void AddNoSwapEdit(const CompositableOperation& op)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
|
|
|
|
mOperations.push_back(op);
|
|
|
|
}
|
|
|
|
void AddEdit(const CompositableOperation& op)
|
|
|
|
{
|
|
|
|
AddNoSwapEdit(op);
|
|
|
|
mSwapRequired = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
OpVector mOperations;
|
|
|
|
bool mSwapRequired;
|
|
|
|
bool mFinished;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AutoEndTransaction {
|
|
|
|
AutoEndTransaction(CompositableTransaction* aTxn) : mTxn(aTxn) {}
|
|
|
|
~AutoEndTransaction() { mTxn->End(); }
|
|
|
|
CompositableTransaction* mTxn;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdateTexture(TextureClient* aTexture,
|
|
|
|
const SurfaceDescriptor& aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage.type() != SurfaceDescriptor::T__None, "[debug] STOP");
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
MOZ_ASSERT(aTexture->GetIPDLActor());
|
|
|
|
mTxn->AddEdit(OpPaintTexture(nullptr, aTexture->GetIPDLActor(), aImage));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable,
|
|
|
|
const nsIntRect& aRect)
|
|
|
|
{
|
|
|
|
mTxn->AddNoSwapEdit(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Singleton
|
2012-07-30 14:20:58 +00:00
|
|
|
static ImageBridgeChild *sImageBridgeChildSingleton = nullptr;
|
|
|
|
static Thread *sImageBridgeChildThread = nullptr;
|
2012-07-13 19:38:09 +00:00
|
|
|
|
|
|
|
// dispatched function
|
|
|
|
static void StopImageBridgeSync(ReentrantMonitor *aBarrier, bool *aDone)
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
|
|
|
|
"Should be in ImageBridgeChild thread.");
|
|
|
|
if (sImageBridgeChildSingleton) {
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->SendStop();
|
|
|
|
}
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
// dispatched function
|
|
|
|
static void DeleteImageBridgeSync(ReentrantMonitor *aBarrier, bool *aDone)
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
|
|
|
|
"Should be in ImageBridgeChild thread.");
|
|
|
|
delete sImageBridgeChildSingleton;
|
2012-07-30 14:20:58 +00:00
|
|
|
sImageBridgeChildSingleton = nullptr;
|
2012-07-13 19:38:09 +00:00
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
// dispatched function
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
static void CreateImageClientSync(RefPtr<ImageClient>* result,
|
|
|
|
ReentrantMonitor* barrier,
|
|
|
|
CompositableType aType,
|
|
|
|
bool *aDone)
|
2012-07-13 19:38:09 +00:00
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*barrier);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
*result = sImageBridgeChildSingleton->CreateImageClientNow(aType);
|
2012-07-13 19:38:09 +00:00
|
|
|
*aDone = true;
|
|
|
|
barrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2012-08-17 10:56:55 +00:00
|
|
|
struct GrallocParam {
|
|
|
|
gfxIntSize size;
|
|
|
|
uint32_t format;
|
|
|
|
uint32_t usage;
|
|
|
|
SurfaceDescriptor* buffer;
|
|
|
|
|
|
|
|
GrallocParam(const gfxIntSize& aSize,
|
|
|
|
const uint32_t& aFormat,
|
|
|
|
const uint32_t& aUsage,
|
|
|
|
SurfaceDescriptor* aBuffer)
|
|
|
|
: size(aSize)
|
|
|
|
, format(aFormat)
|
|
|
|
, usage(aUsage)
|
|
|
|
, buffer(aBuffer)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
// dispatched function
|
|
|
|
static void AllocSurfaceDescriptorGrallocSync(const GrallocParam& aParam,
|
|
|
|
Monitor* aBarrier,
|
|
|
|
bool* aDone)
|
|
|
|
{
|
|
|
|
MonitorAutoLock autoMon(*aBarrier);
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->AllocSurfaceDescriptorGrallocNow(aParam.size,
|
|
|
|
aParam.format,
|
|
|
|
aParam.usage,
|
|
|
|
aParam.buffer);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
// dispatched function
|
|
|
|
static void DeallocSurfaceDescriptorGrallocSync(const SurfaceDescriptor& aBuffer,
|
|
|
|
Monitor* aBarrier,
|
|
|
|
bool* aDone)
|
|
|
|
{
|
|
|
|
MonitorAutoLock autoMon(*aBarrier);
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->DeallocSurfaceDescriptorGrallocNow(aBuffer);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
// dispatched function
|
|
|
|
static void ConnectImageBridge(ImageBridgeChild * child, ImageBridgeParent * parent)
|
|
|
|
{
|
|
|
|
MessageLoop *parentMsgLoop = parent->GetMessageLoop();
|
|
|
|
ipc::AsyncChannel *parentChannel = parent->GetIPCChannel();
|
|
|
|
child->Open(parentChannel, parentMsgLoop, mozilla::ipc::AsyncChannel::Child);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
ImageBridgeChild::ImageBridgeChild()
|
|
|
|
{
|
|
|
|
mTxn = new CompositableTransaction();
|
|
|
|
}
|
|
|
|
ImageBridgeChild::~ImageBridgeChild()
|
|
|
|
{
|
|
|
|
delete mTxn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::Connect(CompositableClient* aCompositable)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
uint64_t id = 0;
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(
|
|
|
|
SendPCompositableConstructor(aCompositable->GetType(), &id));
|
|
|
|
MOZ_ASSERT(child);
|
|
|
|
child->SetAsyncID(id);
|
|
|
|
aCompositable->SetIPDLActor(child);
|
|
|
|
MOZ_ASSERT(child->GetAsyncID() == id);
|
|
|
|
child->SetClient(aCompositable);
|
|
|
|
}
|
|
|
|
|
|
|
|
PCompositableChild*
|
|
|
|
ImageBridgeChild::AllocPCompositable(const CompositableType& aType, uint64_t* aID)
|
|
|
|
{
|
|
|
|
return new CompositableChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocPCompositable(PCompositableChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
Thread* ImageBridgeChild::GetThread() const
|
|
|
|
{
|
|
|
|
return sImageBridgeChildThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageBridgeChild* ImageBridgeChild::GetSingleton()
|
|
|
|
{
|
|
|
|
return sImageBridgeChildSingleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageBridgeChild::IsCreated()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return GetSingleton() != nullptr;
|
2012-07-13 19:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::StartUp()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
ImageBridgeChild::StartUpOnThread(new Thread("ImageBridgeChild"));
|
|
|
|
}
|
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
static void
|
|
|
|
ConnectImageBridgeInChildProcess(Transport* aTransport,
|
|
|
|
ProcessHandle aOtherProcess)
|
|
|
|
{
|
|
|
|
// Bind the IPC channel to the image bridge thread.
|
|
|
|
sImageBridgeChildSingleton->Open(aTransport, aOtherProcess,
|
|
|
|
XRE_GetIOMessageLoop(),
|
|
|
|
AsyncChannel::Child);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
static void ReleaseImageClientNow(ImageClient* aClient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(InImageBridgeChildThread());
|
|
|
|
aClient->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* aClient)
|
|
|
|
{
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ReleaseImageClientNow, aClient));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateImageClientNow(ImageClient* aClient, ImageContainer* aContainer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aClient);
|
|
|
|
MOZ_ASSERT(aContainer);
|
|
|
|
sImageBridgeChildSingleton->BeginTransaction();
|
|
|
|
aClient->UpdateImage(aContainer, Layer::CONTENT_OPAQUE);
|
|
|
|
sImageBridgeChildSingleton->EndTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
|
|
|
void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient,
|
|
|
|
ImageContainer* aContainer)
|
|
|
|
{
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&UpdateImageClientNow, aClient, aContainer));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::BeginTransaction()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
|
|
|
|
mTxn->Begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::EndTransaction()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mTxn->Finished(), "forgot BeginTransaction?");
|
|
|
|
|
|
|
|
AutoEndTransaction _(mTxn);
|
|
|
|
|
|
|
|
if (mTxn->IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoInfallibleTArray<CompositableOperation, 10> cset;
|
|
|
|
cset.SetCapacity(mTxn->mOperations.size());
|
|
|
|
if (!mTxn->mOperations.empty()) {
|
|
|
|
cset.AppendElements(&mTxn->mOperations.front(), mTxn->mOperations.size());
|
|
|
|
}
|
|
|
|
ShadowLayerForwarder::PlatformSyncBeforeUpdate();
|
|
|
|
|
|
|
|
AutoInfallibleTArray<EditReply, 10> replies;
|
|
|
|
|
|
|
|
if (mTxn->mSwapRequired) {
|
|
|
|
if (!SendUpdate(cset, &replies)) {
|
|
|
|
NS_WARNING("could not send async texture transaction");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If we don't require a swap we can call SendUpdateNoSwap which
|
|
|
|
// assumes that aReplies is empty (DEBUG assertion)
|
|
|
|
if (!SendUpdateNoSwap(cset)) {
|
|
|
|
NS_WARNING("could not send async texture transaction (no swap)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (nsTArray<EditReply>::size_type i = 0; i < replies.Length(); ++i) {
|
|
|
|
const EditReply& reply = replies[i];
|
|
|
|
switch (reply.type()) {
|
|
|
|
case EditReply::TOpTextureSwap: {
|
|
|
|
const OpTextureSwap& ots = reply.get_OpTextureSwap();
|
|
|
|
PTextureChild* textureChild = ots.textureChild();
|
|
|
|
MOZ_ASSERT(textureChild);
|
|
|
|
TextureClient* texClient = static_cast<TextureChild*>(textureChild)->GetTextureClient();
|
|
|
|
texClient->SetDescriptor(ots.image());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
PImageBridgeChild*
|
|
|
|
ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
|
|
|
|
ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
|
|
|
|
ProcessHandle processHandle;
|
|
|
|
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
|
|
|
if (!sImageBridgeChildThread->Start()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton = new ImageBridgeChild();
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(ConnectImageBridgeInChildProcess,
|
|
|
|
aTransport, processHandle));
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
return sImageBridgeChildSingleton;
|
|
|
|
}
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
void ImageBridgeChild::ShutDown()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
if (ImageBridgeChild::IsCreated()) {
|
|
|
|
ImageBridgeChild::DestroyBridge();
|
|
|
|
delete sImageBridgeChildThread;
|
2012-07-30 14:20:58 +00:00
|
|
|
sImageBridgeChildThread = nullptr;
|
2012-07-13 19:38:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageBridgeChild::StartUpOnThread(Thread* aThread)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aThread, "ImageBridge needs a thread.");
|
2012-07-30 14:20:58 +00:00
|
|
|
if (sImageBridgeChildSingleton == nullptr) {
|
2012-07-13 19:38:09 +00:00
|
|
|
sImageBridgeChildThread = aThread;
|
|
|
|
if (!aThread->IsRunning()) {
|
|
|
|
aThread->Start();
|
|
|
|
}
|
|
|
|
sImageBridgeChildSingleton = new ImageBridgeChild();
|
|
|
|
ImageBridgeParent* imageBridgeParent = new ImageBridgeParent(
|
2013-02-19 19:27:49 +00:00
|
|
|
CompositorParent::CompositorLoop(), nullptr);
|
2012-07-13 19:38:09 +00:00
|
|
|
sImageBridgeChildSingleton->ConnectAsync(imageBridgeParent);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::DestroyBridge()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!InImageBridgeChildThread(),
|
|
|
|
"This method must not be called in this thread.");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
// ...because we are about to dispatch synchronous messages to the
|
2012-07-13 19:38:09 +00:00
|
|
|
// ImageBridgeChild thread.
|
|
|
|
|
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReentrantMonitor barrier("ImageBridgeDestroyTask lock");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
|
|
|
|
bool done = false;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
|
2012-07-13 19:38:09 +00:00
|
|
|
NewRunnableFunction(&StopImageBridgeSync, &barrier, &done));
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
done = false;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
|
2012-07-13 19:38:09 +00:00
|
|
|
NewRunnableFunction(&DeleteImageBridgeSync, &barrier, &done));
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InImageBridgeChildThread()
|
|
|
|
{
|
|
|
|
return sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId();
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageLoop * ImageBridgeChild::GetMessageLoop() const
|
|
|
|
{
|
|
|
|
return sImageBridgeChildThread->message_loop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::ConnectAsync(ImageBridgeParent* aParent)
|
|
|
|
{
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
GetMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(&ConnectImageBridge,
|
2012-07-13 19:38:09 +00:00
|
|
|
this, aParent));
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
TemporaryRef<ImageClient>
|
|
|
|
ImageBridgeChild::CreateImageClient(CompositableType aType)
|
2012-07-13 19:38:09 +00:00
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
return CreateImageClientNow(aType);
|
|
|
|
}
|
|
|
|
ReentrantMonitor barrier("CreateImageClient Lock");
|
2012-07-13 19:38:09 +00:00
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
RefPtr<ImageClient> result = nullptr;
|
|
|
|
GetMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(&CreateImageClientSync,
|
|
|
|
&result, &barrier, aType, &done));
|
|
|
|
// should stop the thread until the ImageClient has been created on
|
2012-07-13 19:38:09 +00:00
|
|
|
// the other thread
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
TemporaryRef<ImageClient>
|
|
|
|
ImageBridgeChild::CreateImageClientNow(CompositableType aType)
|
2012-07-13 19:38:09 +00:00
|
|
|
{
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
mCompositorBackend = LAYERS_OPENGL;
|
|
|
|
|
|
|
|
RefPtr<ImageClient> client
|
|
|
|
= ImageClient::CreateImageClient(mCompositorBackend,
|
|
|
|
aType, this, 0);
|
|
|
|
MOZ_ASSERT(client, "failed to create ImageClient");
|
|
|
|
if (client) {
|
|
|
|
client->Connect();
|
|
|
|
}
|
|
|
|
return client.forget();
|
2012-07-13 19:38:09 +00:00
|
|
|
}
|
|
|
|
|
2012-08-17 10:56:55 +00:00
|
|
|
PGrallocBufferChild*
|
|
|
|
ImageBridgeChild::AllocPGrallocBuffer(const gfxIntSize&, 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::DeallocPGrallocBuffer(PGrallocBufferChild* actor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Um, how did we get here?");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::AllocSurfaceDescriptorGralloc(const gfxIntSize& aSize,
|
|
|
|
const uint32_t& aFormat,
|
|
|
|
const uint32_t& aUsage,
|
|
|
|
SurfaceDescriptor* aBuffer)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
return ImageBridgeChild::AllocSurfaceDescriptorGrallocNow(aSize, aFormat, aUsage, aBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
Monitor barrier("AllocSurfaceDescriptorGralloc Lock");
|
|
|
|
MonitorAutoLock autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&AllocSurfaceDescriptorGrallocSync,
|
|
|
|
GrallocParam(aSize, aFormat, aUsage, aBuffer), &barrier, &done));
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::AllocSurfaceDescriptorGrallocNow(const gfxIntSize& aSize,
|
|
|
|
const uint32_t& aFormat,
|
|
|
|
const uint32_t& aUsage,
|
|
|
|
SurfaceDescriptor* aBuffer)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
MaybeMagicGrallocBufferHandle handle;
|
|
|
|
PGrallocBufferChild* gc = SendPGrallocBufferConstructor(aSize, aFormat, aUsage, &handle);
|
|
|
|
if (handle.Tnull_t == handle.type()) {
|
|
|
|
PGrallocBufferChild::Send__delete__(gc);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrallocBufferActor* gba = static_cast<GrallocBufferActor*>(gc);
|
|
|
|
gba->InitFromHandle(handle.get_MagicGrallocBufferHandle());
|
|
|
|
|
2013-03-28 13:59:47 +00:00
|
|
|
*aBuffer = SurfaceDescriptorGralloc(nullptr, gc, aSize, /* external */ false);
|
2012-08-17 10:56:55 +00:00
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No gralloc buffers for you");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocSurfaceDescriptorGralloc(const SurfaceDescriptor& aBuffer)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
return ImageBridgeChild::DeallocSurfaceDescriptorGrallocNow(aBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
Monitor barrier("DeallocSurfaceDescriptor Lock");
|
|
|
|
MonitorAutoLock autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
GetMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(&DeallocSurfaceDescriptorGrallocSync,
|
|
|
|
aBuffer, &barrier, &done));
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocSurfaceDescriptorGrallocNow(const SurfaceDescriptor& aBuffer)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
PGrallocBufferChild* gbp =
|
|
|
|
aBuffer.get_SurfaceDescriptorGralloc().bufferChild();
|
|
|
|
PGrallocBufferChild::Send__delete__(gbp);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Um, how did we get here?");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
bool
|
|
|
|
ImageBridgeChild::AllocUnsafeShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
return PImageBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
|
|
|
|
} else {
|
|
|
|
return DispatchAllocShmemInternal(aSize, aType, aShmem, true); // true: unsafe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::AllocShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
return PImageBridgeChild::AllocShmem(aSize, aType, aShmem);
|
|
|
|
} else {
|
|
|
|
return DispatchAllocShmemInternal(aSize, aType, aShmem, false); // false: unsafe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRunnableFunction accepts a limited number of parameters so we need a
|
|
|
|
// struct here
|
|
|
|
struct AllocShmemParams {
|
|
|
|
ISurfaceAllocator* mAllocator;
|
|
|
|
size_t mSize;
|
|
|
|
ipc::SharedMemory::SharedMemoryType mType;
|
|
|
|
ipc::Shmem* mShmem;
|
|
|
|
bool mUnsafe;
|
|
|
|
bool mSuccess;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ProxyAllocShmemNow(AllocShmemParams* aParams,
|
|
|
|
ReentrantMonitor* aBarrier,
|
|
|
|
bool* aDone)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aParams);
|
|
|
|
MOZ_ASSERT(aDone);
|
|
|
|
MOZ_ASSERT(aBarrier);
|
|
|
|
|
|
|
|
if (aParams->mUnsafe) {
|
|
|
|
aParams->mSuccess = aParams->mAllocator->AllocUnsafeShmem(aParams->mSize,
|
|
|
|
aParams->mType,
|
|
|
|
aParams->mShmem);
|
|
|
|
} else {
|
|
|
|
aParams->mSuccess = aParams->mAllocator->AllocShmem(aParams->mSize,
|
|
|
|
aParams->mType,
|
|
|
|
aParams->mShmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DispatchAllocShmemInternal(size_t aSize,
|
|
|
|
SharedMemory::SharedMemoryType aType,
|
|
|
|
Shmem* aShmem,
|
|
|
|
bool aUnsafe)
|
|
|
|
{
|
|
|
|
ReentrantMonitor barrier("AllocatorProxy alloc");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
|
|
|
|
AllocShmemParams params = {
|
|
|
|
this, aSize, aType, aShmem, aUnsafe, true
|
|
|
|
};
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
GetMessageLoop()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(&ProxyAllocShmemNow,
|
|
|
|
¶ms,
|
|
|
|
&barrier,
|
|
|
|
&done));
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
return params.mSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ProxyDeallocShmemNow(ISurfaceAllocator* aAllocator,
|
|
|
|
Shmem* aShmem,
|
|
|
|
ReentrantMonitor* aBarrier,
|
|
|
|
bool* aDone)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aShmem);
|
|
|
|
MOZ_ASSERT(aDone);
|
|
|
|
MOZ_ASSERT(aBarrier);
|
|
|
|
|
|
|
|
aAllocator->DeallocShmem(*aShmem);
|
|
|
|
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
PImageBridgeChild::DeallocShmem(aShmem);
|
|
|
|
} else {
|
|
|
|
ReentrantMonitor barrier("AllocatorProxy Dealloc");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
GetMessageLoop()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(&ProxyDeallocShmemNow,
|
|
|
|
this,
|
|
|
|
&aShmem,
|
|
|
|
&barrier,
|
|
|
|
&done));
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PGrallocBufferChild*
|
|
|
|
ImageBridgeChild::AllocGrallocBuffer(const gfxIntSize& aSize,
|
|
|
|
gfxASurface::gfxContentType aContent,
|
|
|
|
MaybeMagicGrallocBufferHandle* aHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
return SendPGrallocBufferConstructor(aSize,
|
|
|
|
aContent,
|
|
|
|
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
|
|
|
|
aHandle);
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("not implemented");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
} // layers
|
|
|
|
} // mozilla
|