Bug 765734, part 2: Migrate ImageLayers to SurfaceDescriptor. r=mattwoodrow,roc

--HG--
extra : rebase_source : 19fc8b0ae4cfffdf9a098911deac3b48c2f5d768
This commit is contained in:
Chris Jones 2012-07-12 05:51:57 -07:00
Родитель 14518d6f62
Коммит 96f961a570
6 изменённых файлов: 77 добавлений и 56 удалений

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

@ -196,9 +196,9 @@ public:
mBackBuffer = aBuffer;
}
virtual void SetBackBufferYUVImage(gfxSharedImageSurface* aYBuffer,
gfxSharedImageSurface* aUBuffer,
gfxSharedImageSurface* aVBuffer)
virtual void SetBackBufferYUVImage(const SurfaceDescriptor& aYBuffer,
const SurfaceDescriptor& aUBuffer,
const SurfaceDescriptor& aVBuffer)
{
mBackBufferY = aYBuffer;
mBackBufferU = aUBuffer;
@ -207,7 +207,9 @@ public:
virtual void Disconnect()
{
mBackBufferY = mBackBufferU = mBackBufferV = nsnull;
mBackBufferY = SurfaceDescriptor();
mBackBufferU = SurfaceDescriptor();
mBackBufferV = SurfaceDescriptor();
mBackBuffer = SurfaceDescriptor();
BasicShadowableLayer::Disconnect();
}
@ -217,11 +219,11 @@ public:
if (IsSurfaceDescriptorValid(mBackBuffer)) {
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
}
if (mBackBufferY) {
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferY);
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferU);
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferV);
}
if (IsSurfaceDescriptorValid(mBackBufferY)) {
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBufferY);
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBufferU);
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBufferV);
}
}
private:
@ -234,9 +236,9 @@ private:
// for RGB images only mBackSurface is used.
SurfaceDescriptor mBackBuffer;
bool mBufferIsOpaque;
nsRefPtr<gfxSharedImageSurface> mBackBufferY;
nsRefPtr<gfxSharedImageSurface> mBackBufferU;
nsRefPtr<gfxSharedImageSurface> mBackBufferV;
SurfaceDescriptor mBackBufferY;
SurfaceDescriptor mBackBufferU;
SurfaceDescriptor mBackBufferV;
gfxIntSize mCbCrSize;
};
@ -271,38 +273,52 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
const PlanarYCbCrImage::Data *data = YCbCrImage->GetData();
NS_ASSERTION(data, "Must be able to retrieve yuv data from image!");
if (mSize != data->mYSize || mCbCrSize != data->mCbCrSize || !mBackBufferY) {
if (mSize != data->mYSize || mCbCrSize != data->mCbCrSize || !IsSurfaceDescriptorValid(mBackBufferY)) {
DestroyBackBuffer();
mSize = data->mYSize;
mCbCrSize = data->mCbCrSize;
if (!BasicManager()->AllocBuffer(mSize, gfxASurface::CONTENT_ALPHA,
getter_AddRefs(mBackBufferY)) ||
!BasicManager()->AllocBuffer(mCbCrSize, gfxASurface::CONTENT_ALPHA,
getter_AddRefs(mBackBufferU)) ||
!BasicManager()->AllocBuffer(mCbCrSize, gfxASurface::CONTENT_ALPHA,
getter_AddRefs(mBackBufferV))) {
// We either allocate all three planes or none.
if (!BasicManager()->AllocBufferWithCaps(mSize,
gfxASurface::CONTENT_ALPHA,
MAP_AS_IMAGE_SURFACE,
&mBackBufferY) ||
!BasicManager()->AllocBufferWithCaps(mCbCrSize,
gfxASurface::CONTENT_ALPHA,
MAP_AS_IMAGE_SURFACE,
&mBackBufferU) ||
!BasicManager()->AllocBufferWithCaps(mCbCrSize,
gfxASurface::CONTENT_ALPHA,
MAP_AS_IMAGE_SURFACE,
&mBackBufferV)) {
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
}
}
nsRefPtr<gfxASurface> dyas = BasicManager()->OpenDescriptor(mBackBufferY);
nsRefPtr<gfxImageSurface> dy = dyas->GetAsImageSurface();
for (int i = 0; i < data->mYSize.height; i++) {
memcpy(mBackBufferY->Data() + i * mBackBufferY->Stride(),
memcpy(dy->Data() + i * dy->Stride(),
data->mYChannel + i * data->mYStride,
data->mYSize.width);
}
nsRefPtr<gfxASurface> duas = BasicManager()->OpenDescriptor(mBackBufferU);
nsRefPtr<gfxImageSurface> du = duas->GetAsImageSurface();
nsRefPtr<gfxASurface> dvas = BasicManager()->OpenDescriptor(mBackBufferV);
nsRefPtr<gfxImageSurface> dv = dvas->GetAsImageSurface();
for (int i = 0; i < data->mCbCrSize.height; i++) {
memcpy(mBackBufferU->Data() + i * mBackBufferU->Stride(),
memcpy(du->Data() + i * du->Stride(),
data->mCbChannel + i * data->mCbCrStride,
data->mCbCrSize.width);
memcpy(mBackBufferV->Data() + i * mBackBufferV->Stride(),
memcpy(dv->Data() + i * dv->Stride(),
data->mCrChannel + i * data->mCbCrStride,
data->mCbCrSize.width);
}
YUVImage yuv(mBackBufferY->GetShmem(),
mBackBufferU->GetShmem(),
mBackBufferV->GetShmem(),
YUVImage yuv(mBackBufferY, mBackBufferU, mBackBufferV,
data->GetPictureRect());
BasicManager()->PaintedImage(BasicManager()->Hold(this),

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

@ -839,7 +839,6 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
gfxUtils::ClipToRegion(aTarget, aLayer->GetEffectiveVisibleRegion());
}
AutoSetOperator setOperator(aTarget, container->GetOperator());
gfxMatrix temp = aTarget->CurrentMatrix();
PaintWithMask(aTarget, aLayer->GetEffectiveOpacity(),
HasShadowManager() ? nsnull : aLayer->GetMaskLayer());
}
@ -1048,13 +1047,12 @@ BasicShadowLayerManager::ForwardTransaction()
layer->SetBackBuffer(newBack.get_SurfaceDescriptor());
} else if (newBack.type() == SharedImage::TYUVImage) {
const YUVImage& yuv = newBack.get_YUVImage();
nsRefPtr<gfxSharedImageSurface> YSurf = gfxSharedImageSurface::Open(yuv.Ydata());
nsRefPtr<gfxSharedImageSurface> USurf = gfxSharedImageSurface::Open(yuv.Udata());
nsRefPtr<gfxSharedImageSurface> VSurf = gfxSharedImageSurface::Open(yuv.Vdata());
layer->SetBackBufferYUVImage(YSurf, USurf, VSurf);
layer->SetBackBufferYUVImage(yuv.Ydata(), yuv.Udata(), yuv.Vdata());
} else {
layer->SetBackBuffer(SurfaceDescriptor());
layer->SetBackBufferYUVImage(nsnull, nsnull, nsnull);
layer->SetBackBufferYUVImage(SurfaceDescriptor(),
SurfaceDescriptor(),
SurfaceDescriptor());
}
break;

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

@ -279,11 +279,11 @@ public:
NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
}
virtual void SetBackBufferYUVImage(gfxSharedImageSurface* aYBuffer,
gfxSharedImageSurface* aUBuffer,
gfxSharedImageSurface* aVBuffer)
virtual void SetBackBufferYUVImage(const SurfaceDescriptor& aYBuffer,
const SurfaceDescriptor& aUBuffer,
const SurfaceDescriptor& aVBuffer)
{
NS_RUNTIMEABORT("if this default impl is called, |aBuffer| leaks");
NS_RUNTIMEABORT("if this default impl is called, the buffers leak");
}
virtual void Disconnect()

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

@ -558,12 +558,15 @@ ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront,
} else {
const YUVImage& yuv = aNewFront.get_YUVImage();
nsRefPtr<gfxSharedImageSurface> surfY =
gfxSharedImageSurface::Open(yuv.Ydata());
nsRefPtr<gfxSharedImageSurface> surfU =
gfxSharedImageSurface::Open(yuv.Udata());
nsRefPtr<gfxSharedImageSurface> surfV =
gfxSharedImageSurface::Open(yuv.Vdata());
nsRefPtr<gfxASurface> asurfY =
ShadowLayerForwarder::OpenDescriptor(yuv.Ydata());
nsRefPtr<gfxImageSurface> surfY = asurfY->GetAsImageSurface();
nsRefPtr<gfxASurface> asurfU =
ShadowLayerForwarder::OpenDescriptor(yuv.Udata());
nsRefPtr<gfxImageSurface> surfU = asurfU->GetAsImageSurface();
nsRefPtr<gfxASurface> asurfV =
ShadowLayerForwarder::OpenDescriptor(yuv.Vdata());
nsRefPtr<gfxImageSurface> surfV = asurfV->GetAsImageSurface();
PlanarYCbCrImage::Data data;
data.mYChannel = surfY->Data();

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

@ -53,9 +53,9 @@ union SurfaceDescriptor {
};
struct YUVImage {
Shmem Ydata;
Shmem Udata;
Shmem Vdata;
SurfaceDescriptor Ydata;
SurfaceDescriptor Udata;
SurfaceDescriptor Vdata;
nsIntRect picture;
};

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

@ -674,12 +674,12 @@ ShadowImageLayerOGL::Init(const SharedImage& aFront)
} else {
YUVImage yuv = aFront.get_YUVImage();
nsRefPtr<gfxSharedImageSurface> surfY =
gfxSharedImageSurface::Open(yuv.Ydata());
nsRefPtr<gfxSharedImageSurface> surfU =
gfxSharedImageSurface::Open(yuv.Udata());
nsRefPtr<gfxSharedImageSurface> surfV =
gfxSharedImageSurface::Open(yuv.Vdata());
nsRefPtr<gfxASurface> asurfY =
ShadowLayerForwarder::OpenDescriptor(yuv.Ydata());
nsRefPtr<gfxImageSurface> surfY = asurfY->GetAsImageSurface();
nsRefPtr<gfxASurface> asurfU =
ShadowLayerForwarder::OpenDescriptor(yuv.Udata());
nsRefPtr<gfxImageSurface> surfU = asurfU->GetAsImageSurface();
mSize = surfY->GetSize();
mCbCrSize = surfU->GetSize();
@ -723,12 +723,16 @@ ShadowImageLayerOGL::Swap(const SharedImage& aNewFront,
} else {
const YUVImage& yuv = aNewFront.get_YUVImage();
nsRefPtr<gfxSharedImageSurface> surfY =
gfxSharedImageSurface::Open(yuv.Ydata());
nsRefPtr<gfxSharedImageSurface> surfU =
gfxSharedImageSurface::Open(yuv.Udata());
nsRefPtr<gfxSharedImageSurface> surfV =
gfxSharedImageSurface::Open(yuv.Vdata());
nsRefPtr<gfxASurface> asurfY =
ShadowLayerForwarder::OpenDescriptor(yuv.Ydata());
nsRefPtr<gfxImageSurface> surfY = asurfY->GetAsImageSurface();
nsRefPtr<gfxASurface> asurfU =
ShadowLayerForwarder::OpenDescriptor(yuv.Udata());
nsRefPtr<gfxImageSurface> surfU = asurfU->GetAsImageSurface();
// XXX do we really need to open this?
nsRefPtr<gfxASurface> asurfV =
ShadowLayerForwarder::OpenDescriptor(yuv.Vdata());
nsRefPtr<gfxImageSurface> surfV = asurfV->GetAsImageSurface();
mPictureRect = yuv.picture();
gfxIntSize size = surfY->GetSize();