Bug 753784; allow access to the max texture size from FrameLayerBuilder. r=roc

This commit is contained in:
Nicholas Cameron
2012-05-22 19:15:16 -04:00
parent 4ffe1932d5
commit 189d6e2368
20 changed files with 64 additions and 14 deletions

View File

@@ -910,7 +910,8 @@ TabChild::InitWidget(const nsIntSize& size)
NS_ABORT_IF_FALSE(0 == remoteFrame->ManagedPLayersChild().Length(), NS_ABORT_IF_FALSE(0 == remoteFrame->ManagedPLayersChild().Length(),
"shouldn't have a shadow manager yet"); "shouldn't have a shadow manager yet");
LayerManager::LayersBackend be; LayerManager::LayersBackend be;
PLayersChild* shadowManager = remoteFrame->SendPLayersConstructor(&be); PRInt32 maxTextureSize;
PLayersChild* shadowManager = remoteFrame->SendPLayersConstructor(&be, &maxTextureSize);
if (!shadowManager) { if (!shadowManager) {
NS_WARNING("failed to construct LayersChild"); NS_WARNING("failed to construct LayersChild");
// This results in |remoteFrame| being deleted. // This results in |remoteFrame| being deleted.
@@ -923,6 +924,7 @@ TabChild::InitWidget(const nsIntSize& size)
NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(), NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(),
"PuppetWidget should have shadow manager"); "PuppetWidget should have shadow manager");
lf->SetParentBackendType(be); lf->SetParentBackendType(be);
lf->SetMaxTextureSize(maxTextureSize);
mRemoteFrame = remoteFrame; mRemoteFrame = remoteFrame;
return true; return true;

View File

@@ -445,6 +445,12 @@ public:
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return true; } virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return true; }
/**
* returns the maximum texture size on this layer backend, or PR_INT32_MAX
* if there is no maximum
*/
virtual PRInt32 GetMaxTextureSize() const = 0;
/** /**
* Return the name of the layer manager's backend. * Return the name of the layer manager's backend.
*/ */

View File

@@ -1433,6 +1433,16 @@ BasicLayerManager::PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxCon
} }
} }
PRInt32
BasicShadowLayerManager::GetMaxTextureSize() const
{
if (HasShadowManager()) {
return ShadowLayerForwarder::GetMaxTextureSize();
}
return PR_INT32_MAX;
}
void void
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
{ {

View File

@@ -146,6 +146,7 @@ public:
virtual bool IsCompositingCheap() { return false; } virtual bool IsCompositingCheap() { return false; }
virtual bool HasShadowManagerInternal() const { return false; } virtual bool HasShadowManagerInternal() const { return false; }
bool HasShadowManager() const { return HasShadowManagerInternal(); } bool HasShadowManager() const { return HasShadowManagerInternal(); }
virtual PRInt32 GetMaxTextureSize() const { return PR_INT32_MAX; }
protected: protected:
#ifdef DEBUG #ifdef DEBUG
@@ -207,6 +208,8 @@ public:
return this; return this;
} }
virtual PRInt32 GetMaxTextureSize() const;
virtual void BeginTransactionWithTarget(gfxContext* aTarget); virtual void BeginTransactionWithTarget(gfxContext* aTarget);
virtual bool EndEmptyTransaction(); virtual bool EndEmptyTransaction();
virtual void EndTransaction(DrawThebesLayerCallback aCallback, virtual void EndTransaction(DrawThebesLayerCallback aCallback,

View File

@@ -109,6 +109,11 @@ public:
return aSize <= gfxIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE); return aSize <= gfxIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
} }
virtual PRInt32 GetMaxTextureSize() const
{
return MAX_TEXTURE_SIZE;
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer(); virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ShadowThebesLayer> CreateShadowThebesLayer(); virtual already_AddRefed<ShadowThebesLayer> CreateShadowThebesLayer();

View File

@@ -121,6 +121,11 @@ public:
return aSize <= gfxIntSize(maxSize, maxSize); return aSize <= gfxIntSize(maxSize, maxSize);
} }
virtual PRInt32 GetMaxTextureSize() const
{
return mDeviceManager->GetMaxTextureSize();
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer(); virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ContainerLayer> CreateContainerLayer(); virtual already_AddRefed<ContainerLayer> CreateContainerLayer();

View File

@@ -42,7 +42,7 @@ CompositorChild::Destroy()
} }
PLayersChild* PLayersChild*
CompositorChild::AllocPLayers(const LayersBackend &backend) CompositorChild::AllocPLayers(const LayersBackend &aBackend, int* aMaxTextureSize)
{ {
return new ShadowLayersChild(); return new ShadowLayersChild();
} }

View File

@@ -25,7 +25,7 @@ public:
void Destroy(); void Destroy();
protected: protected:
virtual PLayersChild* AllocPLayers(const LayersBackend &aBackend); virtual PLayersChild* AllocPLayers(const LayersBackend &aBackend, int* aMaxTextureSize);
virtual bool DeallocPLayers(PLayersChild *aChild); virtual bool DeallocPLayers(PLayersChild *aChild);
private: private:

View File

@@ -427,9 +427,9 @@ CompositorParent::ShadowLayersUpdated(bool isFirstPaint)
} }
PLayersParent* PLayersParent*
CompositorParent::AllocPLayers(const LayersBackend &backendType) CompositorParent::AllocPLayers(const LayersBackend& aBackendType, int* aMaxTextureSize)
{ {
if (backendType == LayerManager::LAYERS_OPENGL) { if (aBackendType == LayerManager::LAYERS_OPENGL) {
nsRefPtr<LayerManagerOGL> layerManager; nsRefPtr<LayerManagerOGL> layerManager;
layerManager = layerManager =
new LayerManagerOGL(mWidget, mEGLSurfaceSize.width, mEGLSurfaceSize.height, mRenderToEGLSurface); new LayerManagerOGL(mWidget, mEGLSurfaceSize.width, mEGLSurfaceSize.height, mRenderToEGLSurface);
@@ -445,8 +445,9 @@ CompositorParent::AllocPLayers(const LayersBackend &backendType)
if (!slm) { if (!slm) {
return NULL; return NULL;
} }
*aMaxTextureSize = layerManager->GetMaxTextureSize();
return new ShadowLayersParent(slm, this); return new ShadowLayersParent(slm, this);
} else if (backendType == LayerManager::LAYERS_BASIC) { } else if (aBackendType == LayerManager::LAYERS_BASIC) {
// This require Cairo to be thread-safe // This require Cairo to be thread-safe
nsRefPtr<LayerManager> layerManager = new BasicShadowLayerManager(mWidget); nsRefPtr<LayerManager> layerManager = new BasicShadowLayerManager(mWidget);
mWidget = NULL; mWidget = NULL;
@@ -455,6 +456,7 @@ CompositorParent::AllocPLayers(const LayersBackend &backendType)
if (!slm) { if (!slm) {
return NULL; return NULL;
} }
*aMaxTextureSize = layerManager->GetMaxTextureSize();
return new ShadowLayersParent(slm, this); return new ShadowLayersParent(slm, this);
} else { } else {
NS_ERROR("Unsupported backend selected for Async Compositor"); NS_ERROR("Unsupported backend selected for Async Compositor");

View File

@@ -78,7 +78,7 @@ public:
void ScheduleResumeOnCompositorThread(int width, int height); void ScheduleResumeOnCompositorThread(int width, int height);
protected: protected:
virtual PLayersParent* AllocPLayers(const LayersBackend &backendType); virtual PLayersParent* AllocPLayers(const LayersBackend& aBackendType, int* aMaxTextureSize);
virtual bool DeallocPLayers(PLayersParent* aLayers); virtual bool DeallocPLayers(PLayersParent* aLayers);
virtual void ScheduleTask(CancelableTask*, int); virtual void ScheduleTask(CancelableTask*, int);
virtual void Composite(); virtual void Composite();

View File

@@ -38,7 +38,8 @@ parent:
sync Pause(); sync Pause();
sync Resume(); sync Resume();
sync PLayers(LayersBackend backend); sync PLayers(LayersBackend backend)
returns (int maxTextureSize);
}; };
} // layers } // layers

View File

@@ -106,6 +106,7 @@ struct AutoTxnEnd {
ShadowLayerForwarder::ShadowLayerForwarder() ShadowLayerForwarder::ShadowLayerForwarder()
: mShadowManager(NULL) : mShadowManager(NULL)
, mMaxTextureSize(0)
, mParentBackend(LayerManager::LAYERS_NONE) , mParentBackend(LayerManager::LAYERS_NONE)
, mIsFirstPaint(false) , mIsFirstPaint(false)
{ {

View File

@@ -297,6 +297,9 @@ public:
*/ */
void SetIsFirstPaint() { mIsFirstPaint = true; } void SetIsFirstPaint() { mIsFirstPaint = true; }
virtual PRInt32 GetMaxTextureSize() const { return mMaxTextureSize; }
void SetMaxTextureSize(PRInt32 aMaxTextureSize) { mMaxTextureSize = aMaxTextureSize; }
protected: protected:
ShadowLayerForwarder(); ShadowLayerForwarder();
@@ -320,6 +323,7 @@ private:
static void PlatformSyncBeforeUpdate(); static void PlatformSyncBeforeUpdate();
Transaction* mTxn; Transaction* mTxn;
PRInt32 mMaxTextureSize;
LayersBackend mParentBackend; LayersBackend mParentBackend;
bool mIsFirstPaint; bool mIsFirstPaint;

View File

@@ -118,6 +118,11 @@ public:
return aSize <= gfxIntSize(maxSize, maxSize); return aSize <= gfxIntSize(maxSize, maxSize);
} }
virtual PRInt32 GetMaxTextureSize() const
{
return mGLContext->GetMaxTextureSize();
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer(); virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ContainerLayer> CreateContainerLayer(); virtual already_AddRefed<ContainerLayer> CreateContainerLayer();

View File

@@ -29,7 +29,7 @@ sync protocol PRenderFrame
parent: parent:
sync PLayers() sync PLayers()
returns (LayersBackend backend); returns (LayersBackend backend, int maxTextureSize);
async __delete__(); async __delete__();

View File

@@ -33,7 +33,7 @@ RenderFrameChild::Destroy()
} }
PLayersChild* PLayersChild*
RenderFrameChild::AllocPLayers(LayerManager::LayersBackend* aBackendType) RenderFrameChild::AllocPLayers(LayerManager::LayersBackend* aBackendType, int* aMaxTextureSize)
{ {
return new ShadowLayersChild(); return new ShadowLayersChild();
} }

View File

@@ -23,7 +23,7 @@ public:
protected: protected:
NS_OVERRIDE NS_OVERRIDE
virtual PLayersChild* AllocPLayers(LayerManager::LayersBackend* aBackendType); virtual PLayersChild* AllocPLayers(LayerManager::LayersBackend* aBackendType, int* aMaxTextureSize);
NS_OVERRIDE NS_OVERRIDE
virtual bool DeallocPLayers(PLayersChild* aLayers); virtual bool DeallocPLayers(PLayersChild* aLayers);
}; };

View File

@@ -603,10 +603,11 @@ RenderFrameParent::ActorDestroy(ActorDestroyReason why)
} }
PLayersParent* PLayersParent*
RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType) RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType, int* aMaxTextureSize)
{ {
if (!mFrameLoader || mFrameLoaderDestroyed) { if (!mFrameLoader || mFrameLoaderDestroyed) {
*aBackendType = LayerManager::LAYERS_NONE; *aBackendType = LayerManager::LAYERS_NONE;
*aMaxTextureSize = 0;
return nsnull; return nsnull;
} }
@@ -615,9 +616,11 @@ RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
ShadowLayerManager* slm = lm->AsShadowManager(); ShadowLayerManager* slm = lm->AsShadowManager();
if (!slm) { if (!slm) {
*aBackendType = LayerManager::LAYERS_NONE; *aBackendType = LayerManager::LAYERS_NONE;
*aMaxTextureSize = 0;
return nsnull; return nsnull;
} }
*aBackendType = lm->GetBackendType(); *aBackendType = lm->GetBackendType();
*aMaxTextureSize = lm->GetMaxTextureSize();
return new ShadowLayersParent(slm, this); return new ShadowLayersParent(slm, this);
} }

View File

@@ -72,7 +72,8 @@ public:
protected: protected:
NS_OVERRIDE void ActorDestroy(ActorDestroyReason why); NS_OVERRIDE void ActorDestroy(ActorDestroyReason why);
NS_OVERRIDE virtual PLayersParent* AllocPLayers(LayerManager::LayersBackend* aBackendType); NS_OVERRIDE virtual PLayersParent* AllocPLayers(LayerManager::LayersBackend* aBackendType,
int* aMaxTextureSize);
NS_OVERRIDE virtual bool DeallocPLayers(PLayersParent* aLayers); NS_OVERRIDE virtual bool DeallocPLayers(PLayersParent* aLayers);
private: private:

View File

@@ -872,8 +872,9 @@ void nsBaseWidget::CreateCompositor()
AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel(); AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child; AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
mCompositorChild->Open(parentChannel, childMessageLoop, childSide); mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
PRInt32 maxTextureSize;
PLayersChild* shadowManager = PLayersChild* shadowManager =
mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL); mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL, &maxTextureSize);
if (shadowManager) { if (shadowManager) {
ShadowLayerForwarder* lf = lm->AsShadowForwarder(); ShadowLayerForwarder* lf = lm->AsShadowForwarder();
@@ -884,6 +885,7 @@ void nsBaseWidget::CreateCompositor()
} }
lf->SetShadowManager(shadowManager); lf->SetShadowManager(shadowManager);
lf->SetParentBackendType(LayerManager::LAYERS_OPENGL); lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);
lf->SetMaxTextureSize(maxTextureSize);
mLayerManager = lm; mLayerManager = lm;
} else { } else {