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

View File

@ -445,6 +445,12 @@ public:
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.
*/

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
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
{

View File

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

View File

@ -109,6 +109,11 @@ public:
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<ShadowThebesLayer> CreateShadowThebesLayer();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,7 +72,8 @@ public:
protected:
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);
private:

View File

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