2012-07-13 12:38:09 -07: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 05:24:48 -07:00
|
|
|
#include "ImageBridgeChild.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <vector> // for vector
|
|
|
|
#include "CompositorParent.h" // for CompositorParent
|
|
|
|
#include "ImageBridgeParent.h" // for ImageBridgeParent
|
|
|
|
#include "ImageContainer.h" // for ImageContainer
|
|
|
|
#include "Layers.h" // for Layer, etc
|
|
|
|
#include "ShadowLayers.h" // for ShadowLayerForwarder
|
|
|
|
#include "base/message_loop.h" // for MessageLoop
|
|
|
|
#include "base/platform_thread.h" // for PlatformThread
|
|
|
|
#include "base/process.h" // for ProcessHandle
|
|
|
|
#include "base/process_util.h" // for OpenProcessHandle
|
|
|
|
#include "base/task.h" // for NewRunnableFunction, etc
|
|
|
|
#include "base/thread.h" // for Thread
|
|
|
|
#include "base/tracked.h" // for FROM_HERE
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/Monitor.h" // for Monitor, MonitorAutoLock
|
|
|
|
#include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc
|
2013-09-27 18:42:08 -07:00
|
|
|
#include "mozilla/ipc/MessageChannel.h" // for MessageChannel, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/ipc/Transport.h" // for Transport
|
2013-12-20 08:46:28 -08:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableChild, etc
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h" // for ISurfaceAllocator
|
|
|
|
#include "mozilla/layers/ImageClient.h" // for ImageClient
|
2013-09-06 08:41:00 -07:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for CompositableOperation
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/PCompositableChild.h" // for PCompositableChild
|
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
|
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsISupportsImpl.h" // for ImageContainer::AddRef, etc
|
|
|
|
#include "nsTArray.h" // for nsAutoTArray, nsTArray, etc
|
|
|
|
#include "nsTArrayForwardDeclare.h" // for AutoInfallibleTArray
|
|
|
|
#include "nsThreadUtils.h" // for NS_IsMainThread
|
|
|
|
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
2013-11-01 04:34:40 -07:00
|
|
|
#include "mozilla/StaticPtr.h" // for StaticRefPtr
|
2013-12-11 17:44:44 -08:00
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
|
|
|
|
struct nsIntRect;
|
2013-04-27 23:46:30 -07:00
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
using namespace base;
|
2012-08-29 05:24:48 -07:00
|
|
|
using namespace mozilla::ipc;
|
2013-12-20 08:46:28 -08:00
|
|
|
using namespace mozilla::gfx;
|
2012-07-13 12:38:09 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-11 16:17:23 -07:00
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
namespace layers {
|
|
|
|
|
2014-04-25 09:51:11 -07:00
|
|
|
class PGrallocBufferChild;
|
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 02:20:52 -07: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;
|
|
|
|
};
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture)
|
|
|
|
{
|
2014-04-11 09:48:01 -07:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
|
|
|
MOZ_ASSERT(aTexture->GetIPDLActor());
|
2013-07-30 02:59:51 -07:00
|
|
|
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
2013-12-11 17:44:44 -08:00
|
|
|
nullptr, aTexture->GetIPDLActor()));
|
2013-07-30 02:59:51 -07:00
|
|
|
}
|
|
|
|
|
2014-02-06 03:28:29 -08:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UseComponentAlphaTextures(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTextureOnBlack,
|
|
|
|
TextureClient* aTextureOnWhite)
|
|
|
|
{
|
2014-04-11 09:48:01 -07:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aTextureOnWhite);
|
|
|
|
MOZ_ASSERT(aTextureOnBlack);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
|
|
|
MOZ_ASSERT(aTextureOnWhite->GetIPDLActor());
|
|
|
|
MOZ_ASSERT(aTextureOnBlack->GetIPDLActor());
|
2014-03-21 10:03:20 -07:00
|
|
|
MOZ_ASSERT(aTextureOnBlack->GetSize() == aTextureOnWhite->GetSize());
|
2014-02-06 03:28:29 -08:00
|
|
|
mTxn->AddNoSwapEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
|
|
|
|
nullptr, aTextureOnBlack->GetIPDLActor(),
|
|
|
|
nullptr, aTextureOnWhite->GetIPDLActor()));
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture,
|
|
|
|
nsIntRegion* aRegion)
|
|
|
|
{
|
2014-04-11 09:48:01 -07:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
|
|
|
MOZ_ASSERT(aTexture->GetIPDLActor());
|
2013-07-30 02:59:51 -07:00
|
|
|
MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
|
|
|
|
: MaybeRegion(null_t());
|
|
|
|
mTxn->AddNoSwapEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
|
2013-12-11 17:44:44 -08:00
|
|
|
nullptr, aTexture->GetIPDLActor(),
|
2013-07-30 02:59:51 -07:00
|
|
|
region));
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable,
|
|
|
|
const nsIntRect& aRect)
|
|
|
|
{
|
2014-04-11 09:48:01 -07:00
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
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 02:20:52 -07:00
|
|
|
mTxn->AddNoSwapEdit(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Singleton
|
2013-11-27 07:19:34 -08:00
|
|
|
static StaticRefPtr<ImageBridgeChild> sImageBridgeChildSingleton;
|
2013-11-01 04:34:40 -07:00
|
|
|
static StaticRefPtr<ImageBridgeParent> sImageBridgeParentSingleton;
|
2012-07-30 07:20:58 -07:00
|
|
|
static Thread *sImageBridgeChildThread = nullptr;
|
2012-07-13 12:38:09 -07: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) {
|
2014-04-25 04:55:36 -07:00
|
|
|
// Force all managed protocols to shut themselves down cleanly
|
|
|
|
InfallibleTArray<PCompositableChild*> compositables;
|
|
|
|
sImageBridgeChildSingleton->ManagedPCompositableChild(compositables);
|
|
|
|
for (int i = compositables.Length() - 1; i >= 0; --i) {
|
|
|
|
CompositableClient::FromIPDLActor(compositables[i])->Destroy();
|
|
|
|
}
|
|
|
|
InfallibleTArray<PTextureChild*> textures;
|
|
|
|
sImageBridgeChildSingleton->ManagedPTextureChild(textures);
|
|
|
|
for (int i = textures.Length() - 1; i >= 0; --i) {
|
|
|
|
TextureClient::AsTextureClient(textures[i])->ForceRemove();
|
|
|
|
}
|
2012-07-13 12:38:09 -07:00
|
|
|
sImageBridgeChildSingleton->SendStop();
|
2014-04-25 04:55:36 -07:00
|
|
|
sImageBridgeChildSingleton->MarkShutDown();
|
|
|
|
// From now on, no message can be sent through the image bridge from the
|
|
|
|
// client side.
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
2014-04-25 04:55:36 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::MarkShutDown()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
|
|
|
mShuttingDown = true;
|
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
// dispatched function
|
|
|
|
static void DeleteImageBridgeSync(ReentrantMonitor *aBarrier, bool *aDone)
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
|
|
|
|
"Should be in ImageBridgeChild thread.");
|
2012-07-30 07:20:58 -07:00
|
|
|
sImageBridgeChildSingleton = nullptr;
|
2013-10-01 20:05:34 -07:00
|
|
|
sImageBridgeParentSingleton = nullptr;
|
2012-07-13 12:38:09 -07: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 02:20:52 -07:00
|
|
|
static void CreateImageClientSync(RefPtr<ImageClient>* result,
|
|
|
|
ReentrantMonitor* barrier,
|
|
|
|
CompositableType aType,
|
|
|
|
bool *aDone)
|
2012-07-13 12:38:09 -07: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 02:20:52 -07:00
|
|
|
*result = sImageBridgeChildSingleton->CreateImageClientNow(aType);
|
2012-07-13 12:38:09 -07:00
|
|
|
*aDone = true;
|
|
|
|
barrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
2014-04-25 09:51:11 -07:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
// dispatched function
|
|
|
|
static void ConnectImageBridge(ImageBridgeChild * child, ImageBridgeParent * parent)
|
|
|
|
{
|
|
|
|
MessageLoop *parentMsgLoop = parent->GetMessageLoop();
|
2013-09-27 18:42:08 -07:00
|
|
|
ipc::MessageChannel *parentChannel = parent->GetIPCChannel();
|
|
|
|
child->Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
|
2012-07-13 12:38:09 -07: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 02:20:52 -07:00
|
|
|
ImageBridgeChild::ImageBridgeChild()
|
2014-04-25 04:55:36 -07:00
|
|
|
: mShuttingDown(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 02:20:52 -07:00
|
|
|
{
|
|
|
|
mTxn = new CompositableTransaction();
|
|
|
|
}
|
|
|
|
ImageBridgeChild::~ImageBridgeChild()
|
|
|
|
{
|
|
|
|
delete mTxn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeChild::Connect(CompositableClient* aCompositable)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCompositable);
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
uint64_t id = 0;
|
2014-04-24 11:13:59 -07:00
|
|
|
PCompositableChild* child =
|
|
|
|
SendPCompositableConstructor(aCompositable->GetTextureInfo(), &id);
|
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 02:20:52 -07:00
|
|
|
MOZ_ASSERT(child);
|
2014-04-24 11:13:59 -07:00
|
|
|
aCompositable->InitIPDLActor(child, id);
|
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 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PCompositableChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ImageBridgeChild::AllocPCompositableChild(const TextureInfo& aInfo, uint64_t* aID)
|
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 02:20:52 -07:00
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
2014-04-24 11:13:59 -07:00
|
|
|
return CompositableClient::CreateIPDLActor();
|
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 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ImageBridgeChild::DeallocPCompositableChild(PCompositableChild* aActor)
|
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 02:20:52 -07:00
|
|
|
{
|
2014-04-24 11:13:59 -07:00
|
|
|
return CompositableClient::DestroyIPDLActor(aActor);
|
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 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
Thread* ImageBridgeChild::GetThread() const
|
|
|
|
{
|
|
|
|
return sImageBridgeChildThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageBridgeChild* ImageBridgeChild::GetSingleton()
|
|
|
|
{
|
|
|
|
return sImageBridgeChildSingleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageBridgeChild::IsCreated()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return GetSingleton() != nullptr;
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::StartUp()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
ImageBridgeChild::StartUpOnThread(new Thread("ImageBridgeChild"));
|
|
|
|
}
|
|
|
|
|
2014-04-11 03:37:12 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
#include "ipc/Nuwa.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-29 05:24:48 -07:00
|
|
|
static void
|
|
|
|
ConnectImageBridgeInChildProcess(Transport* aTransport,
|
|
|
|
ProcessHandle aOtherProcess)
|
|
|
|
{
|
|
|
|
// Bind the IPC channel to the image bridge thread.
|
|
|
|
sImageBridgeChildSingleton->Open(aTransport, aOtherProcess,
|
|
|
|
XRE_GetIOMessageLoop(),
|
2013-09-27 18:42:08 -07:00
|
|
|
ipc::ChildSide);
|
2013-06-03 03:14:42 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2014-04-11 03:37:12 -07:00
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
sImageBridgeChildThread
|
|
|
|
->message_loop()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(NuwaMarkCurrentThread,
|
|
|
|
(void (*)(void *))nullptr,
|
|
|
|
(void *)nullptr));
|
|
|
|
}
|
2013-06-03 03:14:42 -07:00
|
|
|
#endif
|
2014-04-11 03:37:12 -07:00
|
|
|
}
|
2013-06-03 03:14:42 -07: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 02:20:52 -07:00
|
|
|
static void ReleaseImageClientNow(ImageClient* aClient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(InImageBridgeChildThread());
|
|
|
|
aClient->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* aClient)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ReleaseImageClientNow, aClient));
|
|
|
|
}
|
|
|
|
|
2013-10-01 20:05:35 -07:00
|
|
|
static void ReleaseTextureClientNow(TextureClient* aClient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(InImageBridgeChildThread());
|
|
|
|
aClient->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void ImageBridgeChild::DispatchReleaseTextureClient(TextureClient* aClient)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-01 20:05:35 -07:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ReleaseTextureClientNow, aClient));
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
static void UpdateImageClientNow(ImageClient* aClient, ImageContainer* aContainer)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aClient);
|
|
|
|
MOZ_ASSERT(aContainer);
|
|
|
|
sImageBridgeChildSingleton->BeginTransaction();
|
|
|
|
aClient->UpdateImage(aContainer, Layer::CONTENT_OPAQUE);
|
2013-07-30 02:59:51 -07:00
|
|
|
aClient->OnTransaction();
|
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 02:20:52 -07:00
|
|
|
sImageBridgeChildSingleton->EndTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
|
|
|
void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient,
|
|
|
|
ImageContainer* aContainer)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-30 05:10:02 -07:00
|
|
|
if (InImageBridgeChildThread()) {
|
|
|
|
UpdateImageClientNow(aClient, aContainer);
|
|
|
|
return;
|
|
|
|
}
|
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 02:20:52 -07:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
2013-07-17 23:33:28 -07:00
|
|
|
NewRunnableFunction<
|
|
|
|
void (*)(ImageClient*, ImageContainer*),
|
|
|
|
ImageClient*,
|
|
|
|
nsRefPtr<ImageContainer> >(&UpdateImageClientNow, aClient, aContainer));
|
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 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-10-17 08:09:15 -07:00
|
|
|
static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront, ReentrantMonitor* aBarrier, bool* aDone)
|
2013-09-12 07:50:28 -07:00
|
|
|
{
|
2013-10-17 08:09:15 -07:00
|
|
|
ImageBridgeChild::FlushAllImagesNow(aClient, aContainer, aExceptFront);
|
2013-09-12 07:50:28 -07:00
|
|
|
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2013-10-17 08:09:15 -07:00
|
|
|
void ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
|
2013-09-12 07:50:28 -07:00
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-12 07:50:28 -07:00
|
|
|
if (InImageBridgeChildThread()) {
|
2013-10-17 08:09:15 -07:00
|
|
|
FlushAllImagesNow(aClient, aContainer, aExceptFront);
|
2013-09-12 07:50:28 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReentrantMonitor barrier("CreateImageClient Lock");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
2013-10-17 08:09:15 -07:00
|
|
|
NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, aExceptFront, &barrier, &done));
|
2013-09-12 07:50:28 -07:00
|
|
|
|
|
|
|
// should stop the thread until the ImageClient has been created on
|
|
|
|
// the other thread
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2013-10-17 08:09:15 -07:00
|
|
|
void ImageBridgeChild::FlushAllImagesNow(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
|
2013-09-12 07:50:28 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aClient);
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
|
2013-09-12 07:50:28 -07:00
|
|
|
sImageBridgeChildSingleton->BeginTransaction();
|
2013-10-17 08:09:15 -07:00
|
|
|
if (aContainer && !aExceptFront) {
|
2013-09-12 07:50:28 -07:00
|
|
|
aContainer->ClearCurrentImage();
|
|
|
|
}
|
2013-10-17 08:09:15 -07:00
|
|
|
aClient->FlushAllImages(aExceptFront);
|
2013-09-12 07:50:28 -07:00
|
|
|
aClient->OnTransaction();
|
|
|
|
sImageBridgeChildSingleton->EndTransaction();
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::BeginTransaction()
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
|
|
|
|
mTxn->Begin();
|
|
|
|
}
|
|
|
|
|
2014-02-09 18:24:27 -08:00
|
|
|
class MOZ_STACK_CLASS AutoRemoveTextures
|
2014-01-23 06:31:12 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-02-09 18:24:27 -08:00
|
|
|
AutoRemoveTextures(ImageBridgeChild* aImageBridge)
|
2014-01-23 06:31:12 -08:00
|
|
|
: mImageBridge(aImageBridge) {}
|
|
|
|
|
2014-02-09 18:24:27 -08:00
|
|
|
~AutoRemoveTextures()
|
2014-01-23 06:31:12 -08:00
|
|
|
{
|
2014-02-09 18:24:27 -08:00
|
|
|
mImageBridge->RemoveTexturesIfNecessary();
|
2014-01-23 06:31:12 -08:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
ImageBridgeChild* mImageBridge;
|
|
|
|
};
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::EndTransaction()
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
MOZ_ASSERT(!mTxn->Finished(), "forgot BeginTransaction?");
|
|
|
|
|
|
|
|
AutoEndTransaction _(mTxn);
|
2014-02-09 18:24:27 -08:00
|
|
|
AutoRemoveTextures autoRemoveTextures(this);
|
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 02:20:52 -07:00
|
|
|
|
2013-08-08 05:53:12 -07:00
|
|
|
if (mTxn->IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
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();
|
2013-04-12 00:28:55 -07:00
|
|
|
|
2014-04-24 11:13:59 -07:00
|
|
|
CompositableClient* compositable =
|
|
|
|
CompositableClient::FromIPDLActor(ots.compositableChild());
|
2013-04-12 00:28:55 -07:00
|
|
|
|
2014-04-24 11:13:59 -07:00
|
|
|
MOZ_ASSERT(compositable);
|
2013-04-12 00:28:55 -07:00
|
|
|
|
2014-04-24 11:13:59 -07:00
|
|
|
compositable->SetDescriptorFromReply(ots.textureId(), ots.image());
|
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 02:20:52 -07:00
|
|
|
break;
|
|
|
|
}
|
2014-02-24 20:23:41 -08:00
|
|
|
case EditReply::TReturnReleaseFence: {
|
|
|
|
const ReturnReleaseFence& rep = reply.get_ReturnReleaseFence();
|
|
|
|
FenceHandle fence = rep.fence();
|
|
|
|
PTextureChild* child = rep.textureChild();
|
|
|
|
|
|
|
|
if (!fence.IsValid() || !child) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(child);
|
|
|
|
if (texture) {
|
|
|
|
texture->SetReleaseFenceHandle(fence);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
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 02:20:52 -07:00
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-25 21:19:09 -07:00
|
|
|
PImageBridgeChild*
|
2012-08-29 05:24:48 -07:00
|
|
|
ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
|
|
|
|
ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
|
|
|
|
ProcessHandle processHandle;
|
|
|
|
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
2013-09-25 21:19:09 -07:00
|
|
|
return nullptr;
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
|
|
|
if (!sImageBridgeChildThread->Start()) {
|
2013-09-25 21:19:09 -07:00
|
|
|
return nullptr;
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
|
2013-09-25 21:19:09 -07:00
|
|
|
return sImageBridgeChildSingleton;
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
void ImageBridgeChild::ShutDown()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
|
|
|
if (ImageBridgeChild::IsCreated()) {
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
|
2012-07-13 12:38:09 -07:00
|
|
|
ImageBridgeChild::DestroyBridge();
|
|
|
|
delete sImageBridgeChildThread;
|
2012-07-30 07:20:58 -07:00
|
|
|
sImageBridgeChildThread = nullptr;
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageBridgeChild::StartUpOnThread(Thread* aThread)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aThread, "ImageBridge needs a thread.");
|
2012-07-30 07:20:58 -07:00
|
|
|
if (sImageBridgeChildSingleton == nullptr) {
|
2012-07-13 12:38:09 -07:00
|
|
|
sImageBridgeChildThread = aThread;
|
|
|
|
if (!aThread->IsRunning()) {
|
|
|
|
aThread->Start();
|
|
|
|
}
|
|
|
|
sImageBridgeChildSingleton = new ImageBridgeChild();
|
2013-10-01 20:05:34 -07:00
|
|
|
sImageBridgeParentSingleton = new ImageBridgeParent(
|
2013-02-19 11:27:49 -08:00
|
|
|
CompositorParent::CompositorLoop(), nullptr);
|
2013-10-01 20:05:34 -07:00
|
|
|
sImageBridgeChildSingleton->ConnectAsync(sImageBridgeParentSingleton);
|
2012-07-13 12:38:09 -07:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::DestroyBridge()
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
if (!IsCreated()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-13 12:38:09 -07:00
|
|
|
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 02:20:52 -07:00
|
|
|
// ...because we are about to dispatch synchronous messages to the
|
2012-07-13 12:38:09 -07:00
|
|
|
// ImageBridgeChild thread.
|
|
|
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
|
2012-07-13 12:38:09 -07: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 02:20:52 -07:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(FROM_HERE,
|
2012-07-13 12:38:09 -07:00
|
|
|
NewRunnableFunction(&DeleteImageBridgeSync, &barrier, &done));
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InImageBridgeChildThread()
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
return ImageBridgeChild::IsCreated() &&
|
|
|
|
sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId();
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
GetMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(&ConnectImageBridge,
|
2012-07-13 12:38:09 -07:00
|
|
|
this, aParent));
|
|
|
|
}
|
|
|
|
|
2013-06-23 22:28:22 -07:00
|
|
|
void
|
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(const TextureFactoryIdentifier& aIdentifier)
|
|
|
|
{
|
|
|
|
if (sImageBridgeChildSingleton) {
|
|
|
|
sImageBridgeChildSingleton->IdentifyTextureHost(aIdentifier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
TemporaryRef<ImageClient>
|
|
|
|
ImageBridgeChild::CreateImageClient(CompositableType aType)
|
2012-07-13 12:38:09 -07: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 02:20:52 -07:00
|
|
|
return CreateImageClientNow(aType);
|
|
|
|
}
|
|
|
|
ReentrantMonitor barrier("CreateImageClient Lock");
|
2012-07-13 12:38:09 -07: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 02:20:52 -07: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 12:38:09 -07: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 02:20:52 -07:00
|
|
|
TemporaryRef<ImageClient>
|
|
|
|
ImageBridgeChild::CreateImageClientNow(CompositableType aType)
|
2012-07-13 12:38:09 -07:00
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!sImageBridgeChildSingleton->mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
RefPtr<ImageClient> client
|
2013-04-16 14:36:06 -07:00
|
|
|
= ImageClient::CreateImageClient(aType, this, 0);
|
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 02:20:52 -07:00
|
|
|
MOZ_ASSERT(client, "failed to create ImageClient");
|
|
|
|
if (client) {
|
|
|
|
client->Connect();
|
|
|
|
}
|
|
|
|
return client.forget();
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
2014-04-25 09:51:11 -07:00
|
|
|
PGrallocBufferChild*
|
|
|
|
ImageBridgeChild::AllocPGrallocBufferChild(const IntSize&, const uint32_t&, const uint32_t&,
|
|
|
|
MaybeMagicGrallocBufferHandle*)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
return GrallocBufferActor::Create();
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No gralloc buffers for you");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
delete actor;
|
|
|
|
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 02:20:52 -07:00
|
|
|
bool
|
|
|
|
ImageBridgeChild::AllocUnsafeShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
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)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
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 02:20:52 -07:00
|
|
|
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 {
|
2013-12-03 10:44:38 -08:00
|
|
|
RefPtr<ISurfaceAllocator> mAllocator;
|
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 02:20:52 -07:00
|
|
|
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,
|
2013-08-11 16:17:23 -07:00
|
|
|
ipc::Shmem* aShmem,
|
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 02:20:52 -07:00
|
|
|
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,
|
2013-08-11 16:17:23 -07:00
|
|
|
ipc::Shmem* aShmem,
|
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 02:20:52 -07:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 09:51:11 -07:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
|
|
|
#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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-11 17:44:44 -08:00
|
|
|
PTextureChild*
|
2014-01-21 14:06:18 -08:00
|
|
|
ImageBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
|
|
|
const TextureFlags&)
|
2013-12-11 17:44:44 -08:00
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
2013-12-11 17:44:44 -08:00
|
|
|
return TextureClient::CreateIPDLActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocPTextureChild(PTextureChild* actor)
|
|
|
|
{
|
|
|
|
return TextureClient::DestroyIPDLActor(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
PTextureChild*
|
2014-01-21 14:06:18 -08:00
|
|
|
ImageBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
|
|
|
|
TextureFlags aFlags)
|
2013-12-11 17:44:44 -08:00
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
2014-01-21 14:06:18 -08:00
|
|
|
return SendPTextureConstructor(aSharedData, aFlags);
|
2013-12-11 17:44:44 -08:00
|
|
|
}
|
|
|
|
|
2014-02-10 12:52:35 -08:00
|
|
|
void
|
|
|
|
ImageBridgeChild::RemoveTextureFromCompositable(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture)
|
|
|
|
{
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
2014-02-10 12:52:35 -08:00
|
|
|
if (aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
|
|
|
|
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
|
|
|
|
nullptr, aTexture->GetIPDLActor()));
|
|
|
|
} else {
|
|
|
|
mTxn->AddNoSwapEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
|
|
|
|
nullptr, aTexture->GetIPDLActor()));
|
|
|
|
}
|
|
|
|
// Hold texture until transaction complete.
|
|
|
|
HoldUntilTransaction(aTexture);
|
|
|
|
}
|
|
|
|
|
2013-12-11 17:44:45 -08:00
|
|
|
static void RemoveTextureSync(TextureClient* aTexture, ReentrantMonitor* aBarrier, bool* aDone)
|
|
|
|
{
|
|
|
|
aTexture->ForceRemove();
|
|
|
|
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBridgeChild::RemoveTexture(TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
2014-04-25 04:55:36 -07:00
|
|
|
MOZ_ASSERT(!mShuttingDown);
|
2013-12-11 17:44:45 -08:00
|
|
|
aTexture->ForceRemove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReentrantMonitor barrier("RemoveTexture Lock");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&RemoveTextureSync, aTexture, &barrier, &done));
|
|
|
|
|
|
|
|
// should stop the thread until the ImageClient has been created on
|
|
|
|
// the other thread
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 05:12:49 -08:00
|
|
|
bool ImageBridgeChild::IsSameProcess() const
|
|
|
|
{
|
|
|
|
return OtherProcess() == ipc::kInvalidProcessHandle;
|
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
} // layers
|
|
|
|
} // mozilla
|