mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
Bug 711168 - Implement the compositor protocol for OMTC. r=cjones
This commit is contained in:
parent
c679b9cfa2
commit
daacfcbeb7
@ -131,12 +131,19 @@ endif
|
||||
EXPORTS_NAMESPACES = gfxipc mozilla/layers
|
||||
EXPORTS_gfxipc = ShadowLayerUtils.h
|
||||
EXPORTS_mozilla/layers =\
|
||||
CompositorCocoaWidgetHelper.h \
|
||||
CompositorChild.h \
|
||||
CompositorParent.h \
|
||||
ShadowLayers.h \
|
||||
ShadowLayersChild.h \
|
||||
ShadowLayersParent.h \
|
||||
ShadowLayersManager.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS += \
|
||||
CompositorCocoaWidgetHelper.cpp \
|
||||
CompositorChild.cpp \
|
||||
CompositorParent.cpp \
|
||||
ShadowLayers.cpp \
|
||||
ShadowLayerChild.cpp \
|
||||
ShadowLayersChild.cpp \
|
||||
|
93
gfx/layers/ipc/CompositorChild.cpp
Normal file
93
gfx/layers/ipc/CompositorChild.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=2 ts=2 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "CompositorChild.h"
|
||||
#include "CompositorParent.h"
|
||||
#include "LayerManagerOGL.h"
|
||||
#include "mozilla/layers/ShadowLayersChild.h"
|
||||
|
||||
using mozilla::layers::ShadowLayersChild;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
CompositorChild::CompositorChild(LayerManager *aLayerManager)
|
||||
: mLayerManager(aLayerManager)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositorChild);
|
||||
}
|
||||
|
||||
CompositorChild::~CompositorChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CompositorChild);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::Destroy()
|
||||
{
|
||||
mLayerManager = NULL;
|
||||
size_t numChildren = ManagedPLayersChild().Length();
|
||||
NS_ABORT_IF_FALSE(0 == numChildren || 1 == numChildren,
|
||||
"compositor must only have 0 or 1 layer forwarder");
|
||||
|
||||
if (numChildren) {
|
||||
ShadowLayersChild* layers =
|
||||
static_cast<ShadowLayersChild*>(ManagedPLayersChild()[0]);
|
||||
layers->Destroy();
|
||||
}
|
||||
SendStop();
|
||||
}
|
||||
|
||||
PLayersChild*
|
||||
CompositorChild::AllocPLayers(const LayersBackend &backend)
|
||||
{
|
||||
return new ShadowLayersChild();
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorChild::DeallocPLayers(PLayersChild* actor)
|
||||
{
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
73
gfx/layers/ipc/CompositorChild.h
Normal file
73
gfx/layers/ipc/CompositorChild.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_layers_CompositorChild_h
|
||||
#define mozilla_layers_CompositorChild_h
|
||||
|
||||
#include "mozilla/layers/PCompositorChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class LayerManager;
|
||||
class CompositorParent;
|
||||
|
||||
class CompositorChild : public PCompositorChild
|
||||
{
|
||||
NS_INLINE_DECL_REFCOUNTING(CompositorChild)
|
||||
public:
|
||||
CompositorChild(LayerManager *aLayerManager);
|
||||
virtual ~CompositorChild();
|
||||
|
||||
void Destroy();
|
||||
|
||||
protected:
|
||||
virtual PLayersChild* AllocPLayers(const LayersBackend &aBackend);
|
||||
virtual bool DeallocPLayers(PLayersChild *aChild);
|
||||
|
||||
private:
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorChild);
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
||||
|
||||
#endif // mozilla_layers_CompositorChild_h
|
58
gfx/layers/ipc/CompositorCocoaWidgetHelper.cpp
Normal file
58
gfx/layers/ipc/CompositorCocoaWidgetHelper.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=2 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "CompositorParent.h"
|
||||
#include "CompositorCocoaWidgetHelper.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
namespace compositor {
|
||||
|
||||
LayerManager*
|
||||
GetLayerManager(CompositorParent* aParent)
|
||||
{
|
||||
return aParent->GetLayerManager();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
gfx/layers/ipc/CompositorCocoaWidgetHelper.h
Normal file
63
gfx/layers/ipc/CompositorCocoaWidgetHelper.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_layers_CompositorCocoaWidgetHelper_h
|
||||
#define mozilla_layers_CompositorCocoaWidgetHelper_h
|
||||
|
||||
// Note we can't include IPDL-generated headers here, since this file is being
|
||||
// used as a workaround for Bug 719036.
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class CompositorParent;
|
||||
class LayerManager;
|
||||
|
||||
namespace compositor {
|
||||
|
||||
// Needed when we cannot directly include CompositorParent.h since it includes
|
||||
// an IPDL-generated header (e.g. in widget/cocoa/nsChildView.mm; see Bug 719036).
|
||||
LayerManager* GetLayerManager(CompositorParent* aParent);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // mozilla_layers_CompositorCocoaWidgetHelper_h
|
||||
|
159
gfx/layers/ipc/CompositorParent.cpp
Normal file
159
gfx/layers/ipc/CompositorParent.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=2 ts=2 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "CompositorParent.h"
|
||||
#include "ShadowLayersParent.h"
|
||||
#include "LayerManagerOGL.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
CompositorParent::CompositorParent(nsIWidget* aWidget)
|
||||
: mStopped(false), mWidget(aWidget)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositorParent);
|
||||
}
|
||||
|
||||
CompositorParent::~CompositorParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CompositorParent);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::Destroy()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(ManagedPLayersParent().Length() == 0,
|
||||
"CompositorParent destroyed before managed PLayersParent");
|
||||
|
||||
// Ensure that the layer manager is destroyed on the compositor thread.
|
||||
mLayerManager = NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorParent::RecvStop()
|
||||
{
|
||||
mStopped = true;
|
||||
Destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::ScheduleComposition()
|
||||
{
|
||||
CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::Composite);
|
||||
MessageLoop::current()->PostTask(FROM_HERE, composeTask);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::Composite()
|
||||
{
|
||||
if (mStopped || !mLayerManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
mLayerManager->EndEmptyTransaction();
|
||||
}
|
||||
|
||||
// Go down shadow layer tree, setting properties to match their non-shadow
|
||||
// counterparts.
|
||||
static void
|
||||
SetShadowProperties(Layer* aLayer)
|
||||
{
|
||||
// FIXME: Bug 717688 -- Do these updates in ShadowLayersParent::RecvUpdate.
|
||||
ShadowLayer* shadow = aLayer->AsShadowLayer();
|
||||
shadow->SetShadowTransform(aLayer->GetTransform());
|
||||
shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
|
||||
shadow->SetShadowClipRect(aLayer->GetClipRect());
|
||||
|
||||
for (Layer* child = aLayer->GetFirstChild();
|
||||
child; child = child->GetNextSibling()) {
|
||||
SetShadowProperties(child);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::ShadowLayersUpdated()
|
||||
{
|
||||
const nsTArray<PLayersParent*>& shadowParents = ManagedPLayersParent();
|
||||
NS_ABORT_IF_FALSE(shadowParents.Length() <= 1,
|
||||
"can only support at most 1 ShadowLayersParent");
|
||||
if (shadowParents.Length()) {
|
||||
Layer* root = static_cast<ShadowLayersParent*>(shadowParents[0])->GetRoot();
|
||||
mLayerManager->SetRoot(root);
|
||||
SetShadowProperties(root);
|
||||
}
|
||||
ScheduleComposition();
|
||||
}
|
||||
|
||||
PLayersParent*
|
||||
CompositorParent::AllocPLayers(const LayersBackend &backendType)
|
||||
{
|
||||
if (backendType == LayerManager::LAYERS_OPENGL) {
|
||||
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(mWidget);
|
||||
mWidget = NULL;
|
||||
mLayerManager = layerManager;
|
||||
|
||||
if (!layerManager->Initialize()) {
|
||||
NS_ERROR("Failed to init OGL Layers");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ShadowLayerManager* slm = layerManager->AsShadowManager();
|
||||
if (!slm) {
|
||||
return NULL;
|
||||
}
|
||||
return new ShadowLayersParent(slm, this);
|
||||
} else {
|
||||
NS_ERROR("Unsupported backend selected for Async Compositor");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorParent::DeallocPLayers(PLayersParent* actor)
|
||||
{
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
88
gfx/layers/ipc/CompositorParent.h
Normal file
88
gfx/layers/ipc/CompositorParent.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_layers_CompositorParent_h
|
||||
#define mozilla_layers_CompositorParent_h
|
||||
|
||||
#include "mozilla/layers/PCompositorParent.h"
|
||||
#include "mozilla/layers/PLayersParent.h"
|
||||
#include "ShadowLayersManager.h"
|
||||
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class LayerManager;
|
||||
|
||||
class CompositorParent : public PCompositorParent,
|
||||
public ShadowLayersManager
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorParent)
|
||||
public:
|
||||
CompositorParent(nsIWidget* aWidget);
|
||||
virtual ~CompositorParent();
|
||||
|
||||
virtual bool RecvStop() MOZ_OVERRIDE;
|
||||
|
||||
virtual void ShadowLayersUpdated() MOZ_OVERRIDE;
|
||||
void Destroy();
|
||||
|
||||
LayerManager* GetLayerManager() { return mLayerManager; }
|
||||
|
||||
protected:
|
||||
virtual PLayersParent* AllocPLayers(const LayersBackend &backendType);
|
||||
virtual bool DeallocPLayers(PLayersParent* aLayers);
|
||||
|
||||
private:
|
||||
void ScheduleComposition();
|
||||
void Composite();
|
||||
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
bool mStopped;
|
||||
nsIWidget* mWidget;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
||||
|
||||
#endif // mozilla_layers_CompositorParent_h
|
71
gfx/layers/ipc/PCompositor.ipdl
Normal file
71
gfx/layers/ipc/PCompositor.ipdl
Normal file
@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=8 et :
|
||||
*/
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benoit Girard <bgirard@mozilla.com>
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
include protocol PLayers;
|
||||
|
||||
using mozilla::LayersBackend;
|
||||
using mozilla::null_t;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* The PCompositor protocol is used to manage communication between
|
||||
* the main thread and the compositor thread context. It's primary
|
||||
* purpose is to manage the PLayers sub protocol.
|
||||
*/
|
||||
// This should really be 'sync', but we're using 'rpc' as a workaround
|
||||
// for Bug 716631.
|
||||
rpc protocol PCompositor
|
||||
{
|
||||
// A Compositor manages a single Layer Manager (PLayers)
|
||||
manages PLayers;
|
||||
|
||||
parent:
|
||||
|
||||
// Clean up in preparation for destruction.
|
||||
sync Stop();
|
||||
|
||||
sync PLayers(LayersBackend backend);
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
@ -38,7 +38,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//include protocol PCompositor;
|
||||
include protocol PCompositor;
|
||||
include protocol PLayer;
|
||||
include protocol PRenderFrame;
|
||||
|
||||
@ -226,7 +226,7 @@ union EditReply {
|
||||
|
||||
|
||||
sync protocol PLayers {
|
||||
manager PRenderFrame /*or PCompositor or PMedia or PPlugin*/;
|
||||
manager PRenderFrame or PCompositor;
|
||||
manages PLayer;
|
||||
|
||||
parent:
|
||||
|
63
gfx/layers/ipc/ShadowLayersManager.h
Normal file
63
gfx/layers/ipc/ShadowLayersManager.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Content App.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ali Juma <ajuma@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_layers_ShadowLayersManager_h
|
||||
#define mozilla_layers_ShadowLayersManager_h
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace layout {
|
||||
class RenderFrameParent;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
||||
class CompositorParent;
|
||||
|
||||
class ShadowLayersManager
|
||||
{
|
||||
|
||||
public:
|
||||
virtual void ShadowLayersUpdated() = 0;
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
||||
|
||||
#endif // mozilla_layers_ShadowLayersManager_h
|
@ -47,6 +47,7 @@
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "mozilla/layout/RenderFrameParent.h"
|
||||
#include "CompositorParent.h"
|
||||
|
||||
#include "gfxSharedImageSurface.h"
|
||||
|
||||
@ -121,11 +122,11 @@ ShadowChild(const OpRemoveChild& op)
|
||||
|
||||
//--------------------------------------------------
|
||||
// ShadowLayersParent
|
||||
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager)
|
||||
: mDestroyed(false)
|
||||
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager,
|
||||
ShadowLayersManager* aLayersManager)
|
||||
: mLayerManager(aManager), mShadowLayersManager(aLayersManager), mDestroyed(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ShadowLayersParent);
|
||||
mLayerManager = aManager;
|
||||
}
|
||||
|
||||
ShadowLayersParent::~ShadowLayersParent()
|
||||
@ -382,7 +383,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
// other's buffer contents.
|
||||
ShadowLayerManager::PlatformSyncBeforeReplyUpdate();
|
||||
|
||||
Frame()->ShadowLayersUpdated();
|
||||
mShadowLayersManager->ShadowLayersUpdated();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -400,12 +401,6 @@ ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
|
||||
return true;
|
||||
}
|
||||
|
||||
RenderFrameParent*
|
||||
ShadowLayersParent::Frame()
|
||||
{
|
||||
return static_cast<RenderFrameParent*>(Manager());
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayersParent::DestroySharedSurface(gfxSharedImageSurface* aSurface)
|
||||
{
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "mozilla/layers/PLayersParent.h"
|
||||
#include "ShadowLayers.h"
|
||||
#include "ShadowLayersManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -63,7 +64,7 @@ class ShadowLayersParent : public PLayersParent,
|
||||
typedef InfallibleTArray<EditReply> EditReplyArray;
|
||||
|
||||
public:
|
||||
ShadowLayersParent(ShadowLayerManager* aManager);
|
||||
ShadowLayersParent(ShadowLayerManager* aManager, ShadowLayersManager* aLayersManager);
|
||||
~ShadowLayersParent();
|
||||
|
||||
void Destroy();
|
||||
@ -83,9 +84,8 @@ protected:
|
||||
NS_OVERRIDE virtual bool DeallocPLayer(PLayerParent* actor);
|
||||
|
||||
private:
|
||||
RenderFrameParent* Frame();
|
||||
|
||||
nsRefPtr<ShadowLayerManager> mLayerManager;
|
||||
ShadowLayersManager* mShadowLayersManager;
|
||||
// Hold the root because it might be grafted under various
|
||||
// containers in the "real" layer tree
|
||||
nsRefPtr<ContainerLayer> mRoot;
|
||||
|
@ -1,4 +1,5 @@
|
||||
IPDLSRCS = \
|
||||
PCompositor.ipdl \
|
||||
PLayer.ipdl \
|
||||
PLayers.ipdl \
|
||||
$(NULL)
|
||||
|
@ -648,7 +648,7 @@ RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
|
||||
return nsnull;
|
||||
}
|
||||
*aBackendType = lm->GetBackendType();
|
||||
return new ShadowLayersParent(slm);
|
||||
return new ShadowLayersParent(slm, this);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -42,6 +42,7 @@
|
||||
#define mozilla_layout_RenderFrameParent_h
|
||||
|
||||
#include "mozilla/layout/PRenderFrameParent.h"
|
||||
#include "mozilla/layers/ShadowLayersManager.h"
|
||||
|
||||
#include <map>
|
||||
#include "nsDisplayList.h"
|
||||
@ -59,7 +60,8 @@ class ShadowLayersParent;
|
||||
|
||||
namespace layout {
|
||||
|
||||
class RenderFrameParent : public PRenderFrameParent
|
||||
class RenderFrameParent : public PRenderFrameParent,
|
||||
public mozilla::layers::ShadowLayersManager
|
||||
{
|
||||
typedef mozilla::layers::FrameMetrics FrameMetrics;
|
||||
typedef mozilla::layers::ContainerLayer ContainerLayer;
|
||||
@ -84,7 +86,7 @@ public:
|
||||
|
||||
void ContentViewScaleChanged(nsContentView* aView);
|
||||
|
||||
void ShadowLayersUpdated();
|
||||
virtual void ShadowLayersUpdated() MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
nsSubDocumentFrame* aFrame,
|
||||
|
@ -119,6 +119,10 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
class TextureImage;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
class LayerManagerOGL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NP_NO_CARBON
|
||||
@ -295,6 +299,9 @@ typedef NSInteger NSEventGestureAxis;
|
||||
#ifdef __LP64__
|
||||
BOOL *mSwipeAnimationCancelled;
|
||||
#endif
|
||||
|
||||
// Whether this uses off-main-thread compositing.
|
||||
BOOL mUsingOMTCompositor;
|
||||
}
|
||||
|
||||
// class initialization
|
||||
@ -327,6 +334,8 @@ typedef NSInteger NSEventGestureAxis;
|
||||
// If so, we shouldn't focus or unfocus a plugin.
|
||||
- (BOOL)isInFailingLeftClickThrough;
|
||||
|
||||
- (void)setGLContext:(NSOpenGLContext *)aGLContext;
|
||||
|
||||
// Simple gestures support
|
||||
//
|
||||
// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent,
|
||||
@ -348,6 +357,8 @@ typedef NSInteger NSEventGestureAxis;
|
||||
- (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent
|
||||
scrollOverflow:(PRInt32)overflow;
|
||||
#endif
|
||||
|
||||
- (void)setUsingOMTCompositor:(BOOL)aUseOMTC;
|
||||
@end
|
||||
|
||||
class ChildViewMouseTracker {
|
||||
@ -433,7 +444,7 @@ public:
|
||||
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
|
||||
|
||||
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture, bool aConsumeRollupEvent);
|
||||
NS_IMETHOD SetTitle(const nsAString& title);
|
||||
|
||||
@ -486,6 +497,7 @@ public:
|
||||
already_AddRefed<nsAccessible> GetDocumentAccessible();
|
||||
#endif
|
||||
|
||||
virtual void CreateCompositor();
|
||||
virtual gfxASurface* GetThebesSurface();
|
||||
virtual void DrawOver(LayerManager* aManager, nsIntRect aRect);
|
||||
|
||||
|
@ -87,6 +87,7 @@
|
||||
#include "Layers.h"
|
||||
#include "LayerManagerOGL.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/layers/CompositorCocoaWidgetHelper.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
@ -1772,6 +1773,22 @@ NSView<mozView>* nsChildView::GetEditorView()
|
||||
|
||||
#pragma mark -
|
||||
|
||||
void
|
||||
nsChildView::CreateCompositor()
|
||||
{
|
||||
nsBaseWidget::CreateCompositor();
|
||||
if (mCompositorChild) {
|
||||
LayerManagerOGL *manager =
|
||||
static_cast<LayerManagerOGL*>(compositor::GetLayerManager(mCompositorParent));
|
||||
|
||||
NSOpenGLContext *glContext =
|
||||
(NSOpenGLContext *) manager->gl()->GetNativeData(GLContext::NativeGLContext);
|
||||
|
||||
[(ChildView *)mView setGLContext:glContext];
|
||||
[(ChildView *)mView setUsingOMTCompositor:true];
|
||||
}
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
nsChildView::GetThebesSurface()
|
||||
{
|
||||
@ -2096,6 +2113,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (void)setGLContext:(NSOpenGLContext *)aGLContext
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
mGLContext = aGLContext;
|
||||
[mGLContext retain];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
@ -2546,13 +2573,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mGeckoChild->GetLayerManager(nsnull)->GetBackendType() == LayerManager::LAYERS_OPENGL) {
|
||||
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(mGeckoChild->GetLayerManager(nsnull));
|
||||
manager->SetClippingRegion(paintEvent.region);
|
||||
LayerManager *layerManager = mGeckoChild->GetLayerManager(nsnull);
|
||||
if (layerManager->GetBackendType() == LayerManager::LAYERS_OPENGL) {
|
||||
NSOpenGLContext *glContext;
|
||||
|
||||
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(layerManager);
|
||||
manager->SetClippingRegion(paintEvent.region);
|
||||
glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
|
||||
|
||||
if (!mGLContext) {
|
||||
mGLContext = (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
|
||||
[mGLContext retain];
|
||||
[self setGLContext:glContext];
|
||||
}
|
||||
|
||||
mGeckoChild->DispatchWindowEvent(paintEvent);
|
||||
|
||||
// Force OpenGL to refresh the very first time we draw. This works around a
|
||||
@ -2592,6 +2624,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
painted = mGeckoChild->DispatchWindowEvent(paintEvent);
|
||||
}
|
||||
|
||||
// Force OpenGL to refresh the very first time we draw. This works around a
|
||||
// Mac OS X bug that stops windows updating on OS X when we use OpenGL.
|
||||
if (painted && !mDidForceRefreshOpenGL &&
|
||||
layerManager->AsShadowManager() && mUsingOMTCompositor) {
|
||||
if (!mDidForceRefreshOpenGL) {
|
||||
[self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0];
|
||||
mDidForceRefreshOpenGL = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!painted && [self isOpaque]) {
|
||||
// Gecko refused to draw, but we've claimed to be opaque, so we have to
|
||||
// draw something--fill with white.
|
||||
@ -3129,6 +3171,12 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
}
|
||||
#endif // #ifdef __LP64__
|
||||
|
||||
- (void)setUsingOMTCompositor:(BOOL)aUseOMTC
|
||||
{
|
||||
mUsingOMTCompositor = aUseOMTC;
|
||||
}
|
||||
|
||||
|
||||
// Returning NO from this method only disallows ordering on mousedown - in order
|
||||
// to prevent it for mouseup too, we need to call [NSApp preventWindowOrdering]
|
||||
// when handling the mousedown event.
|
||||
|
@ -38,6 +38,8 @@
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "nsBaseWidget.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -55,6 +57,7 @@
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsIGfxInfo.h"
|
||||
#include "npapi.h"
|
||||
#include "base/thread.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "nsIObserver.h"
|
||||
@ -70,6 +73,8 @@ static PRInt32 gNumWidgets;
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla;
|
||||
using base::Thread;
|
||||
using mozilla::ipc::AsyncChannel;
|
||||
|
||||
nsIContent* nsBaseWidget::mLastRollup = nsnull;
|
||||
|
||||
@ -104,6 +109,7 @@ nsBaseWidget::nsBaseWidget()
|
||||
, mEventCallback(nsnull)
|
||||
, mViewCallback(nsnull)
|
||||
, mContext(nsnull)
|
||||
, mCompositorThread(nsnull)
|
||||
, mCursor(eCursor_standard)
|
||||
, mWindowType(eWindowType_child)
|
||||
, mBorderStyle(eBorderStyle_none)
|
||||
@ -142,6 +148,12 @@ nsBaseWidget::~nsBaseWidget()
|
||||
|
||||
if (mLayerManager) {
|
||||
mLayerManager->Destroy();
|
||||
mLayerManager = nsnull;
|
||||
}
|
||||
|
||||
if (mCompositorChild) {
|
||||
mCompositorChild->Destroy();
|
||||
delete mCompositorThread;
|
||||
}
|
||||
|
||||
#ifdef NOISY_WIDGET_LEAKS
|
||||
@ -814,6 +826,38 @@ nsBaseWidget::GetShouldAccelerate()
|
||||
return mUseAcceleratedRendering;
|
||||
}
|
||||
|
||||
void nsBaseWidget::CreateCompositor()
|
||||
{
|
||||
mCompositorParent = new CompositorParent(this);
|
||||
mCompositorThread = new Thread("CompositorThread");
|
||||
if (mCompositorThread->Start()) {
|
||||
LayerManager* lm = CreateBasicLayerManager();
|
||||
MessageLoop *childMessageLoop = mCompositorThread->message_loop();
|
||||
mCompositorChild = new CompositorChild(lm);
|
||||
AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
|
||||
AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
|
||||
mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
|
||||
PLayersChild* shadowManager =
|
||||
mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL);
|
||||
|
||||
if (shadowManager) {
|
||||
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
|
||||
if (!lf) {
|
||||
delete lm;
|
||||
mCompositorChild = nsnull;
|
||||
}
|
||||
lf->SetShadowManager(shadowManager);
|
||||
lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);
|
||||
|
||||
mLayerManager = lm;
|
||||
} else {
|
||||
NS_WARNING("fail to construct LayersChild");
|
||||
delete lm;
|
||||
mCompositorChild = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
||||
LayersBackend aBackendHint,
|
||||
LayerManagerPersistence aPersistence,
|
||||
@ -824,16 +868,29 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
||||
|
||||
if (mUseAcceleratedRendering) {
|
||||
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
||||
/**
|
||||
* XXX - On several OSes initialization is expected to fail for now.
|
||||
* If we'd get a none-basic layer manager they'd crash. This is ok though
|
||||
* since on those platforms it will fail. Anyone implementing new
|
||||
* platforms on LayerManagerOGL should ensure their widget is able to
|
||||
* deal with it though!
|
||||
*/
|
||||
if (layerManager->Initialize()) {
|
||||
mLayerManager = layerManager;
|
||||
|
||||
// Try to use an async compositor first, if possible
|
||||
bool useCompositor =
|
||||
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
|
||||
if (useCompositor) {
|
||||
// e10s uses the parameter to pass in the shadow manager from the TabChild
|
||||
// so we don't expect to see it there since this doesn't support e10s.
|
||||
NS_ASSERTION(aShadowManager == nsnull, "Async Compositor not supported with e10s");
|
||||
CreateCompositor();
|
||||
}
|
||||
|
||||
if (!mLayerManager) {
|
||||
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
||||
/**
|
||||
* XXX - On several OSes initialization is expected to fail for now.
|
||||
* If we'd get a non-basic layer manager they'd crash. This is ok though
|
||||
* since on those platforms it will fail. Anyone implementing new
|
||||
* platforms on LayerManagerOGL should ensure their widget is able to
|
||||
* deal with it though!
|
||||
*/
|
||||
if (layerManager->Initialize()) {
|
||||
mLayerManager = layerManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mLayerManager) {
|
||||
|
@ -51,6 +51,17 @@ class nsIContent;
|
||||
class nsAutoRollup;
|
||||
class gfxContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
class CompositorChild;
|
||||
class CompositorParent;
|
||||
}
|
||||
}
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common widget implementation used as base class for native
|
||||
* or crossplatform implementations of Widgets.
|
||||
@ -66,6 +77,9 @@ class nsBaseWidget : public nsIWidget
|
||||
|
||||
protected:
|
||||
typedef mozilla::layers::BasicLayerManager BasicLayerManager;
|
||||
typedef mozilla::layers::CompositorChild CompositorChild;
|
||||
typedef mozilla::layers::CompositorParent CompositorParent;
|
||||
typedef base::Thread Thread;
|
||||
|
||||
public:
|
||||
nsBaseWidget();
|
||||
@ -117,6 +131,7 @@ public:
|
||||
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
||||
bool* aAllowRetaining = nsnull);
|
||||
|
||||
virtual void CreateCompositor();
|
||||
virtual void DrawOver(LayerManager* aManager, nsIntRect aRect) {}
|
||||
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) {}
|
||||
virtual gfxASurface* GetThebesSurface();
|
||||
@ -268,6 +283,9 @@ protected:
|
||||
nsDeviceContext* mContext;
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
nsRefPtr<LayerManager> mBasicLayerManager;
|
||||
nsRefPtr<CompositorChild> mCompositorChild;
|
||||
nsRefPtr<CompositorParent> mCompositorParent;
|
||||
Thread* mCompositorThread;
|
||||
nscolor mBackground;
|
||||
nscolor mForeground;
|
||||
nsCursor mCursor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user