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 "ImageBridgeChild.h"
|
2013-08-11 23:17:23 +00: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-28 01:42:08 +00:00
|
|
|
#include "mozilla/ipc/MessageChannel.h" // for MessageChannel, etc
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/ipc/Transport.h" // for Transport
|
2013-12-20 16:46:28 +00:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-11 23:17:23 +00: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 15:41:00 +00:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for CompositableOperation
|
2013-08-11 23:17:23 +00: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 11:34:40 +00:00
|
|
|
#include "mozilla/StaticPtr.h" // for StaticRefPtr
|
2013-12-12 01:44:44 +00:00
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
|
|
|
|
struct nsIntRect;
|
2013-04-28 06:46:30 +00:00
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
using namespace base;
|
2012-08-29 12:24:48 +00:00
|
|
|
using namespace mozilla::ipc;
|
2013-12-20 16:46:28 +00:00
|
|
|
using namespace mozilla::gfx;
|
2012-07-13 19:38:09 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-08-11 23:17:23 +00:00
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 23:17:23 +00: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 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;
|
|
|
|
};
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
2013-12-12 01:44:44 +00:00
|
|
|
nullptr, aTexture->GetIPDLActor()));
|
2013-07-30 09:59:51 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 11:28:29 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UseComponentAlphaTextures(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTextureOnBlack,
|
|
|
|
TextureClient* aTextureOnWhite)
|
|
|
|
{
|
|
|
|
mTxn->AddNoSwapEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
|
|
|
|
nullptr, aTextureOnBlack->GetIPDLActor(),
|
|
|
|
nullptr, aTextureOnWhite->GetIPDLActor()));
|
|
|
|
}
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture,
|
|
|
|
nsIntRegion* aRegion)
|
|
|
|
{
|
|
|
|
MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
|
|
|
|
: MaybeRegion(null_t());
|
|
|
|
mTxn->AddNoSwapEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
|
2013-12-12 01:44:44 +00:00
|
|
|
nullptr, aTexture->GetIPDLActor(),
|
2013-07-30 09:59:51 +00: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 09:20:52 +00:00
|
|
|
void
|
2013-04-12 07:28:55 +00:00
|
|
|
ImageBridgeChild::UpdateTexture(CompositableClient* aCompositable,
|
|
|
|
TextureIdentifier aTextureId,
|
|
|
|
SurfaceDescriptor* aDescriptor)
|
|
|
|
{
|
|
|
|
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
|
|
|
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
|
|
|
mTxn->AddEdit(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
|
|
|
SurfaceDescriptor(*aDescriptor)));
|
|
|
|
*aDescriptor = SurfaceDescriptor();
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-05-01 23:24:27 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdateTextureNoSwap(CompositableClient* aCompositable,
|
|
|
|
TextureIdentifier aTextureId,
|
|
|
|
SurfaceDescriptor* aDescriptor)
|
|
|
|
{
|
|
|
|
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
|
|
|
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
|
|
|
MOZ_ASSERT(aCompositable);
|
|
|
|
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
|
|
|
mTxn->AddNoSwapEdit(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
|
|
|
SurfaceDescriptor(*aDescriptor)));
|
|
|
|
*aDescriptor = SurfaceDescriptor();
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void
|
|
|
|
ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable,
|
|
|
|
const nsIntRect& aRect)
|
|
|
|
{
|
|
|
|
mTxn->AddNoSwapEdit(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Singleton
|
2013-11-27 15:19:34 +00:00
|
|
|
static StaticRefPtr<ImageBridgeChild> sImageBridgeChildSingleton;
|
2013-11-01 11:34:40 +00:00
|
|
|
static StaticRefPtr<ImageBridgeParent> sImageBridgeParentSingleton;
|
2012-07-30 14:20:58 +00:00
|
|
|
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.");
|
2012-07-30 14:20:58 +00:00
|
|
|
sImageBridgeChildSingleton = nullptr;
|
2013-10-02 03:05:34 +00:00
|
|
|
sImageBridgeParentSingleton = 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 {
|
2013-12-20 16:46:28 +00:00
|
|
|
IntSize size;
|
2012-08-17 10:56:55 +00:00
|
|
|
uint32_t format;
|
|
|
|
uint32_t usage;
|
|
|
|
SurfaceDescriptor* buffer;
|
|
|
|
|
2013-12-20 16:46:28 +00:00
|
|
|
GrallocParam(const IntSize& aSize,
|
2012-08-17 10:56:55 +00:00
|
|
|
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();
|
2013-09-28 01:42:08 +00:00
|
|
|
ipc::MessageChannel *parentChannel = parent->GetIPCChannel();
|
|
|
|
child->Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
|
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
|
|
|
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*>(
|
2013-04-12 07:28:55 +00:00
|
|
|
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 09:20:52 +00:00
|
|
|
MOZ_ASSERT(child);
|
|
|
|
child->SetAsyncID(id);
|
|
|
|
aCompositable->SetIPDLActor(child);
|
|
|
|
MOZ_ASSERT(child->GetAsyncID() == id);
|
|
|
|
child->SetClient(aCompositable);
|
|
|
|
}
|
|
|
|
|
|
|
|
PCompositableChild*
|
2013-07-08 15:48:39 +00: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 09:20:52 +00:00
|
|
|
{
|
|
|
|
return new CompositableChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 15:48:39 +00: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 09:20:52 +00:00
|
|
|
{
|
|
|
|
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(),
|
2013-09-28 01:42:08 +00:00
|
|
|
ipc::ChildSide);
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 10:14:42 +00:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
#include "ipc/Nuwa.h"
|
|
|
|
#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
|
|
|
static void ReleaseImageClientNow(ImageClient* aClient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(InImageBridgeChildThread());
|
|
|
|
aClient->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* aClient)
|
|
|
|
{
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ReleaseImageClientNow, aClient));
|
|
|
|
}
|
|
|
|
|
2013-10-02 03:05:35 +00:00
|
|
|
static void ReleaseTextureClientNow(TextureClient* aClient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(InImageBridgeChildThread());
|
|
|
|
aClient->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void ImageBridgeChild::DispatchReleaseTextureClient(TextureClient* aClient)
|
|
|
|
{
|
|
|
|
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 09:20:52 +00: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 09:59:51 +00: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 09:20:52 +00:00
|
|
|
sImageBridgeChildSingleton->EndTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
|
|
|
void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient,
|
|
|
|
ImageContainer* aContainer)
|
|
|
|
{
|
2013-05-30 12:10:02 +00: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 09:20:52 +00:00
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
2013-07-18 06:33:28 +00: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 09:20:52 +00:00
|
|
|
}
|
|
|
|
|
2013-10-17 15:09:15 +00:00
|
|
|
static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront, ReentrantMonitor* aBarrier, bool* aDone)
|
2013-09-12 14:50:28 +00:00
|
|
|
{
|
2013-10-17 15:09:15 +00:00
|
|
|
ImageBridgeChild::FlushAllImagesNow(aClient, aContainer, aExceptFront);
|
2013-09-12 14:50:28 +00:00
|
|
|
|
|
|
|
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
|
|
|
*aDone = true;
|
|
|
|
aBarrier->NotifyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2013-10-17 15:09:15 +00:00
|
|
|
void ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
|
2013-09-12 14:50:28 +00:00
|
|
|
{
|
|
|
|
if (InImageBridgeChildThread()) {
|
2013-10-17 15:09:15 +00:00
|
|
|
FlushAllImagesNow(aClient, aContainer, aExceptFront);
|
2013-09-12 14:50:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReentrantMonitor barrier("CreateImageClient Lock");
|
|
|
|
ReentrantMonitorAutoEnter autoMon(barrier);
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
2013-10-17 15:09:15 +00:00
|
|
|
NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, aExceptFront, &barrier, &done));
|
2013-09-12 14:50:28 +00:00
|
|
|
|
|
|
|
// should stop the thread until the ImageClient has been created on
|
|
|
|
// the other thread
|
|
|
|
while (!done) {
|
|
|
|
barrier.Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2013-10-17 15:09:15 +00:00
|
|
|
void ImageBridgeChild::FlushAllImagesNow(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
|
2013-09-12 14:50:28 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aClient);
|
|
|
|
sImageBridgeChildSingleton->BeginTransaction();
|
2013-10-17 15:09:15 +00:00
|
|
|
if (aContainer && !aExceptFront) {
|
2013-09-12 14:50:28 +00:00
|
|
|
aContainer->ClearCurrentImage();
|
|
|
|
}
|
2013-10-17 15:09:15 +00:00
|
|
|
aClient->FlushAllImages(aExceptFront);
|
2013-09-12 14:50:28 +00: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 09:20:52 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::BeginTransaction()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTxn->Finished(), "uncommitted txn?");
|
|
|
|
mTxn->Begin();
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:24:27 +00:00
|
|
|
class MOZ_STACK_CLASS AutoRemoveTextures
|
2014-01-23 14:31:12 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-10 02:24:27 +00:00
|
|
|
AutoRemoveTextures(ImageBridgeChild* aImageBridge)
|
2014-01-23 14:31:12 +00:00
|
|
|
: mImageBridge(aImageBridge) {}
|
|
|
|
|
2014-02-10 02:24:27 +00:00
|
|
|
~AutoRemoveTextures()
|
2014-01-23 14:31:12 +00:00
|
|
|
{
|
2014-02-10 02:24:27 +00:00
|
|
|
mImageBridge->RemoveTexturesIfNecessary();
|
2014-01-23 14:31:12 +00: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 09:20:52 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::EndTransaction()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mTxn->Finished(), "forgot BeginTransaction?");
|
|
|
|
|
|
|
|
AutoEndTransaction _(mTxn);
|
2014-02-10 02:24:27 +00: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 09:20:52 +00:00
|
|
|
|
2013-08-08 12:53:12 +00: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 09:20:52 +00: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 07:28:55 +00:00
|
|
|
|
|
|
|
CompositableChild* compositableChild =
|
|
|
|
static_cast<CompositableChild*>(ots.compositableChild());
|
|
|
|
|
|
|
|
MOZ_ASSERT(compositableChild);
|
|
|
|
|
|
|
|
compositableChild->GetCompositableClient()
|
|
|
|
->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 09:20:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-26 04:19:09 +00:00
|
|
|
PImageBridgeChild*
|
2012-08-29 12:24:48 +00: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-26 04:19:09 +00:00
|
|
|
return nullptr;
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
|
|
|
if (!sImageBridgeChildThread->Start()) {
|
2013-09-26 04:19:09 +00:00
|
|
|
return nullptr;
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 10:14:42 +00:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
sImageBridgeChildThread
|
|
|
|
->message_loop()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(NuwaMarkCurrentThread,
|
|
|
|
(void (*)(void *))nullptr,
|
|
|
|
(void *)nullptr));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-29 12:24:48 +00: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 09:20:52 +00:00
|
|
|
|
2013-09-26 04:19:09 +00:00
|
|
|
return sImageBridgeChildSingleton;
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
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();
|
2013-10-02 03:05:34 +00:00
|
|
|
sImageBridgeParentSingleton = new ImageBridgeParent(
|
2013-02-19 19:27:49 +00:00
|
|
|
CompositorParent::CompositorLoop(), nullptr);
|
2013-10-02 03:05:34 +00:00
|
|
|
sImageBridgeChildSingleton->ConnectAsync(sImageBridgeParentSingleton);
|
2012-07-13 19:38:09 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2013-06-24 05:28:22 +00: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 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
|
|
|
RefPtr<ImageClient> client
|
2013-04-16 21:36:06 +00: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 09:20:52 +00:00
|
|
|
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*
|
2013-12-20 16:46:28 +00:00
|
|
|
ImageBridgeChild::AllocPGrallocBufferChild(const IntSize&, const uint32_t&, const uint32_t&,
|
2013-07-08 15:48:39 +00:00
|
|
|
MaybeMagicGrallocBufferHandle*)
|
2012-08-17 10:56:55 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
return GrallocBufferActor::Create();
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No gralloc buffers for you");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 15:48:39 +00:00
|
|
|
ImageBridgeChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor)
|
2012-08-17 10:56:55 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Um, how did we get here?");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-12-20 16:46:28 +00:00
|
|
|
ImageBridgeChild::AllocSurfaceDescriptorGralloc(const IntSize& aSize,
|
2012-08-17 10:56:55 +00:00
|
|
|
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
|
2013-12-20 16:46:28 +00:00
|
|
|
ImageBridgeChild::AllocSurfaceDescriptorGrallocNow(const IntSize& aSize,
|
2012-08-17 10:56:55 +00:00
|
|
|
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-05-27 14:12:13 +00:00
|
|
|
*aBuffer = SurfaceDescriptorGralloc(nullptr, gc, aSize, /* external */ false, /* swapRB */ 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 {
|
2013-12-03 18:44:38 +00: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 09:20:52 +00: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 23:17:23 +00: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 09:20:52 +00: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 23:17:23 +00: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 09:20:52 +00: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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PGrallocBufferChild*
|
2013-12-20 16:46:28 +00:00
|
|
|
ImageBridgeChild::AllocGrallocBuffer(const IntSize& aSize,
|
2013-05-27 14:12:13 +00:00
|
|
|
uint32_t aFormat,
|
|
|
|
uint32_t aUsage,
|
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
|
|
|
MaybeMagicGrallocBufferHandle* aHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
return SendPGrallocBufferConstructor(aSize,
|
2013-05-27 14:12:13 +00:00
|
|
|
aFormat,
|
|
|
|
aUsage,
|
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
|
|
|
aHandle);
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("not implemented");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-12-12 01:44:44 +00:00
|
|
|
PTextureChild*
|
2014-01-21 22:06:18 +00:00
|
|
|
ImageBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
|
|
|
const TextureFlags&)
|
2013-12-12 01:44:44 +00:00
|
|
|
{
|
|
|
|
return TextureClient::CreateIPDLActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeChild::DeallocPTextureChild(PTextureChild* actor)
|
|
|
|
{
|
|
|
|
return TextureClient::DestroyIPDLActor(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
PTextureChild*
|
2014-01-21 22:06:18 +00:00
|
|
|
ImageBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
|
|
|
|
TextureFlags aFlags)
|
2013-12-12 01:44:44 +00:00
|
|
|
{
|
2014-01-21 22:06:18 +00:00
|
|
|
return SendPTextureConstructor(aSharedData, aFlags);
|
2013-12-12 01:44:44 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 20:52:35 +00:00
|
|
|
void
|
|
|
|
ImageBridgeChild::RemoveTextureFromCompositable(CompositableClient* aCompositable,
|
|
|
|
TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
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-12 01:44:45 +00: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()) {
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 19:38:09 +00:00
|
|
|
} // layers
|
|
|
|
} // mozilla
|