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
|
|
|
/* -*- 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 16:17:23 -07:00
|
|
|
#include <stdint.h> // for uint64_t, uint32_t
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2013-08-11 19:21:17 -07:00
|
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
2014-04-02 23:04:04 -07:00
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
2014-04-28 04:29:13 -07:00
|
|
|
#include "mozilla/layers/PCompositableChild.h"
|
2013-05-03 10:34:29 -07:00
|
|
|
#ifdef XP_WIN
|
2014-03-07 13:34:04 -08:00
|
|
|
#include "gfxWindowsPlatform.h" // for gfxWindowsPlatform
|
2013-05-03 10:34:29 -07:00
|
|
|
#include "mozilla/layers/TextureD3D11.h"
|
2014-03-07 13:34:04 -08:00
|
|
|
#include "mozilla/layers/TextureD3D9.h"
|
2014-02-13 06:46:59 -08: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 02:20:52 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2014-04-24 11:13:59 -07: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 07:39:25 -07:00
|
|
|
, public AsyncTransactionTrackersHolder
|
2014-04-24 11:13:59 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CompositableChild()
|
|
|
|
: mCompositableClient(nullptr), mAsyncID(0)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositableChild);
|
|
|
|
}
|
|
|
|
|
2014-05-12 07:39:25 -07:00
|
|
|
virtual ~CompositableChild()
|
2014-04-24 11:13:59 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositableChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason) MOZ_OVERRIDE {
|
2014-05-12 07:39:25 -07:00
|
|
|
DestroyAsyncTransactionTrackersHolder();
|
2014-04-24 11:13:59 -07:00
|
|
|
if (mCompositableClient) {
|
|
|
|
mCompositableClient->mCompositableChild = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositableClient* mCompositableClient;
|
|
|
|
|
|
|
|
uint64_t mAsyncID;
|
|
|
|
};
|
|
|
|
|
2014-06-27 06:26:51 -07:00
|
|
|
void
|
|
|
|
RemoveTextureFromCompositableTracker::ReleaseTextureClient()
|
|
|
|
{
|
2014-07-15 06:22:35 -07:00
|
|
|
if (mTextureClient &&
|
|
|
|
mTextureClient->GetAllocator() &&
|
|
|
|
!mTextureClient->GetAllocator()->IsImageBridgeChild())
|
|
|
|
{
|
2014-06-27 06:26:51 -07:00
|
|
|
TextureClientReleaseTask* task = new TextureClientReleaseTask(mTextureClient);
|
|
|
|
RefPtr<ISurfaceAllocator> allocator = mTextureClient->GetAllocator();
|
|
|
|
mTextureClient = nullptr;
|
|
|
|
allocator->GetMessageLoop()->PostTask(FROM_HERE, task);
|
2014-07-15 06:22:35 -07:00
|
|
|
} else {
|
|
|
|
mTextureClient = nullptr;
|
2014-06-27 06:26:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-12 07:39:25 -07: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 09:14:45 -07:00
|
|
|
/* static */ uint64_t
|
|
|
|
CompositableClient::GetTrackersHolderId(PCompositableChild* aActor)
|
|
|
|
{
|
|
|
|
CompositableChild* child = static_cast<CompositableChild*>(aActor);
|
|
|
|
return child->GetId();
|
|
|
|
}
|
|
|
|
|
2014-05-12 07:39:25 -07:00
|
|
|
/* static */ PCompositableChild*
|
2014-04-24 11:13:59 -07:00
|
|
|
CompositableClient::CreateIPDLActor()
|
|
|
|
{
|
|
|
|
return new CompositableChild();
|
|
|
|
}
|
|
|
|
|
2014-05-12 07:39:25 -07:00
|
|
|
/* static */ bool
|
2014-04-24 11:13:59 -07: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 07:39:25 -07:00
|
|
|
/* static */ CompositableClient*
|
2014-04-24 11:13:59 -07:00
|
|
|
CompositableClient::FromIPDLActor(PCompositableChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return static_cast<CompositableChild*>(aActor)->mCompositableClient;
|
|
|
|
}
|
|
|
|
|
2014-03-07 13:34:04 -08:00
|
|
|
CompositableClient::CompositableClient(CompositableForwarder* aForwarder,
|
|
|
|
TextureFlags aTextureFlags)
|
2013-12-11 17:44:47 -08:00
|
|
|
: mCompositableChild(nullptr)
|
2013-07-30 02:59:51 -07:00
|
|
|
, mForwarder(aForwarder)
|
2014-03-07 13:34:04 -08:00
|
|
|
, mTextureFlags(aTextureFlags)
|
2013-07-30 02:59:51 -07: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 02:20:52 -07:00
|
|
|
CompositableClient::~CompositableClient()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositableClient);
|
|
|
|
Destroy();
|
2013-09-12 07:50:35 -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
|
|
|
LayersBackend
|
|
|
|
CompositableClient::GetCompositorBackendType() const
|
|
|
|
{
|
|
|
|
return mForwarder->GetCompositorBackendType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositableClient::SetIPDLActor(CompositableChild* aChild)
|
|
|
|
{
|
|
|
|
mCompositableChild = aChild;
|
|
|
|
}
|
|
|
|
|
2014-04-24 11:13:59 -07: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 02:20:52 -07: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 11:13:59 -07: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 02:20:52 -07:00
|
|
|
mCompositableChild = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
CompositableClient::GetAsyncID() const
|
|
|
|
{
|
|
|
|
if (mCompositableChild) {
|
2014-04-24 11:13:59 -07: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 02:20:52 -07:00
|
|
|
}
|
|
|
|
return 0; // zero is always an invalid async ID
|
|
|
|
}
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
TemporaryRef<BufferTextureClient>
|
2014-07-22 05:17:31 -07: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 06:46:59 -08:00
|
|
|
}
|
|
|
|
|
2013-12-05 10:39:22 -08:00
|
|
|
TemporaryRef<TextureClient>
|
2014-07-10 04:45:40 -07:00
|
|
|
CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
2014-07-09 04:23:08 -07:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2014-07-10 04:45:40 -07:00
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags)
|
2013-12-05 10:39:22 -08:00
|
|
|
{
|
2014-07-10 04:45:40 -07:00
|
|
|
return TextureClient::CreateForDrawing(GetForwarder(),
|
|
|
|
aFormat, aSize, aMoz2DBackend,
|
|
|
|
aTextureFlags | mTextureFlags,
|
|
|
|
aAllocFlags);
|
2013-12-05 10:39:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositableClient::AddTextureClient(TextureClient* aClient)
|
|
|
|
{
|
2014-07-04 06:16:13 -07:00
|
|
|
if(!aClient || !aClient->IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-11 17:44:44 -08:00
|
|
|
return aClient->InitIPDLActor(mForwarder);
|
2013-12-11 11:52:50 -08:00
|
|
|
}
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
void
|
|
|
|
CompositableClient::OnTransaction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-08 06:18:53 -07: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 08:25:23 -07: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 02:20:52 -07:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|