mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out 0736b014d4a5 (Bug 610155) for breaking canvas reftests on android
This commit is contained in:
parent
96f6c5ff38
commit
96fc781c65
@ -56,9 +56,6 @@
|
||||
#include "ThebesLayerBuffer.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "ReadbackProcessor.h"
|
||||
#ifdef MOZ_X11
|
||||
#include "gfxXlibSurface.h"
|
||||
#endif
|
||||
|
||||
#include "GLContext.h"
|
||||
|
||||
@ -1627,6 +1624,12 @@ public:
|
||||
mShadow = aShadow;
|
||||
}
|
||||
|
||||
virtual void SetBackBufferImage(gfxSharedImageSurface* aBuffer)
|
||||
{
|
||||
NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
|
||||
}
|
||||
|
||||
virtual PRBool SupportsSurfaceDescriptor() const { return PR_FALSE; }
|
||||
virtual void SetBackBuffer(const SurfaceDescriptor& aBuffer)
|
||||
{
|
||||
NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
|
||||
@ -1732,6 +1735,12 @@ BasicShadowableContainerLayer::RemoveChild(Layer* aChild)
|
||||
BasicContainerLayer::RemoveChild(aChild);
|
||||
}
|
||||
|
||||
static PRBool
|
||||
IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
|
||||
{
|
||||
return SurfaceDescriptor::T__None != aSurface.type();
|
||||
}
|
||||
|
||||
class BasicShadowableThebesLayer : public BasicThebesLayer,
|
||||
public BasicShadowableLayer
|
||||
{
|
||||
@ -1761,6 +1770,8 @@ public:
|
||||
virtual ShadowableLayer* AsShadowableLayer() { return this; }
|
||||
virtual bool MustRetainContent() { return HasShadow(); }
|
||||
|
||||
virtual PRBool SupportsSurfaceDescriptor() const { return PR_TRUE; }
|
||||
|
||||
void SetBackBufferAndAttrs(const ThebesBuffer& aBuffer,
|
||||
const nsIntRegion& aValidRegion,
|
||||
float aXResolution, float aYResolution,
|
||||
@ -1944,8 +1955,8 @@ public:
|
||||
}
|
||||
virtual ~BasicShadowableImageLayer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
if (mBackSurface) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackSurface);
|
||||
}
|
||||
MOZ_COUNT_DTOR(BasicShadowableImageLayer);
|
||||
}
|
||||
@ -1960,14 +1971,14 @@ public:
|
||||
virtual Layer* AsLayer() { return this; }
|
||||
virtual ShadowableLayer* AsShadowableLayer() { return this; }
|
||||
|
||||
virtual void SetBackBuffer(const SurfaceDescriptor& aBuffer)
|
||||
virtual void SetBackBufferImage(gfxSharedImageSurface* aBuffer)
|
||||
{
|
||||
mBackBuffer = aBuffer;
|
||||
mBackSurface = aBuffer;
|
||||
}
|
||||
|
||||
virtual void Disconnect()
|
||||
{
|
||||
mBackBuffer = SurfaceDescriptor();
|
||||
mBackSurface = nsnull;
|
||||
BasicShadowableLayer::Disconnect();
|
||||
}
|
||||
|
||||
@ -1977,7 +1988,7 @@ private:
|
||||
return static_cast<BasicShadowLayerManager*>(mManager);
|
||||
}
|
||||
|
||||
SurfaceDescriptor mBackBuffer;
|
||||
nsRefPtr<gfxSharedImageSurface> mBackSurface;
|
||||
};
|
||||
|
||||
void
|
||||
@ -1989,18 +2000,20 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
|
||||
return;
|
||||
|
||||
if (oldSize != mSize) {
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
if (mBackSurface) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackSurface);
|
||||
mBackSurface = nsnull;
|
||||
|
||||
BasicManager()->DestroyedImageBuffer(BasicManager()->Hold(this));
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
}
|
||||
|
||||
SurfaceDescriptor tmpFrontSurface;
|
||||
nsRefPtr<gfxSharedImageSurface> tmpFrontSurface;
|
||||
// XXX error handling?
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
mSize,
|
||||
(GetContentFlags() & CONTENT_OPAQUE) ?
|
||||
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
|
||||
&tmpFrontSurface, &mBackBuffer))
|
||||
getter_AddRefs(tmpFrontSurface), getter_AddRefs(mBackSurface)))
|
||||
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
|
||||
|
||||
BasicManager()->CreatedImageBuffer(BasicManager()->Hold(this),
|
||||
@ -2008,15 +2021,13 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
|
||||
tmpFrontSurface);
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> backSurface =
|
||||
BasicManager()->OpenDescriptor(mBackBuffer);
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(backSurface);
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackSurface);
|
||||
PaintContext(pat,
|
||||
nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
|
||||
nsnull, 1.0, tmpCtx);
|
||||
|
||||
BasicManager()->PaintedImage(BasicManager()->Hold(this),
|
||||
mBackBuffer);
|
||||
mBackSurface);
|
||||
}
|
||||
|
||||
|
||||
@ -2059,8 +2070,8 @@ public:
|
||||
}
|
||||
virtual ~BasicShadowableCanvasLayer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
if (mBackBuffer) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBuffer);
|
||||
}
|
||||
MOZ_COUNT_DTOR(BasicShadowableCanvasLayer);
|
||||
}
|
||||
@ -2076,14 +2087,14 @@ public:
|
||||
virtual Layer* AsLayer() { return this; }
|
||||
virtual ShadowableLayer* AsShadowableLayer() { return this; }
|
||||
|
||||
virtual void SetBackBuffer(const SurfaceDescriptor& aBuffer)
|
||||
virtual void SetBackBufferImage(gfxSharedImageSurface* aBuffer)
|
||||
{
|
||||
mBackBuffer = aBuffer;
|
||||
}
|
||||
|
||||
|
||||
virtual void Disconnect()
|
||||
{
|
||||
mBackBuffer = SurfaceDescriptor();
|
||||
mBackBuffer = nsnull;
|
||||
BasicShadowableLayer::Disconnect();
|
||||
}
|
||||
|
||||
@ -2093,7 +2104,7 @@ private:
|
||||
return static_cast<BasicShadowLayerManager*>(mManager);
|
||||
}
|
||||
|
||||
SurfaceDescriptor mBackBuffer;
|
||||
nsRefPtr<gfxSharedImageSurface> mBackBuffer;
|
||||
};
|
||||
|
||||
void
|
||||
@ -2105,20 +2116,20 @@ BasicShadowableCanvasLayer::Initialize(const Data& aData)
|
||||
|
||||
// XXX won't get here currently; need to figure out what to do on
|
||||
// canvas resizes
|
||||
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
if (mBackBuffer) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBuffer);
|
||||
mBackBuffer = nsnull;
|
||||
|
||||
BasicManager()->DestroyedCanvasBuffer(BasicManager()->Hold(this));
|
||||
}
|
||||
|
||||
SurfaceDescriptor tmpFrontBuffer;
|
||||
nsRefPtr<gfxSharedImageSurface> tmpFrontBuffer;
|
||||
// XXX error handling?
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
gfxIntSize(aData.mSize.width, aData.mSize.height),
|
||||
(GetContentFlags() & CONTENT_OPAQUE) ?
|
||||
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
|
||||
&tmpFrontBuffer, &mBackBuffer))
|
||||
getter_AddRefs(tmpFrontBuffer), getter_AddRefs(mBackBuffer)))
|
||||
NS_RUNTIMEABORT("creating CanvasLayer back buffer failed!");
|
||||
|
||||
BasicManager()->CreatedCanvasBuffer(BasicManager()->Hold(this),
|
||||
@ -2138,9 +2149,7 @@ BasicShadowableCanvasLayer::Paint(gfxContext* aContext)
|
||||
// changed areas, much like we do for Thebes layers, as well as
|
||||
// do all sorts of magic to swap out the surface underneath the
|
||||
// canvas' thebes/cairo context.
|
||||
nsRefPtr<gfxASurface> backSurface =
|
||||
BasicManager()->OpenDescriptor(mBackBuffer);
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(backSurface);
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackBuffer);
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
|
||||
// call BasicCanvasLayer::Paint to draw to our tmp context, because
|
||||
@ -2433,15 +2442,17 @@ public:
|
||||
ShadowImageLayer::Disconnect();
|
||||
}
|
||||
|
||||
virtual PRBool Init(const SurfaceDescriptor& front, const nsIntSize& size);
|
||||
virtual PRBool Init(gfxSharedImageSurface* front, const nsIntSize& size);
|
||||
|
||||
virtual void Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack);
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* newFront);
|
||||
|
||||
virtual void DestroyFrontBuffer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mFrontBuffer)) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(&mFrontBuffer, mAllocator);
|
||||
if (mFrontSurface) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(mFrontSurface, mAllocator);
|
||||
}
|
||||
mFrontSurface = nsnull;
|
||||
}
|
||||
|
||||
virtual void Paint(gfxContext* aContext);
|
||||
@ -2452,36 +2463,36 @@ protected:
|
||||
return static_cast<BasicShadowLayerManager*>(mManager);
|
||||
}
|
||||
|
||||
SurfaceDescriptor mFrontBuffer;
|
||||
// XXX ShmemImage?
|
||||
nsRefPtr<gfxSharedImageSurface> mFrontSurface;
|
||||
gfxIntSize mSize;
|
||||
};
|
||||
|
||||
PRBool
|
||||
BasicShadowImageLayer::Init(const SurfaceDescriptor& front,
|
||||
BasicShadowImageLayer::Init(gfxSharedImageSurface* front,
|
||||
const nsIntSize& size)
|
||||
{
|
||||
mFrontBuffer = front;
|
||||
mFrontSurface = front;
|
||||
mSize = gfxIntSize(size.width, size.height);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
BasicShadowImageLayer::Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack)
|
||||
already_AddRefed<gfxSharedImageSurface>
|
||||
BasicShadowImageLayer::Swap(gfxSharedImageSurface* newFront)
|
||||
{
|
||||
*aNewBack = mFrontBuffer;
|
||||
mFrontBuffer = aNewFront;
|
||||
already_AddRefed<gfxSharedImageSurface> tmp = mFrontSurface.forget();
|
||||
mFrontSurface = newFront;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void
|
||||
BasicShadowImageLayer::Paint(gfxContext* aContext)
|
||||
{
|
||||
if (!IsSurfaceDescriptorValid(mFrontBuffer)) {
|
||||
if (!mFrontSurface) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> surface =
|
||||
BasicManager()->OpenDescriptor(mFrontBuffer);
|
||||
nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
|
||||
nsRefPtr<gfxPattern> pat = new gfxPattern(mFrontSurface);
|
||||
pat->SetFilter(mFilter);
|
||||
|
||||
// The visible region can extend outside the image. If we're not
|
||||
@ -2535,15 +2546,16 @@ public:
|
||||
}
|
||||
|
||||
virtual void Initialize(const Data& aData);
|
||||
virtual void Init(const SurfaceDescriptor& aNewFront, const nsIntSize& aSize);
|
||||
|
||||
void Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack);
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* newFront);
|
||||
|
||||
virtual void DestroyFrontBuffer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mFrontSurface)) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(&mFrontSurface, mAllocator);
|
||||
if (mFrontSurface) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(mFrontSurface, mAllocator);
|
||||
}
|
||||
mFrontSurface = nsnull;
|
||||
}
|
||||
|
||||
virtual void Paint(gfxContext* aContext);
|
||||
@ -2554,28 +2566,27 @@ private:
|
||||
return static_cast<BasicShadowLayerManager*>(mManager);
|
||||
}
|
||||
|
||||
SurfaceDescriptor mFrontSurface;
|
||||
nsRefPtr<gfxSharedImageSurface> mFrontSurface;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
BasicShadowCanvasLayer::Initialize(const Data& aData)
|
||||
{
|
||||
NS_RUNTIMEABORT("Incompatibe surface type");
|
||||
NS_ASSERTION(mFrontSurface == nsnull,
|
||||
"BasicCanvasLayer::Initialize called twice!");
|
||||
NS_ASSERTION(aData.mSurface && !aData.mGLContext, "no comprende OpenGL!");
|
||||
|
||||
mFrontSurface = static_cast<gfxSharedImageSurface*>(aData.mSurface);
|
||||
mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
|
||||
}
|
||||
|
||||
void
|
||||
BasicShadowCanvasLayer::Init(const SurfaceDescriptor& aNewFront, const nsIntSize& aSize)
|
||||
already_AddRefed<gfxSharedImageSurface>
|
||||
BasicShadowCanvasLayer::Swap(gfxSharedImageSurface* newFront)
|
||||
{
|
||||
mFrontSurface = aNewFront;
|
||||
mBounds.SetRect(0, 0, aSize.width, aSize.height);
|
||||
}
|
||||
|
||||
void
|
||||
BasicShadowCanvasLayer::Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack)
|
||||
{
|
||||
*aNewBack = mFrontSurface;
|
||||
mFrontSurface = aNewFront;
|
||||
already_AddRefed<gfxSharedImageSurface> tmp = mFrontSurface.forget();
|
||||
mFrontSurface = newFront;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2584,13 +2595,11 @@ BasicShadowCanvasLayer::Paint(gfxContext* aContext)
|
||||
NS_ASSERTION(BasicManager()->InDrawing(),
|
||||
"Can only draw in drawing phase");
|
||||
|
||||
if (IsSurfaceDescriptorValid(mFrontSurface)) {
|
||||
if (!mFrontSurface) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> surface =
|
||||
BasicManager()->OpenDescriptor(mFrontSurface);
|
||||
nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
|
||||
nsRefPtr<gfxPattern> pat = new gfxPattern(mFrontSurface);
|
||||
|
||||
pat->SetFilter(mFilter);
|
||||
pat->SetExtend(gfxPattern::EXTEND_PAD);
|
||||
@ -2821,7 +2830,17 @@ BasicShadowLayerManager::ForwardTransaction()
|
||||
|
||||
const OpBufferSwap& obs = reply.get_OpBufferSwap();
|
||||
const SurfaceDescriptor& descr = obs.newBackBuffer();
|
||||
GetBasicShadowable(obs)->SetBackBuffer(descr);
|
||||
BasicShadowableLayer* layer = GetBasicShadowable(obs);
|
||||
if (layer->SupportsSurfaceDescriptor()) {
|
||||
layer->SetBackBuffer(descr);
|
||||
} else {
|
||||
if (SurfaceDescriptor::TShmem != descr.type()) {
|
||||
NS_RUNTIMEABORT("non-Shmem surface sent to a layer that expected one!");
|
||||
}
|
||||
nsRefPtr<gfxASurface> imageSurf = OpenDescriptor(descr);
|
||||
layer->SetBackBufferImage(
|
||||
static_cast<gfxSharedImageSurface*>(imageSurf.get()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,14 @@ struct OpDestroyThebesFrontBuffer { PLayer layer; };
|
||||
struct OpCreateCanvasBuffer {
|
||||
PLayer layer;
|
||||
nsIntSize size;
|
||||
SurfaceDescriptor initialFront;
|
||||
Shmem initialFront;
|
||||
};
|
||||
struct OpDestroyCanvasFrontBuffer { PLayer layer; };
|
||||
|
||||
struct OpCreateImageBuffer {
|
||||
PLayer layer;
|
||||
nsIntSize size;
|
||||
SurfaceDescriptor initialFront;
|
||||
Shmem initialFront;
|
||||
};
|
||||
struct OpDestroyImageFrontBuffer { PLayer layer; };
|
||||
|
||||
@ -173,12 +173,12 @@ struct OpPaintThebesBuffer {
|
||||
|
||||
struct OpPaintCanvas {
|
||||
PLayer layer;
|
||||
SurfaceDescriptor newFrontBuffer;
|
||||
Shmem newFrontBuffer;
|
||||
};
|
||||
|
||||
struct OpPaintImage {
|
||||
PLayer layer;
|
||||
SurfaceDescriptor newFrontBuffer;
|
||||
Shmem newFrontBuffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -192,7 +192,7 @@ ShadowLayerForwarder::CreatedThebesBuffer(ShadowableLayer* aThebes,
|
||||
const SurfaceDescriptor& aTempFrontBuffer)
|
||||
{
|
||||
OptionalThebesBuffer buffer = null_t();
|
||||
if (IsSurfaceDescriptorValid(aTempFrontBuffer)) {
|
||||
if (SurfaceDescriptor::T__None != aTempFrontBuffer.type()) {
|
||||
buffer = ThebesBuffer(aTempFrontBuffer,
|
||||
aBufferRect,
|
||||
nsIntPoint(0, 0));
|
||||
@ -207,21 +207,21 @@ ShadowLayerForwarder::CreatedThebesBuffer(ShadowableLayer* aThebes,
|
||||
void
|
||||
ShadowLayerForwarder::CreatedImageBuffer(ShadowableLayer* aImage,
|
||||
nsIntSize aSize,
|
||||
const SurfaceDescriptor& aTempFrontSurface)
|
||||
gfxSharedImageSurface* aTempFrontSurface)
|
||||
{
|
||||
mTxn->AddEdit(OpCreateImageBuffer(NULL, Shadow(aImage),
|
||||
aSize,
|
||||
aTempFrontSurface));
|
||||
aTempFrontSurface->GetShmem()));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedCanvasBuffer(ShadowableLayer* aCanvas,
|
||||
nsIntSize aSize,
|
||||
const SurfaceDescriptor& aTempFrontSurface)
|
||||
gfxSharedImageSurface* aTempFrontSurface)
|
||||
{
|
||||
mTxn->AddEdit(OpCreateCanvasBuffer(NULL, Shadow(aCanvas),
|
||||
aSize,
|
||||
aTempFrontSurface));
|
||||
aTempFrontSurface->GetShmem()));
|
||||
}
|
||||
|
||||
void
|
||||
@ -291,17 +291,17 @@ ShadowLayerForwarder::PaintedThebesBuffer(ShadowableLayer* aThebes,
|
||||
}
|
||||
void
|
||||
ShadowLayerForwarder::PaintedImage(ShadowableLayer* aImage,
|
||||
const SurfaceDescriptor& aNewFrontSurface)
|
||||
gfxSharedImageSurface* aNewFrontSurface)
|
||||
{
|
||||
mTxn->AddPaint(OpPaintImage(NULL, Shadow(aImage),
|
||||
aNewFrontSurface));
|
||||
aNewFrontSurface->GetShmem()));
|
||||
}
|
||||
void
|
||||
ShadowLayerForwarder::PaintedCanvas(ShadowableLayer* aCanvas,
|
||||
const SurfaceDescriptor& aNewFrontSurface)
|
||||
gfxSharedImageSurface* aNewFrontSurface)
|
||||
{
|
||||
mTxn->AddPaint(OpPaintCanvas(NULL, Shadow(aCanvas),
|
||||
aNewFrontSurface));
|
||||
aNewFrontSurface->GetShmem()));
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -636,11 +636,5 @@ ShadowLayerManager::PlatformSyncBeforeReplyUpdate()
|
||||
|
||||
#endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
|
||||
|
||||
PRBool
|
||||
IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
|
||||
{
|
||||
return SurfaceDescriptor::T__None != aSurface.type();
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -165,10 +165,10 @@ public:
|
||||
*/
|
||||
void CreatedImageBuffer(ShadowableLayer* aImage,
|
||||
nsIntSize aSize,
|
||||
const SurfaceDescriptor& aInitialFrontSurface);
|
||||
gfxSharedImageSurface* aInitialFrontSurface);
|
||||
void CreatedCanvasBuffer(ShadowableLayer* aCanvas,
|
||||
nsIntSize aSize,
|
||||
const SurfaceDescriptor& aInitialFrontSurface);
|
||||
gfxSharedImageSurface* aInitialFrontSurface);
|
||||
|
||||
/**
|
||||
* The specified layer is destroying its buffers.
|
||||
@ -225,9 +225,9 @@ public:
|
||||
* ImageLayers. This is slow, and will be optimized.
|
||||
*/
|
||||
void PaintedImage(ShadowableLayer* aImage,
|
||||
const SurfaceDescriptor& aNewFrontSurface);
|
||||
gfxSharedImageSurface* aNewFrontSurface);
|
||||
void PaintedCanvas(ShadowableLayer* aCanvas,
|
||||
const SurfaceDescriptor& aNewFrontSurface);
|
||||
gfxSharedImageSurface* aNewFrontSurface);
|
||||
|
||||
/**
|
||||
* End the current transaction and forward it to ShadowLayerManager.
|
||||
@ -569,17 +569,6 @@ class ShadowCanvasLayer : public ShadowLayer,
|
||||
public CanvasLayer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
*
|
||||
* Initialize this with a (temporary) front surface with the given
|
||||
* size. This is expected to be followed with a Swap() in the same
|
||||
* transaction to bring in real pixels. Init() may only be called
|
||||
* once.
|
||||
*/
|
||||
virtual void Init(const SurfaceDescriptor& front, const nsIntSize& aSize) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
*
|
||||
@ -587,7 +576,8 @@ public:
|
||||
* out the old front surface (the new back surface for the remote
|
||||
* layer).
|
||||
*/
|
||||
virtual void Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack) = 0;
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* aNewFront) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
@ -619,13 +609,14 @@ public:
|
||||
* transaction to bring in real pixels. Init() may only be called
|
||||
* once.
|
||||
*/
|
||||
virtual PRBool Init(const SurfaceDescriptor& front, const nsIntSize& aSize) = 0;
|
||||
virtual PRBool Init(gfxSharedImageSurface* aFront, const nsIntSize& aSize) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* @see ShadowCanvasLayer::Swap
|
||||
*/
|
||||
virtual void Swap(const SurfaceDescriptor& aFront, SurfaceDescriptor* aNewBack) = 0;
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* newFront) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
@ -659,7 +650,6 @@ protected:
|
||||
{}
|
||||
};
|
||||
|
||||
PRBool IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -222,8 +222,13 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
const OpCreateCanvasBuffer& ocb = edit.get_OpCreateCanvasBuffer();
|
||||
ShadowCanvasLayer* canvas = static_cast<ShadowCanvasLayer*>(
|
||||
AsShadowLayer(ocb)->AsLayer());
|
||||
nsRefPtr<gfxSharedImageSurface> front =
|
||||
gfxSharedImageSurface::Open(ocb.initialFront());
|
||||
CanvasLayer::Data data;
|
||||
data.mSurface = front;
|
||||
data.mSize = ocb.size();
|
||||
|
||||
canvas->Init(ocb.initialFront(), ocb.size());
|
||||
canvas->Initialize(data);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -234,7 +239,9 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
ShadowImageLayer* image = static_cast<ShadowImageLayer*>(
|
||||
AsShadowLayer(ocb)->AsLayer());
|
||||
|
||||
image->Init(ocb.initialFront(), ocb.size());
|
||||
nsRefPtr<gfxSharedImageSurface> surf =
|
||||
gfxSharedImageSurface::Open(ocb.initialFront());
|
||||
image->Init(surf, ocb.size());
|
||||
|
||||
break;
|
||||
}
|
||||
@ -409,17 +416,17 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
ShadowCanvasLayer* canvas =
|
||||
static_cast<ShadowCanvasLayer*>(shadow->AsLayer());
|
||||
|
||||
SurfaceDescriptor newFront = op.newFrontBuffer();
|
||||
SurfaceDescriptor newBack;
|
||||
canvas->Swap(op.newFrontBuffer(), &newBack);
|
||||
nsRefPtr<gfxSharedImageSurface> newFront =
|
||||
gfxSharedImageSurface::Open(op.newFrontBuffer());
|
||||
nsRefPtr<gfxSharedImageSurface> newBack = canvas->Swap(newFront);
|
||||
if (newFront == newBack) {
|
||||
newFront = SurfaceDescriptor();
|
||||
newFront.forget();
|
||||
}
|
||||
|
||||
canvas->Updated();
|
||||
|
||||
replyv.push_back(OpBufferSwap(shadow, NULL,
|
||||
newBack));
|
||||
newBack->GetShmem()));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -431,15 +438,15 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
ShadowImageLayer* image =
|
||||
static_cast<ShadowImageLayer*>(shadow->AsLayer());
|
||||
|
||||
SurfaceDescriptor newFront = op.newFrontBuffer();
|
||||
SurfaceDescriptor newBack;
|
||||
image->Swap(op.newFrontBuffer(), &newBack);
|
||||
nsRefPtr<gfxSharedImageSurface> newFront =
|
||||
gfxSharedImageSurface::Open(op.newFrontBuffer());
|
||||
nsRefPtr<gfxSharedImageSurface> newBack = image->Swap(newFront);
|
||||
if (newFront == newBack) {
|
||||
newFront = SurfaceDescriptor();
|
||||
newFront.forget();
|
||||
}
|
||||
|
||||
replyv.push_back(OpBufferSwap(shadow, NULL,
|
||||
newBack));
|
||||
newBack->GetShmem()));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -52,10 +52,6 @@
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include "gfxXlibSurface.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::gl;
|
||||
@ -297,40 +293,34 @@ ShadowCanvasLayerOGL::~ShadowCanvasLayerOGL()
|
||||
void
|
||||
ShadowCanvasLayerOGL::Initialize(const Data& aData)
|
||||
{
|
||||
NS_RUNTIMEABORT("Incompatibe surface type");
|
||||
}
|
||||
|
||||
void
|
||||
ShadowCanvasLayerOGL::Init(const SurfaceDescriptor& aNewFront, const nsIntSize& aSize)
|
||||
{
|
||||
mDeadweight = aNewFront;
|
||||
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(mDeadweight);
|
||||
|
||||
mTexImage = gl()->CreateTextureImage(nsIntSize(aSize.width, aSize.height),
|
||||
surf->GetContentType(),
|
||||
mDeadweight = static_cast<gfxSharedImageSurface*>(aData.mSurface);
|
||||
gfxSize sz = mDeadweight->GetSize();
|
||||
mTexImage = gl()->CreateTextureImage(nsIntSize(sz.width, sz.height),
|
||||
mDeadweight->GetContentType(),
|
||||
LOCAL_GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowCanvasLayerOGL::Swap(const SurfaceDescriptor& aNewFront,
|
||||
SurfaceDescriptor* aNewBack)
|
||||
already_AddRefed<gfxSharedImageSurface>
|
||||
ShadowCanvasLayerOGL::Swap(gfxSharedImageSurface* aNewFront)
|
||||
{
|
||||
if (!mDestroyed && mTexImage) {
|
||||
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront);
|
||||
gfxSize sz = surf->GetSize();
|
||||
// XXX this is always just ridiculously slow
|
||||
|
||||
gfxSize sz = aNewFront->GetSize();
|
||||
nsIntRegion updateRegion(nsIntRect(0, 0, sz.width, sz.height));
|
||||
mTexImage->DirectUpdate(surf, updateRegion);
|
||||
mTexImage->DirectUpdate(aNewFront, updateRegion);
|
||||
}
|
||||
|
||||
*aNewBack = aNewFront;
|
||||
return aNewFront;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowCanvasLayerOGL::DestroyFrontBuffer()
|
||||
{
|
||||
mTexImage = nsnull;
|
||||
if (IsSurfaceDescriptorValid(mDeadweight)) {
|
||||
mOGLManager->DestroySharedSurface(&mDeadweight, mAllocator);
|
||||
if (mDeadweight) {
|
||||
mOGLManager->DestroySharedSurface(mDeadweight, mAllocator);
|
||||
mDeadweight = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,14 +110,12 @@ public:
|
||||
|
||||
// CanvasLayer impl
|
||||
virtual void Initialize(const Data& aData);
|
||||
virtual void Init(const SurfaceDescriptor& aNewFront, const nsIntSize& aSize);
|
||||
|
||||
// This isn't meaningful for shadow canvas.
|
||||
virtual void Updated(const nsIntRect&) {}
|
||||
|
||||
// ShadowCanvasLayer impl
|
||||
virtual void Swap(const SurfaceDescriptor& aNewFront,
|
||||
SurfaceDescriptor* aNewBack);
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* aNewFront);
|
||||
|
||||
virtual void DestroyFrontBuffer();
|
||||
|
||||
@ -132,7 +130,11 @@ public:
|
||||
private:
|
||||
nsRefPtr<TextureImage> mTexImage;
|
||||
|
||||
SurfaceDescriptor mDeadweight;
|
||||
|
||||
// XXX FIXME holding to free
|
||||
nsRefPtr<gfxSharedImageSurface> mDeadweight;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} /* layers */
|
||||
|
@ -790,38 +790,38 @@ ShadowImageLayerOGL::~ShadowImageLayerOGL()
|
||||
{}
|
||||
|
||||
PRBool
|
||||
ShadowImageLayerOGL::Init(const SurfaceDescriptor& aFront,
|
||||
ShadowImageLayerOGL::Init(gfxSharedImageSurface* aFront,
|
||||
const nsIntSize& aSize)
|
||||
{
|
||||
mDeadweight = aFront;
|
||||
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aFront);
|
||||
gfxSize sz = surf->GetSize();
|
||||
gfxSize sz = mDeadweight->GetSize();
|
||||
mTexImage = gl()->CreateTextureImage(nsIntSize(sz.width, sz.height),
|
||||
surf->GetContentType(),
|
||||
mDeadweight->GetContentType(),
|
||||
LOCAL_GL_CLAMP_TO_EDGE);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerOGL::Swap(const SurfaceDescriptor& aNewFront, SurfaceDescriptor* aNewBack)
|
||||
already_AddRefed<gfxSharedImageSurface>
|
||||
ShadowImageLayerOGL::Swap(gfxSharedImageSurface* aNewFront)
|
||||
{
|
||||
if (!mDestroyed && mTexImage) {
|
||||
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront);
|
||||
// XXX this is always just ridiculously slow
|
||||
gfxSize sz = surf->GetSize();
|
||||
|
||||
gfxSize sz = aNewFront->GetSize();
|
||||
nsIntRegion updateRegion(nsIntRect(0, 0, sz.width, sz.height));
|
||||
mTexImage->DirectUpdate(surf, updateRegion);
|
||||
mTexImage->DirectUpdate(aNewFront, updateRegion);
|
||||
}
|
||||
|
||||
*aNewBack = aNewFront;
|
||||
return aNewFront;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerOGL::DestroyFrontBuffer()
|
||||
{
|
||||
mTexImage = nsnull;
|
||||
if (IsSurfaceDescriptorValid(mDeadweight)) {
|
||||
mOGLManager->DestroySharedSurface(&mDeadweight, mAllocator);
|
||||
if (mDeadweight) {
|
||||
mOGLManager->DestroySharedSurface(mDeadweight, mAllocator);
|
||||
mDeadweight = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,9 +245,10 @@ public:
|
||||
virtual ~ShadowImageLayerOGL();
|
||||
|
||||
// ShadowImageLayer impl
|
||||
virtual PRBool Init(const SurfaceDescriptor& aFront, const nsIntSize& aSize);
|
||||
virtual PRBool Init(gfxSharedImageSurface* aFront, const nsIntSize& aSize);
|
||||
|
||||
virtual void Swap(const SurfaceDescriptor& aFront, SurfaceDescriptor* aNewBack);
|
||||
virtual already_AddRefed<gfxSharedImageSurface>
|
||||
Swap(gfxSharedImageSurface* aNewFront);
|
||||
|
||||
virtual void DestroyFrontBuffer();
|
||||
|
||||
@ -264,7 +265,11 @@ public:
|
||||
private:
|
||||
nsRefPtr<TextureImage> mTexImage;
|
||||
|
||||
SurfaceDescriptor mDeadweight;
|
||||
|
||||
// XXX FIXME holding to free
|
||||
nsRefPtr<gfxSharedImageSurface> mDeadweight;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} /* layers */
|
||||
|
Loading…
Reference in New Issue
Block a user