2012-07-17 16:59:45 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-01-19 06:45:37 -08:00
|
|
|
/* vim: set sw=2 ts=2 et tw=80 : */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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-01-19 06:45:37 -08:00
|
|
|
|
|
|
|
#include "CompositorChild.h"
|
|
|
|
#include "CompositorParent.h"
|
|
|
|
#include "LayerManagerOGL.h"
|
|
|
|
#include "mozilla/layers/ShadowLayersChild.h"
|
|
|
|
|
|
|
|
using mozilla::layers::ShadowLayersChild;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
/*static*/ CompositorChild* CompositorChild::sCompositor;
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
CompositorChild::CompositorChild(LayerManager *aLayerManager)
|
|
|
|
: mLayerManager(aLayerManager)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositorChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositorChild::~CompositorChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositorChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorChild::Destroy()
|
|
|
|
{
|
2013-04-12 00:28:55 -07:00
|
|
|
mLayerManager->Destroy();
|
2012-01-19 06:45:37 -08:00
|
|
|
mLayerManager = NULL;
|
2012-07-17 16:59:45 -07:00
|
|
|
while (size_t len = ManagedPLayersChild().Length()) {
|
2012-01-19 06:45:37 -08:00
|
|
|
ShadowLayersChild* layers =
|
2012-07-17 16:59:45 -07:00
|
|
|
static_cast<ShadowLayersChild*>(ManagedPLayersChild()[len - 1]);
|
2012-01-19 06:45:37 -08:00
|
|
|
layers->Destroy();
|
|
|
|
}
|
|
|
|
SendStop();
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
/*static*/ PCompositorChild*
|
|
|
|
CompositorChild::Create(Transport* aTransport, ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
// There's only one compositor per child process.
|
|
|
|
MOZ_ASSERT(!sCompositor);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsRefPtr<CompositorChild> child(new CompositorChild(nullptr));
|
2012-07-17 16:59:45 -07:00
|
|
|
ProcessHandle handle;
|
|
|
|
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
|
|
|
// We can't go on without a compositor.
|
|
|
|
NS_RUNTIMEABORT("Couldn't OpenProcessHandle() to parent process.");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
if (!child->Open(aTransport, handle, XRE_GetIOMessageLoop(),
|
|
|
|
AsyncChannel::Child)) {
|
|
|
|
NS_RUNTIMEABORT("Couldn't Open() Compositor channel.");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-07-17 16:59:45 -07:00
|
|
|
}
|
|
|
|
// We release this ref in ActorDestroy().
|
|
|
|
return sCompositor = child.forget().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ PCompositorChild*
|
|
|
|
CompositorChild::Get()
|
|
|
|
{
|
|
|
|
// This is only expected to be used in child processes.
|
|
|
|
MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
|
|
|
|
return sCompositor;
|
|
|
|
}
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
PLayersChild*
|
2012-07-17 16:59:45 -07:00
|
|
|
CompositorChild::AllocPLayers(const LayersBackend& aBackendHint,
|
|
|
|
const 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 02:20:52 -07:00
|
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier)
|
2012-01-19 06:45:37 -08:00
|
|
|
{
|
|
|
|
return new ShadowLayersChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositorChild::DeallocPLayers(PLayersChild* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
void
|
|
|
|
CompositorChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(sCompositor == this);
|
|
|
|
sCompositor = NULL;
|
|
|
|
// We don't want to release the ref to sCompositor here, during
|
|
|
|
// cleanup, because that will cause it to be deleted while it's
|
|
|
|
// still being used. So defer the deletion to after it's not in
|
|
|
|
// use.
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &CompositorChild::Release));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|