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

This commit is contained in:
Chris Jones 2011-08-09 12:38:26 -07:00
Родитель 0df4a68455
Коммит e32f6e9a10
7 изменённых файлов: 80 добавлений и 13 удалений

Просмотреть файл

@ -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()
{

Просмотреть файл

@ -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; }

Просмотреть файл

@ -1907,11 +1907,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; }

Просмотреть файл

@ -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(); }

Просмотреть файл

@ -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

Просмотреть файл

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

Просмотреть файл

@ -75,6 +75,7 @@ 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.
@ -508,7 +509,7 @@ struct ParamTraits<mozilla::gfxSurfaceType>
}
};
template<>
template<>
struct ParamTraits<mozilla::LayersBackend>
{
typedef mozilla::LayersBackend paramType;
@ -538,6 +539,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>
{