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
|
2014-12-18 18:32:45 +00:00
|
|
|
#include "gfxUtils.h"
|
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-10-07 18:37:15 +00:00
|
|
|
// Send pending AsyncMessages before deleting CompositableChild.
|
|
|
|
// They might have dependency to the mCompositableChild.
|
|
|
|
mForwarder->SendPendingAsyncMessges();
|
|
|
|
// Delete CompositableChild.
|
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;
|
|
|
|
}
|
2014-11-13 15:53:49 +00:00
|
|
|
aClient->SetAddedToCompositableClient();
|
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-11-13 15:53:49 +00:00
|
|
|
void
|
|
|
|
CompositableClient::ClearCachedResources()
|
|
|
|
{
|
|
|
|
if (mTextureClientRecycler) {
|
|
|
|
mTextureClientRecycler = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 15:25:23 +00:00
|
|
|
void
|
|
|
|
CompositableClient::RemoveTexture(TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
mForwarder->RemoveTextureFromCompositable(this, aTexture);
|
|
|
|
}
|
|
|
|
|
2014-11-13 15:53:49 +00:00
|
|
|
TextureClientRecycleAllocator*
|
|
|
|
CompositableClient::GetTextureClientRecycler()
|
|
|
|
{
|
|
|
|
if (mTextureClientRecycler) {
|
|
|
|
return mTextureClientRecycler;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mForwarder) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mTextureClientRecycler =
|
|
|
|
new layers::TextureClientRecycleAllocator(mForwarder);
|
|
|
|
return mTextureClientRecycler;
|
|
|
|
}
|
|
|
|
|
2014-12-18 18:32:45 +00:00
|
|
|
void
|
|
|
|
CompositableClient::DumpTextureClient(std::stringstream& aStream, TextureClient* aTexture)
|
|
|
|
{
|
|
|
|
if (!aTexture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
|
|
|
|
if (!dSurf) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
|
|
|
|
}
|
|
|
|
|
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
|