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
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
#include "mozilla/layers/CompositableClient.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
#include <stdint.h> // for uint64_t, uint32_t
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2013-08-12 02:21:17 +00:00
|
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
2014-04-03 06:04:04 +00:00
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
2014-04-28 11:29:13 +00:00
|
|
|
#include "mozilla/layers/PCompositableChild.h"
|
2013-05-03 17:34:29 +00:00
|
|
|
#ifdef XP_WIN
|
2014-03-07 21:34:04 +00:00
|
|
|
#include "gfxWindowsPlatform.h" // for gfxWindowsPlatform
|
2013-05-03 17:34:29 +00:00
|
|
|
#include "mozilla/layers/TextureD3D11.h"
|
2014-03-07 21:34:04 +00:00
|
|
|
#include "mozilla/layers/TextureD3D9.h"
|
2014-02-13 14:46:59 +00:00
|
|
|
#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
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-05-22 10:11:45 +00:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2014-04-24 18:13:59 +00:00
|
|
|
/**
|
|
|
|
* IPDL actor used by CompositableClient to match with its corresponding
|
|
|
|
* CompositableHost on the compositor side.
|
|
|
|
*
|
|
|
|
* CompositableChild is owned by a CompositableClient.
|
|
|
|
*/
|
|
|
|
class CompositableChild : public PCompositableChild
|
2014-05-12 14:39:25 +00:00
|
|
|
, public AsyncTransactionTrackersHolder
|
2014-04-24 18:13:59 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CompositableChild()
|
|
|
|
: mCompositableClient(nullptr), mAsyncID(0)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositableChild);
|
|
|
|
}
|
|
|
|
|
2014-05-12 14:39:25 +00:00
|
|
|
virtual ~CompositableChild()
|
2014-04-24 18:13:59 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositableChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason) MOZ_OVERRIDE {
|
2014-05-12 14:39:25 +00:00
|
|
|
DestroyAsyncTransactionTrackersHolder();
|
2014-04-24 18:13:59 +00:00
|
|
|
if (mCompositableClient) {
|
|
|
|
mCompositableClient->mCompositableChild = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositableClient* mCompositableClient;
|
|
|
|
|
|
|
|
uint64_t mAsyncID;
|
|
|
|
};
|
|
|
|
|
2014-06-27 13:26:51 +00:00
|
|
|
void
|
|
|
|
RemoveTextureFromCompositableTracker::ReleaseTextureClient()
|
|
|
|
{
|
2014-07-15 13:22:35 +00:00
|
|
|
if (mTextureClient &&
|
|
|
|
mTextureClient->GetAllocator() &&
|
|
|
|
!mTextureClient->GetAllocator()->IsImageBridgeChild())
|
|
|
|
{
|
2014-06-27 13:26:51 +00:00
|
|
|
TextureClientReleaseTask* task = new TextureClientReleaseTask(mTextureClient);
|
|
|
|
RefPtr<ISurfaceAllocator> allocator = mTextureClient->GetAllocator();
|
|
|
|
mTextureClient = nullptr;
|
|
|
|
allocator->GetMessageLoop()->PostTask(FROM_HERE, task);
|
2014-07-15 13:22:35 +00:00
|
|
|
} else {
|
|
|
|
mTextureClient = nullptr;
|
2014-06-27 13:26:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-12 14:39:25 +00:00
|
|
|
/* static */ void
|
|
|
|
CompositableClient::TransactionCompleteted(PCompositableChild* aActor, uint64_t aTransactionId)
|
|
|
|
{
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(aActor);
|
|
|
|
child->TransactionCompleteted(aTransactionId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
CompositableClient::HoldUntilComplete(PCompositableChild* aActor, AsyncTransactionTracker* aTracker)
|
|
|
|
{
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(aActor);
|
|
|
|
child->HoldUntilComplete(aTracker);
|
|
|
|
}
|
|
|
|
|
2014-05-24 16:14:45 +00:00
|
|
|
/* static */ uint64_t
|
|
|
|
CompositableClient::GetTrackersHolderId(PCompositableChild* aActor)
|
|
|
|
{
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(aActor);
|
|
|
|
return child->GetId();
|
|
|
|
}
|
|
|
|
|
2014-05-12 14:39:25 +00:00
|
|
|
/* static */ PCompositableChild*
|
2014-04-24 18:13:59 +00:00
|
|
|
CompositableClient::CreateIPDLActor()
|
|
|
|
{
|
|
|
|
return new CompositableChild();
|
|
|
|
}
|
|
|
|
|
2014-05-12 14:39:25 +00:00
|
|
|
/* static */ bool
|
2014-04-24 18:13:59 +00:00
|
|
|
CompositableClient::DestroyIPDLActor(PCompositableChild* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositableClient::InitIPDLActor(PCompositableChild* aActor, uint64_t aAsyncID)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(aActor);
|
|
|
|
mCompositableChild = child;
|
|
|
|
child->mCompositableClient = this;
|
|
|
|
child->mAsyncID = aAsyncID;
|
|
|
|
}
|
|
|
|
|
2014-05-12 14:39:25 +00:00
|
|
|
/* static */ CompositableClient*
|
2014-04-24 18:13:59 +00:00
|
|
|
CompositableClient::FromIPDLActor(PCompositableChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return static_cast<CompositableChild*>(aActor)->mCompositableClient;
|
|
|
|
}
|
|
|
|
|
2014-03-07 21:34:04 +00:00
|
|
|
CompositableClient::CompositableClient(CompositableForwarder* aForwarder,
|
|
|
|
TextureFlags aTextureFlags)
|
2013-12-12 01:44:47 +00:00
|
|
|
: mCompositableChild(nullptr)
|
2013-07-30 09:59:51 +00:00
|
|
|
, mForwarder(aForwarder)
|
2014-03-07 21:34:04 +00:00
|
|
|
, mTextureFlags(aTextureFlags)
|
2013-07-30 09:59:51 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositableClient);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
CompositableClient::~CompositableClient()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositableClient);
|
|
|
|
Destroy();
|
2013-09-12 14:50:35 +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
|
|
|
LayersBackend
|
|
|
|
CompositableClient::GetCompositorBackendType() const
|
|
|
|
{
|
|
|
|
return mForwarder->GetCompositorBackendType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositableClient::SetIPDLActor(CompositableChild* aChild)
|
|
|
|
{
|
|
|
|
mCompositableChild = aChild;
|
|
|
|
}
|
|
|
|
|
2014-04-24 18:13:59 +00:00
|
|
|
PCompositableChild*
|
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
|
|
|
CompositableClient::GetIPDLActor() const
|
|
|
|
{
|
|
|
|
return mCompositableChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositableClient::Connect()
|
|
|
|
{
|
|
|
|
if (!GetForwarder() || GetIPDLActor()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
GetForwarder()->Connect(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositableClient::Destroy()
|
|
|
|
{
|
|
|
|
if (!mCompositableChild) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-24 18:13:59 +00:00
|
|
|
mCompositableChild->mCompositableClient = nullptr;
|
|
|
|
PCompositableChild::Send__delete__(mCompositableChild);
|
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
|
|
|
mCompositableChild = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
CompositableClient::GetAsyncID() const
|
|
|
|
{
|
|
|
|
if (mCompositableChild) {
|
2014-04-24 18:13:59 +00:00
|
|
|
return mCompositableChild->mAsyncID;
|
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 0; // zero is always an invalid async ID
|
|
|
|
}
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
TemporaryRef<BufferTextureClient>
|
2014-07-22 12:17:31 +00:00
|
|
|
CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gfx::BackendType aMoz2DBackend,
|
|
|
|
TextureFlags aTextureFlags)
|
|
|
|
{
|
|
|
|
return TextureClient::CreateForRawBufferAccess(GetForwarder(),
|
|
|
|
aFormat, aSize, aMoz2DBackend,
|
|
|
|
aTextureFlags | mTextureFlags);
|
2014-02-13 14:46:59 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 18:39:22 +00:00
|
|
|
TemporaryRef<TextureClient>
|
2014-07-10 11:45:40 +00:00
|
|
|
CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
2014-07-09 11:23:08 +00:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2014-07-10 11:45:40 +00:00
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags)
|
2013-12-05 18:39:22 +00:00
|
|
|
{
|
2014-07-10 11:45:40 +00:00
|
|
|
return TextureClient::CreateForDrawing(GetForwarder(),
|
|
|
|
aFormat, aSize, aMoz2DBackend,
|
|
|
|
aTextureFlags | mTextureFlags,
|
|
|
|
aAllocFlags);
|
2013-12-05 18:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositableClient::AddTextureClient(TextureClient* aClient)
|
|
|
|
{
|
2014-07-04 13:16:13 +00:00
|
|
|
if(!aClient || !aClient->IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-12 01:44:44 +00:00
|
|
|
return aClient->InitIPDLActor(mForwarder);
|
2013-12-11 19:52:50 +00:00
|
|
|
}
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
void
|
|
|
|
CompositableClient::OnTransaction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-08 13:18:53 +00:00
|
|
|
void
|
|
|
|
CompositableClient::UseTexture(TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
if (!aTexture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
|
|
FenceHandle handle = aTexture->GetAcquireFenceHandle();
|
|
|
|
if (handle.IsValid()) {
|
|
|
|
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(handle);
|
|
|
|
mForwarder->SendFenceHandle(tracker, aTexture->GetIPDLActor(), handle);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mForwarder->UseTexture(this, aTexture);
|
|
|
|
}
|
|
|
|
|
2014-05-16 15:25:23 +00:00
|
|
|
void
|
|
|
|
CompositableClient::RemoveTexture(TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
mForwarder->RemoveTextureFromCompositable(this, aTexture);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|