Bug 570620, part g: Fix bone-headed bugs with shadowable layers, remove unnecessary MOZ_LAYER_DECL_NAME()s, and have the "shadow layer manager" side keep a "shadow root" rather than setting the "real" root. r=vlad

This commit is contained in:
Chris Jones 2010-08-20 18:24:41 -05:00
parent 07606bfa23
commit 03c4f01c8b
5 changed files with 58 additions and 49 deletions

View File

@ -1298,41 +1298,44 @@ BasicShadowableThebesLayer::PaintBuffer(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
NS_ABORT_IF_FALSE(!!mBackBuffer, "should have a back buffer by now");
Base::PaintBuffer(aContext, aRegionToDraw, aRegionToInvalidate,
aCallback, aCallbackData);
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackBuffer);
tmpCtx->DrawSurface(aContext->OriginalSurface(),
gfxIntSize(mBufferSize.width, mBufferSize.height));
if (HasShadow()) {
NS_ABORT_IF_FALSE(!!mBackBuffer, "should have a back buffer by now");
BasicManager()->PaintedThebesBuffer(BasicManager()->Hold(this),
mBuffer.BufferRect(),
mBuffer.BufferRotation(),
mBackBuffer);
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackBuffer);
tmpCtx->DrawSurface(aContext->OriginalSurface(),
gfxIntSize(mBufferSize.width, mBufferSize.height));
BasicManager()->PaintedThebesBuffer(BasicManager()->Hold(this),
mBuffer.BufferRect(),
mBuffer.BufferRotation(),
mBackBuffer);
}
}
already_AddRefed<gfxASurface>
BasicShadowableThebesLayer::CreateBuffer(Buffer::ContentType aType,
const nsIntSize& aSize)
{
nsRefPtr<gfxSharedImageSurface> tmpFront;
// XXX error handling
if (!BasicManager()->AllocDoubleBuffer(gfxIntSize(aSize.width, aSize.height),
gfxASurface::ImageFormatARGB32,
getter_AddRefs(tmpFront),
getter_AddRefs(mBackBuffer)))
NS_RUNTIMEABORT("creating ThebesLayer 'back buffer' failed!");
mBufferSize = aSize;
BasicManager()->CreatedThebesBuffer(BasicManager()->Hold(this),
// only |aSize| really matters
// here, since Painted() soon
// follows
nsIntRect(nsIntPoint(0, 0), aSize),
tmpFront);
if (HasShadow()) {
nsRefPtr<gfxSharedImageSurface> tmpFront;
// XXX error handling
if (!BasicManager()->AllocDoubleBuffer(gfxIntSize(aSize.width, aSize.height),
gfxASurface::ImageFormatARGB32,
getter_AddRefs(tmpFront),
getter_AddRefs(mBackBuffer)))
NS_RUNTIMEABORT("creating ThebesLayer 'back buffer' failed!");
mBufferSize = aSize;
BasicManager()->CreatedThebesBuffer(BasicManager()->Hold(this),
// only |aSize| really matters
// here, since Painted() soon
// follows
nsIntRect(nsIntPoint(0, 0), aSize),
tmpFront);
}
return Base::CreateBuffer(aType, aSize);
}
@ -1579,8 +1582,6 @@ public:
void* aCallbackData,
float aOpacity);
MOZ_LAYER_DECL_NAME("BasicShadowThebesLayer", TYPE_SHADOW)
private:
BasicShadowLayerManager* BasicManager()
{
@ -1650,8 +1651,6 @@ public:
void* aCallbackData,
float aOpacity);
MOZ_LAYER_DECL_NAME("BasicShadowImageLayer", TYPE_SHADOW)
protected:
BasicShadowLayerManager* BasicManager()
{
@ -1721,8 +1720,6 @@ public:
void* aCallbackData,
float aOpacity);
MOZ_LAYER_DECL_NAME("BasicShadowCanvasLayer", TYPE_SHADOW)
private:
BasicShadowLayerManager* BasicManager()
{
@ -1879,11 +1876,6 @@ BasicShadowLayerManager::BasicShadowLayerManager(nsIWidget* aWidget) :
BasicShadowLayerManager::~BasicShadowLayerManager()
{
// FIXME/bug 570294: shadow forwarders don't have __delete__ until
// they have manager protocols
//
//if (HasShadowManager())
// PLayersChild::Send__delete__(mShadow);
MOZ_COUNT_DTOR(BasicShadowLayerManager);
}

View File

@ -226,10 +226,15 @@ public:
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer();
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer();
virtual const char* Name() const { return "BasicShadowLayerManager"; }
ShadowableLayer* Hold(Layer* aLayer);
PLayersChild* GetShadowManager() const { return mShadowManager; }
void SetShadowManager(PLayersChild* aShadowManager)
{
mShadowManager = aShadowManager;
}
private:
LayerRefArray mKeepAlive;
};

View File

@ -214,7 +214,7 @@ public:
/**
* True if this is forwarding to a ShadowLayerManager.
*/
PRBool HasShadowManager() { return !!mShadowManager; }
PRBool HasShadowManager() const { return !!mShadowManager; }
PRBool AllocDoubleBuffer(const gfxIntSize& aSize,
gfxASurface::gfxImageFormat aFormat,
@ -248,7 +248,7 @@ public:
void SetForwarder(PLayersParent* aForwarder)
{
NS_ASSERTION(!HasForwarder(), "setting forwarder twice?");
NS_ASSERTION(!aForwarder || !HasForwarder(), "stomping live forwarder?");
mForwarder = aForwarder;
}

View File

@ -278,7 +278,7 @@ ShadowLayersParent::RecvUpdate(const nsTArray<Edit>& cset,
case Edit::TOpSetRoot: {
MOZ_LAYERS_LOG(("[ParentSide] SetRoot"));
layer_manager()->SetRoot(AsShadowLayer(edit.get_OpSetRoot())->AsLayer());
mRoot = AsShadowLayer(edit.get_OpSetRoot())->AsLayer();
break;
}
case Edit::TOpInsertAfter: {
@ -374,5 +374,18 @@ ShadowLayersParent::RecvUpdate(const nsTArray<Edit>& cset,
return true;
}
PLayerParent*
ShadowLayersParent::AllocPLayer()
{
return new ShadowLayerParent();
}
bool
ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
{
delete actor;
return true;
}
} // namespace layers
} // namespace mozilla

View File

@ -42,11 +42,11 @@
#define mozilla_layers_ShadowLayersParent_h
#include "mozilla/layers/PLayersParent.h"
#include "ShadowLayerParent.h"
namespace mozilla {
namespace layers {
class Layer;
class ShadowLayerManager;
class ShadowLayersParent : public PLayersParent
@ -60,21 +60,20 @@ public:
ShadowLayerManager* layer_manager() const { return mLayerManager; }
Layer* GetRoot() const { return mRoot; }
protected:
NS_OVERRIDE virtual bool RecvUpdate(const EditArray& cset,
EditReplyArray* reply);
NS_OVERRIDE virtual PLayerParent* AllocPLayer() {
return new ShadowLayerParent();
}
NS_OVERRIDE virtual bool DeallocPLayer(PLayerParent* actor) {
delete actor;
return true;
}
NS_OVERRIDE virtual PLayerParent* AllocPLayer();
NS_OVERRIDE virtual bool DeallocPLayer(PLayerParent* actor);
private:
nsRefPtr<ShadowLayerManager> mLayerManager;
// Hold the root because it might be grafted under various
// containers in the "real" layer tree
nsRefPtr<Layer> mRoot;
};
} // namespace layers