Bug 929513 Part 3: Use some LayerIntSize in gfx/layers r=nical

This commit is contained in:
David Zbarsky 2013-10-27 17:53:27 -04:00
parent 2288abe9fc
commit a003dbc862
30 changed files with 129 additions and 116 deletions

View File

@ -239,18 +239,18 @@ VideoData* VideoData::Create(VideoInfo& aInfo,
PlanarYCbCrData data;
data.mYChannel = Y.mData + Y.mOffset;
data.mYSize = gfxIntSize(Y.mWidth, Y.mHeight);
data.mYSize = LayerIntSize(Y.mWidth, Y.mHeight);
data.mYStride = Y.mStride;
data.mYSkip = Y.mSkip;
data.mCbChannel = Cb.mData + Cb.mOffset;
data.mCrChannel = Cr.mData + Cr.mOffset;
data.mCbCrSize = gfxIntSize(Cb.mWidth, Cb.mHeight);
data.mCbCrSize = LayerIntSize(Cb.mWidth, Cb.mHeight);
data.mCbCrStride = Cb.mStride;
data.mCbSkip = Cb.mSkip;
data.mCrSkip = Cr.mSkip;
data.mPicX = aPicture.x;
data.mPicY = aPicture.y;
data.mPicSize = gfxIntSize(aPicture.width, aPicture.height);
data.mPicSize = LayerIntSize(aPicture.width, aPicture.height);
data.mStereoMode = aInfo.mStereoMode;
videoImage->SetDelayedConversion(true);

View File

@ -876,7 +876,7 @@ SetImageToBlackPixel(PlanarYCbCrImage* aImage)
data.mCbChannel = blackPixel + 1;
data.mCrChannel = blackPixel + 2;
data.mYStride = data.mCbCrStride = 1;
data.mPicSize = data.mYSize = data.mCbCrSize = gfxIntSize(1, 1);
data.mPicSize = data.mYSize = data.mCbCrSize = LayerIntSize(1, 1);
aImage->SetData(data);
}

View File

@ -92,15 +92,15 @@ static void AllocateSolidColorFrame(layers::PlanarYCbCrData& aData,
memset(frame+yLen+cbLen, aCr, crLen);
aData.mYChannel = frame;
aData.mYSize = gfxIntSize(aWidth, aHeight);
aData.mYSize = LayerIntSize(aWidth, aHeight);
aData.mYStride = aWidth;
aData.mCbCrStride = aWidth>>1;
aData.mCbChannel = frame + yLen;
aData.mCrChannel = aData.mCbChannel + cbLen;
aData.mCbCrSize = gfxIntSize(aWidth>>1, aHeight>>1);
aData.mCbCrSize = LayerIntSize(aWidth>>1, aHeight>>1);
aData.mPicX = 0;
aData.mPicY = 0;
aData.mPicSize = gfxIntSize(aWidth, aHeight);
aData.mPicSize = LayerIntSize(aWidth, aHeight);
aData.mStereoMode = STEREO_MODE_MONO;
}

View File

@ -76,15 +76,15 @@ MediaEngineWebRTCVideoSource::DeliverFrame(
layers::PlanarYCbCrData data;
data.mYChannel = frame;
data.mYSize = gfxIntSize(mWidth, mHeight);
data.mYSize = LayerIntSize(mWidth, mHeight);
data.mYStride = mWidth * lumaBpp/ 8;
data.mCbCrStride = mWidth * chromaBpp / 8;
data.mCbChannel = frame + mHeight * data.mYStride;
data.mCrChannel = data.mCbChannel + mHeight * data.mCbCrStride / 2;
data.mCbCrSize = gfxIntSize(mWidth/ 2, mHeight/ 2);
data.mCbCrSize = LayerIntSize(mWidth/ 2, mHeight/ 2);
data.mPicX = 0;
data.mPicY = 0;
data.mPicSize = gfxIntSize(mWidth, mHeight);
data.mPicSize = LayerIntSize(mWidth, mHeight);
data.mStereoMode = STEREO_MODE_MONO;
videoImage->SetData(data);

View File

@ -76,13 +76,13 @@ GrallocImage::SetData(const Data& aData)
NS_PRECONDITION(aData.mYStride % 16 == 0, "Image should have stride of multiple of 16 pixels");
mData = aData;
mSize = aData.mPicSize;
mSize = aData.mPicSize.ToUnknownSize();
if (!mGraphicBuffer.get()) {
SurfaceDescriptor desc;
ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
ibc->AllocSurfaceDescriptorGralloc(aData.mYSize,
ibc->AllocSurfaceDescriptorGralloc(ThebesIntSize(aData.mYSize.ToUnknownSize()),
HAL_PIXEL_FORMAT_YV12,
GraphicBuffer::USAGE_SW_READ_OFTEN |
GraphicBuffer::USAGE_SW_WRITE_OFTEN |

View File

@ -451,7 +451,7 @@ PlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
static void
CopyPlane(uint8_t *aDst, const uint8_t *aSrc,
const gfxIntSize &aSize, int32_t aStride, int32_t aSkip)
const LayerIntSize &aSize, int32_t aStride, int32_t aSkip)
{
if (!aSkip) {
// Fast path: planar input.
@ -498,7 +498,7 @@ PlanarYCbCrImage::CopyData(const Data& aData)
CopyPlane(mData.mCrChannel, aData.mCrChannel,
mData.mCbCrSize, mData.mCbCrStride, mData.mCrSkip);
mSize = aData.mPicSize;
mSize = aData.mPicSize.ToUnknownSize();
}
void
@ -519,7 +519,7 @@ void
PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
{
mData = aData;
mSize = aData.mPicSize;
mSize = aData.mPicSize.ToUnknownSize();
}
uint8_t*
@ -542,7 +542,7 @@ PlanarYCbCrImage::GetAsSurface()
}
gfxImageFormat format = GetOffscreenFormat();
gfx::IntSize size(mSize);
LayerIntSize size(mSize.width, mSize.height);
gfxUtils::GetYCbCrToRGBDestFormatAndSize(mData, format, size);
if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
size.height > PlanarYCbCrImage::MAX_DIMENSION) {
@ -553,7 +553,8 @@ PlanarYCbCrImage::GetAsSurface()
nsRefPtr<gfxImageSurface> imageSurface =
new gfxImageSurface(ThebesIntSize(mSize), format);
gfxUtils::ConvertYCbCrToRGB(mData, format, mSize,
size = LayerIntSize(mSize.width, mSize.height);
gfxUtils::ConvertYCbCrToRGB(mData, format, size,
imageSurface->Data(),
imageSurface->Stride());

View File

@ -27,6 +27,7 @@
#include "nsTArray.h" // for nsTArray
#include "mozilla/Atomics.h"
#include "nsThreadUtils.h"
#include "Units.h"
#ifndef XPCOM_GLUE_AVOID_NSPR
/**
@ -705,19 +706,19 @@ struct PlanarYCbCrData {
// Luminance buffer
uint8_t* mYChannel;
int32_t mYStride;
gfxIntSize mYSize;
LayerIntSize mYSize;
int32_t mYSkip;
// Chroma buffers
uint8_t* mCbChannel;
uint8_t* mCrChannel;
int32_t mCbCrStride;
gfxIntSize mCbCrSize;
LayerIntSize mCbCrSize;
int32_t mCbSkip;
int32_t mCrSkip;
// Picture region
uint32_t mPicX;
uint32_t mPicY;
gfxIntSize mPicSize;
LayerIntSize mPicSize;
StereoMode mStereoMode;
nsIntRect GetPictureRect() const {

View File

@ -95,16 +95,16 @@ uint32_t YCbCrImageDataDeserializerBase::GetCbCrStride()
return info->mCbCrWidth;
}
gfxIntSize YCbCrImageDataDeserializerBase::GetYSize()
LayerIntSize YCbCrImageDataDeserializerBase::GetYSize()
{
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
return gfxIntSize(info->mYWidth, info->mYHeight);
return LayerIntSize(info->mYWidth, info->mYHeight);
}
gfxIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
LayerIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
{
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
return gfxIntSize(info->mCbCrWidth, info->mCbCrHeight);
return LayerIntSize(info->mCbCrWidth, info->mCbCrHeight);
}
StereoMode YCbCrImageDataDeserializerBase::GetStereoMode()
@ -121,8 +121,8 @@ static size_t ComputeOffset(uint32_t aHeight, uint32_t aStride)
// Minimum required shmem size in bytes
size_t
YCbCrImageDataSerializer::ComputeMinBufferSize(const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize)
YCbCrImageDataSerializer::ComputeMinBufferSize(const LayerIntSize& aYSize,
const LayerIntSize& aCbCrSize)
{
uint32_t yStride = aYSize.width;
uint32_t CbCrStride = aCbCrSize.width;
@ -136,8 +136,8 @@ size_t
YCbCrImageDataSerializer::ComputeMinBufferSize(const gfxIntSize& aYSize,
const gfxIntSize& aCbCrSize)
{
return ComputeMinBufferSize(gfx::IntSize(aYSize.width, aYSize.height),
gfx::IntSize(aCbCrSize.width, aCbCrSize.height));
return ComputeMinBufferSize(LayerIntSize(aYSize.width, aYSize.height),
LayerIntSize(aCbCrSize.width, aCbCrSize.height));
}
// Offset in bytes
static size_t ComputeOffset(uint32_t aSize)
@ -153,8 +153,8 @@ YCbCrImageDataSerializer::ComputeMinBufferSize(uint32_t aSize)
}
void
YCbCrImageDataSerializer::InitializeBufferInfo(const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize,
YCbCrImageDataSerializer::InitializeBufferInfo(const LayerIntSize& aYSize,
const LayerIntSize& aCbCrSize,
StereoMode aStereoMode)
{
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
@ -176,8 +176,8 @@ YCbCrImageDataSerializer::InitializeBufferInfo(const gfxIntSize& aYSize,
const gfxIntSize& aCbCrSize,
StereoMode aStereoMode)
{
InitializeBufferInfo(gfx::IntSize(aYSize.width, aYSize.height),
gfx::IntSize(aCbCrSize.width, aCbCrSize.height),
InitializeBufferInfo(LayerIntSize(aYSize.width, aYSize.height),
LayerIntSize(aCbCrSize.width, aCbCrSize.height),
aStereoMode);
}
@ -192,8 +192,8 @@ static void CopyLineWithSkip(const uint8_t* src, uint8_t* dst, uint32_t len, uin
bool
YCbCrImageDataSerializer::CopyData(const uint8_t* aYData,
const uint8_t* aCbData, const uint8_t* aCrData,
gfxIntSize aYSize, uint32_t aYStride,
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
LayerIntSize aYSize, uint32_t aYStride,
LayerIntSize aCbCrSize, uint32_t aCbCrStride,
uint32_t aYSkip, uint32_t aCbCrSkip)
{
if (!IsValid() || GetYSize() != aYSize || GetCbCrSize() != aCbCrSize) {
@ -238,7 +238,7 @@ TemporaryRef<gfx::DataSourceSurface>
YCbCrImageDataDeserializer::ToDataSourceSurface()
{
RefPtr<gfx::DataSourceSurface> result =
gfx::Factory::CreateDataSourceSurface(ToIntSize(GetYSize()), gfx::FORMAT_R8G8B8X8);
gfx::Factory::CreateDataSourceSurface(GetYSize().ToUnknownSize(), gfx::FORMAT_R8G8B8X8);
gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
result->GetData(),

View File

@ -13,6 +13,7 @@
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
#include "mozilla/RefPtr.h" // for TemporaryRef
#include "mozilla/gfx/Point.h" // for IntSize
#include "Units.h"
namespace mozilla {
namespace gfx {
@ -58,12 +59,12 @@ public:
/**
* Returns the dimensions of the Y Channel.
*/
gfxIntSize GetYSize();
LayerIntSize GetYSize();
/**
* Returns the dimensions of the Cb and Cr Channel.
*/
gfxIntSize GetCbCrSize();
LayerIntSize GetCbCrSize();
/**
* Stereo mode for the image.
@ -103,8 +104,8 @@ public:
* to allocate in a shmem in order to place a shared YCbCr image blob of
* given dimensions.
*/
static size_t ComputeMinBufferSize(const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize);
static size_t ComputeMinBufferSize(const LayerIntSize& aYSize,
const LayerIntSize& aCbCrSize);
static size_t ComputeMinBufferSize(const gfxIntSize& aYSize,
const gfxIntSize& aCbCrSize);
static size_t ComputeMinBufferSize(uint32_t aSize);
@ -114,8 +115,8 @@ public:
* The provided pointer should point to the beginning of the (chunk of)
* buffer on which we want to store the image.
*/
void InitializeBufferInfo(const gfx::IntSize& aYSize,
const gfx::IntSize& aCbCrSize,
void InitializeBufferInfo(const LayerIntSize& aYSize,
const LayerIntSize& aCbCrSize,
StereoMode aStereoMode);
void InitializeBufferInfo(const gfxIntSize& aYSize,
const gfxIntSize& aCbCrSize,
@ -123,8 +124,8 @@ public:
bool CopyData(const uint8_t* aYData,
const uint8_t* aCbData, const uint8_t* aCrData,
gfxIntSize aYSize, uint32_t aYStride,
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
LayerIntSize aYSize, uint32_t aYStride,
LayerIntSize aCbCrSize, uint32_t aCbCrStride,
uint32_t aYSkip, uint32_t aCbCrSkip);
};

View File

@ -186,7 +186,7 @@ public:
DeserializerToPlanarYCbCrImageData(deserializer, data);
gfxImageFormat format = gfxImageFormatRGB24;
gfx::IntSize size;
LayerIntSize size;
gfxUtils::GetYCbCrToRGBDestFormatAndSize(data, format, size);
if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
size.height > PlanarYCbCrImage::MAX_DIMENSION) {
@ -195,7 +195,7 @@ public:
}
mThebesSurface = mThebesImage =
new gfxImageSurface(ThebesIntSize(size), format);
new gfxImageSurface(ThebesIntSize(size.ToUnknownSize()), format);
gfxUtils::ConvertYCbCrToRGB(data, format, size,
mThebesImage->Data(),

View File

@ -101,7 +101,7 @@ BasicPlanarYCbCrImage::SetData(const Data& aData)
gfxImageFormat format = GetOffscreenFormat();
gfx::IntSize size(mScaleHint);
LayerIntSize size(mScaleHint.width, mScaleHint.height);
gfxUtils::GetYCbCrToRGBDestFormatAndSize(aData, format, size);
if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
size.height > PlanarYCbCrImage::MAX_DIMENSION) {
@ -118,7 +118,7 @@ BasicPlanarYCbCrImage::SetData(const Data& aData)
gfxUtils::ConvertYCbCrToRGB(aData, format, size, mDecodedBuffer, mStride);
SetOffscreenFormat(format);
mSize = size;
mSize = size.ToUnknownSize();
}
static cairo_user_data_key_t imageSurfaceDataKey;

View File

@ -169,8 +169,8 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
bool bufferCreated = false;
if (!mFrontBuffer) {
mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_FLAGS_DEFAULT);
gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
LayerIntSize ySize(data->mYSize.width, data->mYSize.height);
LayerIntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
mFrontBuffer = nullptr;
return false;

View File

@ -315,7 +315,7 @@ BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
}
ImageDataSerializer serializer(GetBuffer());
serializer.InitializeBufferInfo(aSize, mFormat);
mSize = aSize;
mSize = LayerIntSize(aSize.width, aSize.height);
return true;
}
@ -346,8 +346,8 @@ BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
}
bool
BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
BufferTextureClient::AllocateForYCbCr(LayerIntSize aYSize,
LayerIntSize aCbCrSize,
StereoMode aStereoMode)
{
MOZ_ASSERT(IsValid());

View File

@ -24,6 +24,7 @@
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsISupportsImpl.h" // for TextureImage::AddRef, etc
#include "Units.h"
class gfxReusableSurfaceWrapper;
class gfxASurface;
@ -66,8 +67,8 @@ class TextureClientYCbCr
{
public:
virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) = 0;
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
virtual bool AllocateForYCbCr(LayerIntSize aYSize,
LayerIntSize aCbCrSize,
StereoMode aStereoMode) = 0;
};
@ -250,7 +251,7 @@ public:
virtual uint8_t* GetBuffer() const = 0;
virtual gfx::IntSize GetSize() const { return mSize; }
virtual gfx::IntSize GetSize() const { return mSize.ToUnknownSize(); }
// TextureClientSurface
@ -268,8 +269,8 @@ public:
virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
virtual bool AllocateForYCbCr(LayerIntSize aYSize,
LayerIntSize aCbCrSize,
StereoMode aStereoMode) MOZ_OVERRIDE;
gfx::SurfaceFormat GetFormat() const { return mFormat; }
@ -285,7 +286,7 @@ public:
protected:
CompositableClient* mCompositable;
gfx::SurfaceFormat mFormat;
gfx::IntSize mSize;
LayerIntSize mSize;
};
/**

View File

@ -413,17 +413,17 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
RefPtr<gfx::DataSourceSurface> tempY =
gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
yuvDeserializer.GetYStride(),
gfx::ToIntSize(yuvDeserializer.GetYSize()),
yuvDeserializer.GetYSize().ToUnknownSize(),
gfx::FORMAT_A8);
RefPtr<gfx::DataSourceSurface> tempCb =
gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
yuvDeserializer.GetCbCrStride(),
gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
yuvDeserializer.GetCbCrSize().ToUnknownSize(),
gfx::FORMAT_A8);
RefPtr<gfx::DataSourceSurface> tempCr =
gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
yuvDeserializer.GetCbCrStride(),
gfx::ToIntSize(yuvDeserializer.GetCbCrSize()),
yuvDeserializer.GetCbCrSize().ToUnknownSize(),
gfx::FORMAT_A8);
// We don't support partial updates for Y U V textures
NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
@ -470,7 +470,7 @@ BufferTextureHost::GetAsSurface()
return nullptr;
}
result = new gfxImageSurface(yuvDeserializer.GetYData(),
yuvDeserializer.GetYSize(),
ThebesIntSize(yuvDeserializer.GetYSize().ToUnknownSize()),
yuvDeserializer.GetYStride(),
gfxImageFormatA8);
} else {

View File

@ -486,9 +486,9 @@ DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
gfxIntSize size = yuvDeserializer.GetYSize();
LayerIntSize size = yuvDeserializer.GetYSize();
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = yuvDeserializer.GetYData();
@ -502,15 +502,15 @@ DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
initData.pSysMem = yuvDeserializer.GetCbData();
initData.SysMemPitch = yuvDeserializer.GetCbCrStride();
desc.Width = yuvDeserializer.GetCbCrSize().width;
desc.Height = yuvDeserializer.GetCbCrSize().height;
desc.Width = gfxCbCrSize.width;
desc.Height = gfxCbCrSize.height;
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));
initData.pSysMem = yuvDeserializer.GetCrData();
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));
mSize = IntSize(size.width, size.height);
mSize = size.ToUnknownSize();
}
}

View File

@ -215,7 +215,7 @@ static TemporaryRef<IDirect3DTexture9>
DataToTexture(IDirect3DDevice9 *aDevice,
unsigned char *aData,
int aStride,
const gfxIntSize &aSize,
const LayerIntSize &aSize,
_D3DFORMAT aFormat,
uint32_t aBPP)
{
@ -224,7 +224,7 @@ DataToTexture(IDirect3DDevice9 *aDevice,
D3DLOCKED_RECT lockedRect;
bool usingD3D9Ex;
if (!InitTextures(aDevice, aSize, aFormat,
if (!InitTextures(aDevice, ThebesIntSize(aSize.ToUnknownSize()), aFormat,
texture, surface, lockedRect, usingD3D9Ex)) {
return nullptr;
}
@ -285,7 +285,8 @@ DeprecatedTextureHostShmemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
if (size.width <= maxSize && size.height <= maxSize) {
mTextures[0] = DataToTexture(mDevice,
surf->Data(), surf->Stride(),
size, format, bpp);
LayerIntSize(size.width, size.height),
format, bpp);
NS_ASSERTION(mTextures[0], "Could not upload texture");
mIsTiled = false;
} else {
@ -302,7 +303,7 @@ DeprecatedTextureHostShmemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
mTileTextures[i] = DataToTexture(mDevice,
data,
surf->Stride(),
gfxIntSize(tileRect.width, tileRect.height),
LayerIntSize(tileRect.width, tileRect.height),
format,
bpp);
}
@ -347,9 +348,9 @@ DeprecatedTextureHostYCbCrD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
gfxIntSize size = yuvDeserializer.GetYSize();
mSize = IntSize(size.width, size.height);
LayerIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
LayerIntSize size = yuvDeserializer.GetYSize();
mSize = size.ToUnknownSize();
mStereoMode = yuvDeserializer.GetStereoMode();
mTextures[0] = DataToTexture(mDevice,
@ -458,7 +459,7 @@ DeprecatedTextureHostSystemMemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
mTileTextures[i] = DataToTexture(mDevice,
reinterpret_cast<unsigned char*>(lockedRect.pBits),
lockedRect.Pitch,
gfxIntSize(tileRect.width, tileRect.height),
LayerIntSize(tileRect.width, tileRect.height),
format,
bpp);
texture->UnlockRect(0);
@ -568,7 +569,7 @@ DeprecatedTextureHostDIB::UpdateImpl(const SurfaceDescriptor& aImage,
mTileTextures[i] = DataToTexture(mDevice,
data,
imgSurface->Stride(),
gfxIntSize(tileRect.width, tileRect.height),
LayerIntSize(tileRect.width, tileRect.height),
format,
bpp);
}

View File

@ -103,7 +103,7 @@ SharedPlanarYCbCrImage::SetData(const PlanarYCbCrData& aData)
// shmem.
mBufferSize = YCbCrImageDataSerializer::ComputeMinBufferSize(mData.mYSize,
mData.mCbCrSize);
mSize = mData.mPicSize;
mSize = mData.mPicSize.ToUnknownSize();
YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
mData.mYChannel = serializer.GetYData();
@ -134,7 +134,7 @@ void
SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
{
mData = aData;
mSize = aData.mPicSize;
mSize = aData.mPicSize.ToUnknownSize();
YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
serializer.InitializeBufferInfo(aData.mYSize,
aData.mCbCrSize,
@ -219,7 +219,7 @@ DeprecatedSharedPlanarYCbCrImage::SetData(const PlanarYCbCrData& aData)
// shmem.
mBufferSize = YCbCrImageDataSerializer::ComputeMinBufferSize(mData.mYSize,
mData.mCbCrSize);
mSize = mData.mPicSize;
mSize = mData.mPicSize.ToUnknownSize();
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip);
@ -256,7 +256,7 @@ void
DeprecatedSharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
{
mData = aData;
mSize = aData.mPicSize;
mSize = aData.mPicSize.ToUnknownSize();
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
serializer.InitializeBufferInfo(aData.mYSize,
aData.mCbCrSize,

View File

@ -21,6 +21,7 @@
#include "nsRegion.h" // for nsIntRegion
#include "nsSize.h" // for nsIntSize
#include "LayerManagerOGL.h" // for LayerOGL::GLContext, etc
#include "gfx2DGlue.h"
#ifdef XP_MACOSX
#include "mozilla/gfx/MacIOSurface.h"
@ -384,7 +385,7 @@ CanvasLayerOGL::CleanupResources()
}
gfxImageSurface*
CanvasLayerOGL::GetTempSurface(const gfxIntSize& aSize,
CanvasLayerOGL::GetTempSurface(const LayerIntSize& aSize,
const gfxImageFormat aFormat)
{
if (!mCachedTempSurface ||
@ -392,7 +393,8 @@ CanvasLayerOGL::GetTempSurface(const gfxIntSize& aSize,
aSize.height != mCachedSize.height ||
aFormat != mCachedFormat)
{
mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
mCachedTempSurface = new gfxImageSurface(ThebesIntSize(aSize.ToUnknownSize()),
aFormat);
mCachedSize = aSize;
mCachedFormat = aFormat;
}

View File

@ -11,7 +11,6 @@
#include "LayerManagerOGL.h" // for LayerOGL::GLContext, etc
#include "Layers.h" // for CanvasLayer, etc
#include "gfxTypes.h"
#include "gfxPoint.h" // for gfxIntSize
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/gfx/2D.h" // for DrawTarget
@ -69,10 +68,10 @@ protected:
#endif
nsRefPtr<gfxImageSurface> mCachedTempSurface;
gfxIntSize mCachedSize;
LayerIntSize mCachedSize;
gfxImageFormat mCachedFormat;
gfxImageSurface* GetTempSurface(const gfxIntSize& aSize,
gfxImageSurface* GetTempSurface(const LayerIntSize& aSize,
const gfxImageFormat aFormat);
void DiscardTempSurface() {

View File

@ -223,10 +223,12 @@ GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize)
}
bool
GrallocTextureClientOGL::AllocateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode)
GrallocTextureClientOGL::AllocateForYCbCr(LayerIntSize aYSize,
LayerIntSize aCbCrSize,
StereoMode aStereoMode)
{
MOZ_ASSERT(IsValid());
return AllocateGralloc(aYSize,
return AllocateGralloc(aYSize.ToUnknownSize(),
HAL_PIXEL_FORMAT_YV12,
android::GraphicBuffer::USAGE_SW_READ_OFTEN);
}

View File

@ -82,8 +82,8 @@ public:
virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
virtual bool AllocateForYCbCr(LayerIntSize aYSize,
LayerIntSize aCbCrSize,
StereoMode aStereoMode) MOZ_OVERRIDE;
bool AllocateGralloc(gfx::IntSize aYSize, uint32_t aAndroidFormat, uint32_t aUsage);

View File

@ -27,6 +27,7 @@
#include "nsThreadUtils.h" // for nsRunnable
#include "nscore.h" // for NS_IMETHOD
#include "LayerManagerOGL.h" // for LayerOGL::GLContext, etc
#include "gfx2DGlue.h"
#if defined(GL_PROVIDER_GLX)
# include "GLXLibrary.h"
# include "gfxXlibSurface.h"
@ -140,7 +141,7 @@ TextureRecycleBin::TextureRecycleBin()
void
TextureRecycleBin::RecycleTexture(GLTexture *aTexture, TextureType aType,
const gfxIntSize& aSize)
const LayerIntSize& aSize)
{
MutexAutoLock lock(mLock);
@ -155,7 +156,7 @@ TextureRecycleBin::RecycleTexture(GLTexture *aTexture, TextureType aType,
}
void
TextureRecycleBin::GetTexture(TextureType aType, const gfxIntSize& aSize,
TextureRecycleBin::GetTexture(TextureType aType, const LayerIntSize& aSize,
GLContext *aContext, GLTexture *aOutTexture)
{
MutexAutoLock lock(mLock);
@ -399,7 +400,7 @@ UploadYUVToTexture(GLContext* gl, const PlanarYCbCrData& aData,
nsIntRect size(0, 0, aData.mYSize.width, aData.mYSize.height);
GLuint texture = aYTexture->GetTextureID();
nsRefPtr<gfxASurface> surf = new gfxImageSurface(aData.mYChannel,
aData.mYSize,
ThebesIntSize(aData.mYSize.ToUnknownSize()),
aData.mYStride,
gfxImageFormatA8);
gl->UploadSurfaceToTexture(surf, size, texture, true);
@ -407,14 +408,14 @@ UploadYUVToTexture(GLContext* gl, const PlanarYCbCrData& aData,
size = nsIntRect(0, 0, aData.mCbCrSize.width, aData.mCbCrSize.height);
texture = aUTexture->GetTextureID();
surf = new gfxImageSurface(aData.mCbChannel,
aData.mCbCrSize,
ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
aData.mCbCrStride,
gfxImageFormatA8);
gl->UploadSurfaceToTexture(surf, size, texture, true);
texture = aVTexture->GetTextureID();
surf = new gfxImageSurface(aData.mCrChannel,
aData.mCbCrSize,
ThebesIntSize(aData.mCbCrSize.ToUnknownSize()),
aData.mCbCrStride,
gfxImageFormatA8);
gl->UploadSurfaceToTexture(surf, size, texture, true);

View File

@ -10,7 +10,6 @@
#include "ImageContainer.h" // for ImageBackendData, etc
#include "ImageLayers.h" // for ImageLayer
#include "LayerManagerOGL.h" // for LayerOGL
#include "gfxPoint.h" // for gfxIntSize
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/Mutex.h" // for Mutex
#include "mozilla/mozalloc.h" // for operator delete
@ -89,8 +88,8 @@ public:
};
void RecycleTexture(GLTexture *aTexture, TextureType aType,
const gfxIntSize& aSize);
void GetTexture(TextureType aType, const gfxIntSize& aSize,
const LayerIntSize& aSize);
void GetTexture(TextureType aType, const LayerIntSize& aSize,
GLContext *aContext, GLTexture *aOutTexture);
private:
@ -101,7 +100,7 @@ private:
Mutex mLock;
nsTArray<GLTexture> mRecycledTextures[2];
gfxIntSize mRecycledTextureSizes[2];
LayerIntSize mRecycledTextureSizes[2];
};
class ImageLayerOGL : public ImageLayer,
@ -146,7 +145,7 @@ struct PlanarYCbCrOGLBackendData : public ImageBackendData
}
GLTexture mTextures[3];
gfxIntSize mYSize, mCbCrSize;
LayerIntSize mYSize, mCbCrSize;
nsRefPtr<TextureRecycleBin> mTextureRecycleBin;
};

View File

@ -846,8 +846,8 @@ YCbCrDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
gfxIntSize gfxSize = deserializer.GetYSize();
gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize();
gfxIntSize gfxSize = ThebesIntSize(deserializer.GetYSize().ToUnknownSize());
gfxIntSize gfxCbCrSize = ThebesIntSize(deserializer.GetCbCrSize().ToUnknownSize());
if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) {
mYTexture->mTexImage = CreateBasicTextureImage(mGL,

View File

@ -151,8 +151,8 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
// client allocation
ASSERT_TRUE(client->AsTextureClientYCbCr() != nullptr);
TextureClientYCbCr* texture = client->AsTextureClientYCbCr();
texture->AllocateForYCbCr(ToIntSize(ycbcrData.mYSize),
ToIntSize(ycbcrData.mCbCrSize),
texture->AllocateForYCbCr(ycbcrData.mYSize,
ycbcrData.mCbCrSize,
ycbcrData.mStereoMode);
ASSERT_TRUE(client->IsAllocated());
@ -249,9 +249,12 @@ TEST(Layers, TextureYCbCrSerialization) {
clientData.mYChannel = ySurface->Data();
clientData.mCbChannel = cbSurface->Data();
clientData.mCrChannel = crSurface->Data();
clientData.mYSize = ySurface->GetSize();
clientData.mPicSize = ySurface->GetSize();
clientData.mCbCrSize = cbSurface->GetSize();
clientData.mYSize = LayerIntSize(ySurface->GetSize().width,
ySurface->GetSize().height);
clientData.mPicSize = LayerIntSize(ySurface->GetSize().width,
ySurface->GetSize().height);
clientData.mCbCrSize = LayerIntSize(cbSurface->GetSize().width,
cbSurface->GetSize().height);
clientData.mYStride = ySurface->Stride();
clientData.mCbCrStride = cbSurface->Stride();
clientData.mStereoMode = STEREO_MODE_MONO;

View File

@ -685,7 +685,7 @@ gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
void
gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
gfxImageFormat& aSuggestedFormat,
gfx::IntSize& aSuggestedSize)
LayerIntSize& aSuggestedSize)
{
gfx::YUVType yuvtype =
gfx::TypeFromSize(aData.mYSize.width,
@ -739,7 +739,7 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
void
gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData,
const gfxImageFormat& aDestFormat,
const gfx::IntSize& aDestSize,
const LayerIntSize& aDestSize,
unsigned char* aDestBuffer,
int32_t aStride)
{

View File

@ -9,6 +9,7 @@
#include "gfxTypes.h"
#include "GraphicsFilter.h"
#include "imgIContainer.h"
#include "Units.h"
class gfxDrawable;
class nsIntRegion;
@ -134,7 +135,7 @@ public:
static void
GetYCbCrToRGBDestFormatAndSize(const mozilla::layers::PlanarYCbCrData& aData,
gfxImageFormat& aSuggestedFormat,
mozilla::gfx::IntSize& aSuggestedSize);
mozilla::LayerIntSize& aSuggestedSize);
/**
* Convert YCbCrImage into RGB aDestBuffer
@ -144,7 +145,7 @@ public:
static void
ConvertYCbCrToRGB(const mozilla::layers::PlanarYCbCrData& aData,
const gfxImageFormat& aDestFormat,
const mozilla::gfx::IntSize& aDestSize,
const mozilla::LayerIntSize& aDestSize,
unsigned char* aDestBuffer,
int32_t aStride);

View File

@ -1148,15 +1148,15 @@ void MediaPipelineReceiveVideo::PipelineListener::RenderVideoFrame(
layers::PlanarYCbCrData data;
data.mYChannel = frame;
data.mYSize = gfxIntSize(width_, height_);
data.mYSize = LayerIntSize(width_, height_);
data.mYStride = width_ * lumaBpp/ 8;
data.mCbCrStride = width_ * chromaBpp / 8;
data.mCbChannel = frame + height_ * data.mYStride;
data.mCrChannel = data.mCbChannel + height_ * data.mCbCrStride / 2;
data.mCbCrSize = gfxIntSize(width_/ 2, height_/ 2);
data.mCbCrSize = LayerIntSize(width_/ 2, height_/ 2);
data.mPicX = 0;
data.mPicY = 0;
data.mPicSize = gfxIntSize(width_, height_);
data.mPicSize = LayerIntSize(width_, height_);
data.mStereoMode = STEREO_MODE_MONO;
videoImage->SetData(data);

View File

@ -39,6 +39,7 @@ namespace mozilla {
#include "nriceresolver.h"
#include "nricemediastream.h"
#include "MediaPipeline.h"
#include "Units.h"
namespace sipcc {
@ -131,15 +132,15 @@ class Fake_VideoGenerator {
mozilla::layers::PlanarYCbCrData data;
data.mYChannel = frame;
data.mYSize = gfxIntSize(WIDTH, HEIGHT);
data.mYSize = mozilla::LayerIntSize(WIDTH, HEIGHT);
data.mYStride = (int32_t) (WIDTH * lumaBpp / 8.0);
data.mCbCrStride = (int32_t) (WIDTH * chromaBpp / 8.0);
data.mCbChannel = frame + HEIGHT * data.mYStride;
data.mCrChannel = data.mCbChannel + HEIGHT * data.mCbCrStride / 2;
data.mCbCrSize = gfxIntSize(WIDTH / 2, HEIGHT / 2);
data.mCbCrSize = mozilla::LayerIntSize(WIDTH / 2, HEIGHT / 2);
data.mPicX = 0;
data.mPicY = 0;
data.mPicSize = gfxIntSize(WIDTH, HEIGHT);
data.mPicSize = mozilla::LayerIntSize(WIDTH, HEIGHT);
data.mStereoMode = mozilla::STEREO_MODE_MONO;
// SetData copies data, so we can free the frame