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