Bug 648484, part 2: Add various helpers, refactor ContainerLayer::SetSpecificAttributes. r=roc

This commit is contained in:
Chris Jones 2011-07-13 22:43:43 -07:00
parent 0369ff5024
commit fcb0f65051
7 changed files with 83 additions and 13 deletions

View File

@ -38,6 +38,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/layers/PLayers.h"
#include "mozilla/layers/ShadowLayers.h"
#include "ImageLayers.h"
@ -389,6 +390,12 @@ Layer::GetEffectiveOpacity()
return opacity;
}
void
ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
aAttrs = ContainerLayerAttributes(GetFrameMetrics());
}
PRBool
ContainerLayer::HasMultipleChildren()
{

View File

@ -79,9 +79,11 @@ class ImageLayer;
class ColorLayer;
class ImageContainer;
class CanvasLayer;
class ShadowLayer;
class ReadbackLayer;
class ReadbackProcessor;
class ShadowLayer;
class ShadowLayerForwarder;
class ShadowLayerManager;
class SpecificLayerAttributes;
/**
@ -115,6 +117,10 @@ public:
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
mScrollId == aOther.mScrollId);
}
PRBool operator!=(const FrameMetrics& aOther) const
{
return !operator==(aOther);
}
PRBool IsDefault() const
{
@ -283,6 +289,12 @@ public:
virtual void Destroy() { mDestroyed = PR_TRUE; mUserData.Clear(); }
PRBool IsDestroyed() { return mDestroyed; }
virtual ShadowLayerForwarder* AsShadowForwarder()
{ return nsnull; }
virtual ShadowLayerManager* AsShadowManager()
{ return nsnull; }
/**
* Start a new transaction. Nested transactions are not allowed so
* there must be no transaction currently in progress.
@ -1071,8 +1083,11 @@ public:
void SetFrameMetrics(const FrameMetrics& aFrameMetrics)
{
mFrameMetrics = aFrameMetrics;
Mutated();
}
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
// These getters can be used anytime.
virtual ContainerLayer* AsContainerLayer() { return this; }

View File

@ -1871,11 +1871,6 @@ public:
virtual void InsertAfter(Layer* aChild, Layer* aAfter);
virtual void RemoveChild(Layer* aChild);
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
aAttrs = ContainerLayerAttributes(GetFrameMetrics());
}
virtual Layer* AsLayer() { return this; }
virtual ShadowableLayer* AsShadowableLayer() { return this; }

View File

@ -224,6 +224,15 @@ public:
BasicShadowLayerManager(nsIWidget* aWidget);
virtual ~BasicShadowLayerManager();
virtual ShadowLayerForwarder* AsShadowForwarder()
{
return this;
}
virtual ShadowLayerManager* AsShadowManager()
{
return this;
}
virtual void BeginTransactionWithTarget(gfxContext* aTarget);
virtual bool EndEmptyTransaction();
virtual void EndTransaction(DrawThebesLayerCallback aCallback,
@ -247,12 +256,6 @@ public:
ShadowableLayer* Hold(Layer* aLayer);
bool HasShadowManager() const { return ShadowLayerForwarder::HasShadowManager(); }
PLayersChild* GetShadowManager() const { return mShadowManager; }
void SetShadowManager(PLayersChild* aShadowManager)
{
mShadowManager = aShadowManager;
}
virtual PRBool IsCompositingCheap();
virtual bool HasShadowManagerInternal() const { return HasShadowManager(); }

View File

@ -237,10 +237,19 @@ public:
*/
PRBool EndTransaction(InfallibleTArray<EditReply>* aReplies);
/**
* Set an actor through which layer updates will be pushed.
*/
void SetShadowManager(PLayersChild* aShadowManager)
{
mShadowManager = aShadowManager;
}
/**
* True if this is forwarding to a ShadowLayerManager.
*/
PRBool HasShadowManager() const { return !!mShadowManager; }
PLayersChild* GetShadowManager() const { return mShadowManager; }
/**
* The following Alloc/Open/Destroy interfaces abstract over the

View File

@ -126,6 +126,11 @@ public:
/**
* LayerManager implementation.
*/
virtual ShadowLayerManager* AsShadowManager()
{
return this;
}
void BeginTransaction();
void BeginTransactionWithTarget(gfxContext* aTarget);

View File

@ -75,6 +75,10 @@ namespace mozilla {
typedef gfxPattern::GraphicsFilter GraphicsFilterType;
typedef gfxASurface::gfxSurfaceType gfxSurfaceType;
typedef LayerManager::LayersBackend LayersBackend;
typedef gfxASurface::gfxImageFormat PixelFormat;
// This is a cross-platform approximation to HANDLE, which we expect
// to be typedef'd to void* or thereabouts.
typedef uintptr_t WindowsHandle;
// XXX there are out of place and might be generally useful. Could
// move to nscore.h or something.
@ -504,7 +508,7 @@ struct ParamTraits<mozilla::gfxSurfaceType>
}
};
template<>
template<>
struct ParamTraits<mozilla::LayersBackend>
{
typedef mozilla::LayersBackend paramType;
@ -534,6 +538,38 @@ struct ParamTraits<mozilla::LayersBackend>
}
};
template<>
struct ParamTraits<mozilla::PixelFormat>
{
typedef mozilla::PixelFormat paramType;
static bool IsLegalPixelFormat(const paramType& format)
{
return (gfxASurface::ImageFormatARGB32 <= format &&
format < gfxASurface::ImageFormatUnknown);
}
static void Write(Message* msg, const paramType& param)
{
if (!IsLegalPixelFormat(param)) {
NS_RUNTIMEABORT("Unknown pixel format");
}
WriteParam(msg, int32(param));
return;
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
int32 format;
if (!ReadParam(msg, iter, &format) ||
!IsLegalPixelFormat(paramType(format))) {
return false;
}
*result = paramType(format);
return true;
}
};
template<>
struct ParamTraits<gfxRGBA>
{