зеркало из https://github.com/mozilla/gecko-dev.git
Bug 889515 - Get rid of static sCompositorParent. r=nical
This commit is contained in:
Родитель
5121773a74
Коммит
ddd78fd1a5
|
@ -232,6 +232,16 @@ ClientLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
|
|||
return true;
|
||||
}
|
||||
|
||||
CompositorChild *
|
||||
ClientLayerManager::GetRemoteRenderer()
|
||||
{
|
||||
if (!mWidget) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mWidget->GetRemoteRenderer();
|
||||
}
|
||||
|
||||
void
|
||||
ClientLayerManager::MakeSnapshotIfRequired()
|
||||
{
|
||||
|
@ -239,7 +249,7 @@ ClientLayerManager::MakeSnapshotIfRequired()
|
|||
return;
|
||||
}
|
||||
if (mWidget) {
|
||||
if (CompositorChild* remoteRenderer = mWidget->GetRemoteRenderer()) {
|
||||
if (CompositorChild* remoteRenderer = GetRemoteRenderer()) {
|
||||
nsIntRect bounds;
|
||||
mWidget->GetBounds(bounds);
|
||||
SurfaceDescriptor inSnapshot, snapshot;
|
||||
|
|
|
@ -53,6 +53,11 @@ public:
|
|||
virtual already_AddRefed<ColorLayer> CreateColorLayer();
|
||||
virtual already_AddRefed<RefLayer> CreateRefLayer();
|
||||
|
||||
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE
|
||||
{
|
||||
return mTextureFactoryIdentifier;
|
||||
}
|
||||
|
||||
virtual void FlushRendering() MOZ_OVERRIDE;
|
||||
|
||||
virtual bool NeedsWidgetInvalidation() MOZ_OVERRIDE { return false; }
|
||||
|
@ -89,6 +94,8 @@ public:
|
|||
void* GetThebesLayerCallbackData() const
|
||||
{ return mThebesLayerCallbackData; }
|
||||
|
||||
CompositorChild *GetRemoteRenderer();
|
||||
|
||||
/**
|
||||
* Called for each iteration of a progressive tile update. Fills
|
||||
* aViewport, aScaleX and aScaleY with the current scale and viewport
|
||||
|
|
|
@ -40,10 +40,6 @@ public:
|
|||
typedef gfxASurface::gfxContentType gfxContentType;
|
||||
|
||||
CompositableForwarder()
|
||||
: mMaxTextureSize(0)
|
||||
, mCompositorBackend(layers::LAYERS_NONE)
|
||||
, mSupportsTextureBlitting(false)
|
||||
, mSupportsPartialUploads(false)
|
||||
{}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +146,7 @@ public:
|
|||
/**
|
||||
* Returns the maximum texture size supported by the compositor.
|
||||
*/
|
||||
virtual int32_t GetMaxTextureSize() const { return mMaxTextureSize; }
|
||||
virtual int32_t GetMaxTextureSize() const { return mTextureFactoryIdentifier.mMaxTextureSize; }
|
||||
|
||||
bool IsOnCompositorSide() const MOZ_OVERRIDE { return false; }
|
||||
|
||||
|
@ -161,24 +157,21 @@ public:
|
|||
*/
|
||||
LayersBackend GetCompositorBackendType() const
|
||||
{
|
||||
return mCompositorBackend;
|
||||
return mTextureFactoryIdentifier.mParentBackend;
|
||||
}
|
||||
|
||||
bool SupportsTextureBlitting() const
|
||||
{
|
||||
return mSupportsTextureBlitting;
|
||||
return mTextureFactoryIdentifier.mSupportsTextureBlitting;
|
||||
}
|
||||
|
||||
bool SupportsPartialUploads() const
|
||||
{
|
||||
return mSupportsPartialUploads;
|
||||
return mTextureFactoryIdentifier.mSupportsPartialUploads;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t mMaxTextureSize;
|
||||
LayersBackend mCompositorBackend;
|
||||
bool mSupportsTextureBlitting;
|
||||
bool mSupportsPartialUploads;
|
||||
TextureFactoryIdentifier mTextureFactoryIdentifier;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace layers {
|
|||
// FIXME/bug 774386: we're assuming that there's only one
|
||||
// CompositorParent, but that's not always true. This assumption only
|
||||
// affects CrossProcessCompositorParent below.
|
||||
static CompositorParent* sCurrentCompositor;
|
||||
static Thread* sCompositorThread = nullptr;
|
||||
// manual reference count of the compositor thread.
|
||||
static int sCompositorThreadRefCount = 0;
|
||||
|
@ -153,9 +152,6 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
|
|||
CompositorLoop()->PostTask(FROM_HERE, NewRunnableFunction(&AddCompositor,
|
||||
this, &mCompositorID));
|
||||
|
||||
if (!sCurrentCompositor) {
|
||||
sCurrentCompositor = this;
|
||||
}
|
||||
++sCompositorThreadRefCount;
|
||||
}
|
||||
|
||||
|
@ -169,9 +165,6 @@ CompositorParent::~CompositorParent()
|
|||
{
|
||||
MOZ_COUNT_DTOR(CompositorParent);
|
||||
|
||||
if (this == sCurrentCompositor) {
|
||||
sCurrentCompositor = NULL;
|
||||
}
|
||||
ReleaseCompositorThread();
|
||||
}
|
||||
|
||||
|
@ -677,6 +670,19 @@ CompositorParent::SetTimeAndSampleAnimations(TimeStamp aTime, bool aIsTesting)
|
|||
typedef map<uint64_t, CompositorParent::LayerTreeState> LayerTreeMap;
|
||||
static LayerTreeMap sIndirectLayerTrees;
|
||||
|
||||
bool
|
||||
CompositorParent::RecvNotifyChildCreated(const uint64_t& child)
|
||||
{
|
||||
NotifyChildCreated(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::NotifyChildCreated(uint64_t aChild)
|
||||
{
|
||||
sIndirectLayerTrees[aChild].mParent = this;
|
||||
}
|
||||
|
||||
/*static*/ uint64_t
|
||||
CompositorParent::AllocateLayerTreeId()
|
||||
{
|
||||
|
@ -710,7 +716,7 @@ UpdateControllerForLayersId(uint64_t aLayersId,
|
|||
|
||||
// Notify the AsyncPanZoomController about the current compositor so that it
|
||||
// can request composites off the compositor thread.
|
||||
aController->SetCompositorParent(sCurrentCompositor);
|
||||
aController->SetCompositorParent(sIndirectLayerTrees[aLayersId].mParent);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
|
@ -752,6 +758,7 @@ public:
|
|||
virtual bool RecvStop() MOZ_OVERRIDE { return true; }
|
||||
virtual bool RecvPause() MOZ_OVERRIDE { return true; }
|
||||
virtual bool RecvResume() MOZ_OVERRIDE { return true; }
|
||||
virtual bool RecvNotifyChildCreated(const uint64_t& child) MOZ_OVERRIDE;
|
||||
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
|
||||
SurfaceDescriptor* aOutSnapshot)
|
||||
{ return true; }
|
||||
|
@ -851,9 +858,14 @@ CrossProcessCompositorParent::AllocPLayerTransactionParent(const LayersBackend&
|
|||
{
|
||||
MOZ_ASSERT(aId != 0);
|
||||
|
||||
nsRefPtr<LayerManager> lm = sCurrentCompositor->GetLayerManager();
|
||||
*aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier();
|
||||
return new LayerTransactionParent(lm->AsLayerManagerComposite(), this, aId);
|
||||
if (sIndirectLayerTrees[aId].mParent) {
|
||||
nsRefPtr<LayerManager> lm = sIndirectLayerTrees[aId].mParent->GetLayerManager();
|
||||
*aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier();
|
||||
return new LayerTransactionParent(lm->AsLayerManagerComposite(), this, aId);
|
||||
}
|
||||
|
||||
NS_WARNING("Created child without a matching parent?");
|
||||
return new LayerTransactionParent(nullptr, this, aId);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -865,6 +877,13 @@ CrossProcessCompositorParent::DeallocPLayerTransactionParent(PLayerTransactionPa
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CrossProcessCompositorParent::RecvNotifyChildCreated(const uint64_t& child)
|
||||
{
|
||||
sIndirectLayerTrees[child].mParent->NotifyChildCreated(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CrossProcessCompositorParent::ShadowLayersUpdated(
|
||||
LayerTransactionParent* aLayerTree,
|
||||
|
@ -879,7 +898,7 @@ CrossProcessCompositorParent::ShadowLayersUpdated(
|
|||
}
|
||||
UpdateIndirectTree(id, shadowRoot, aTargetConfig, isFirstPaint);
|
||||
|
||||
sCurrentCompositor->NotifyShadowTreeTransaction();
|
||||
sIndirectLayerTrees[id].mParent->NotifyShadowTreeTransaction();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
virtual bool RecvStop() MOZ_OVERRIDE;
|
||||
virtual bool RecvPause() MOZ_OVERRIDE;
|
||||
virtual bool RecvResume() MOZ_OVERRIDE;
|
||||
virtual bool RecvNotifyChildCreated(const uint64_t& child) MOZ_OVERRIDE;
|
||||
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
|
||||
SurfaceDescriptor* aOutSnapshot);
|
||||
virtual bool RecvFlushRendering() MOZ_OVERRIDE;
|
||||
|
@ -74,6 +75,8 @@ public:
|
|||
|
||||
LayerManagerComposite* GetLayerManager() { return mLayerManager; }
|
||||
|
||||
void NotifyChildCreated(uint64_t aChild);
|
||||
|
||||
void AsyncRender();
|
||||
|
||||
// Can be called from any thread
|
||||
|
@ -152,6 +155,7 @@ public:
|
|||
struct LayerTreeState {
|
||||
nsRefPtr<Layer> mRoot;
|
||||
nsRefPtr<AsyncPanZoomController> mController;
|
||||
CompositorParent *mParent;
|
||||
TargetConfig mTargetConfig;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ parent:
|
|||
sync Pause();
|
||||
sync Resume();
|
||||
|
||||
async NotifyChildCreated(uint64_t id);
|
||||
|
||||
// Make a snapshot of the content that would have been drawn to our
|
||||
// render target at the time this message is received. If the size
|
||||
// or format of |inSnapshot| doesn't match our render target,
|
||||
|
|
|
@ -160,10 +160,7 @@ struct AutoTxnEnd {
|
|||
void
|
||||
CompositableForwarder::IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier)
|
||||
{
|
||||
mMaxTextureSize = aIdentifier.mMaxTextureSize;
|
||||
mCompositorBackend = aIdentifier.mParentBackend;
|
||||
mSupportsTextureBlitting = aIdentifier.mSupportsTextureBlitting;
|
||||
mSupportsPartialUploads = aIdentifier.mSupportsPartialUploads;
|
||||
mTextureFactoryIdentifier = aIdentifier;
|
||||
}
|
||||
|
||||
ShadowLayerForwarder::ShadowLayerForwarder()
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsViewportFrame.h"
|
||||
#include "RenderFrameParent.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
#include "ClientLayerManager.h"
|
||||
|
||||
typedef nsContentView::ViewConfig ViewConfig;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -602,7 +604,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
|||
|
||||
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
||||
// Perhaps the document containing this frame currently has no presentation?
|
||||
if (lm && lm->AsLayerManagerComposite()) {
|
||||
if (lm && lm->GetBackendType() == LAYERS_CLIENT) {
|
||||
*aTextureFactoryIdentifier = lm->GetTextureFactoryIdentifier();
|
||||
} else {
|
||||
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
||||
|
@ -612,6 +614,10 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
|||
// Our remote frame will push layers updates to the compositor,
|
||||
// and we'll keep an indirect reference to that tree.
|
||||
*aId = mLayersId = CompositorParent::AllocateLayerTreeId();
|
||||
if (lm && lm->GetBackendType() == LAYERS_CLIENT) {
|
||||
ClientLayerManager *clientManager = static_cast<ClientLayerManager*>(lm.get());
|
||||
clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
|
||||
}
|
||||
if (aScrollingBehavior == ASYNC_PAN_ZOOM) {
|
||||
mContentController = new RemoteContentController(this);
|
||||
mPanZoomController = new AsyncPanZoomController(
|
||||
|
|
Загрузка…
Ссылка в новой задаче