Bug 1262278 - Rename PlanarYCbCrImage::SetData and PlanarYCbCrImage::SetDataNoCopy r=nical

This commit is contained in:
Sotaro Ikeda 2016-04-18 20:12:41 -07:00
Родитель 2792ab700c
Коммит 3b81e9dd7d
19 изменённых файлов: 36 добавлений и 47 удалений

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

@ -2382,7 +2382,7 @@ nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer)
IntSize picSize(mCurrentConfiguration.mPreviewSize.width,
mCurrentConfiguration.mPreviewSize.height);
frame->SetData(aBuffer, picSize);
frame->AdoptData(aBuffer, picSize);
if (mCapturePoster.exchange(false)) {
CreatePoster(frame,

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

@ -247,9 +247,9 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
aVideoImage->SetDelayedConversion(true);
if (aCopyData) {
return aVideoImage->SetData(data);
return aVideoImage->CopyData(data);
} else {
return aVideoImage->SetDataNoCopy(data);
return aVideoImage->AdoptData(data);
}
}
@ -480,7 +480,7 @@ VideoData::Create(const VideoInfo& aInfo,
0));
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
image->SetData(aBuffer, aPicture.Size());
image->AdoptData(aBuffer, aPicture.Size());
v->mImage = image;
return v.forget();

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

@ -890,7 +890,7 @@ SetImageToBlackPixel(PlanarYCbCrImage* aImage)
data.mCrChannel = blackPixel + 2;
data.mYStride = data.mCbCrStride = 1;
data.mPicSize = data.mYSize = data.mCbCrSize = IntSize(1, 1);
aImage->SetData(data);
aImage->CopyData(data);
}
class VideoFrameContainerInvalidateRunnable : public nsRunnable {

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

@ -79,8 +79,8 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
data.mPicSize = gfx::IntSize(aSize.width, aSize.height);
data.mStereoMode = StereoMode::MONO;
// SetData copies data, so we can free data.
if (!image->SetData(data)) {
// Copies data, so we can free data.
if (!image->CopyData(data)) {
MOZ_ASSERT(false);
return nullptr;
}

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

@ -421,7 +421,7 @@ AndroidMediaReader::ImageBufferCallback::CreateI420Image(size_t aWidth,
frameDesc.mPicY = 0;
frameDesc.mPicSize = IntSize(aWidth, aHeight);
yuvImage->SetDataNoCopy(frameDesc);
yuvImage->AdoptData(frameDesc);
return buffer;
}

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

@ -87,7 +87,7 @@ private:
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
image->CopyData(data);
return image;
}
@ -124,7 +124,7 @@ private:
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
image->CopyData(data);
return image;
}
@ -161,7 +161,7 @@ private:
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
image->CopyData(data);
return image;
}

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

@ -489,7 +489,7 @@ OMXVideoEncoder::Encode(const Image* aImage, int aWidth, int aHeight,
NS_ENSURE_TRUE(aWidth == size.width, NS_ERROR_INVALID_ARG);
NS_ENSURE_TRUE(aHeight == size.height, NS_ERROR_INVALID_ARG);
if (format == ImageFormat::PLANAR_YCBCR) {
// Test for data, allowing SetDataNoCopy() on an image without an mBuffer
// Test for data, allowing AdoptData() on an image without an mBuffer
// (as used from WebrtcOMXH264VideoCodec, and a few other places) - bug 1067442
const PlanarYCbCrData* yuv = static_cast<PlanarYCbCrImage*>(img)->GetData();
NS_ENSURE_TRUE(yuv->mYChannel, NS_ERROR_INVALID_ARG);

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

@ -251,7 +251,7 @@ MediaEngineDefaultVideoSource::Notify(nsITimer* aTimer)
0, 0);
#endif
bool setData = ycbcr_image->SetData(data);
bool setData = ycbcr_image->CopyData(data);
MOZ_ASSERT(setData);
// SetData copies data, so we can free the frame

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

@ -789,7 +789,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
libyuv::FOURCC_NV21);
destBuffer->unlock();
image->AsGrallocImage()->SetData(textureClient, gfx::IntSize(dstWidth, dstHeight));
image->AsGrallocImage()->AdoptData(textureClient, gfx::IntSize(dstWidth, dstHeight));
} else {
// Handle out of gralloc case.
image = mImageContainer->CreatePlanarYCbCrImage();
@ -821,7 +821,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
data.mPicSize = IntSize(dstWidth, dstHeight);
data.mStereoMode = StereoMode::MONO;
image->AsPlanarYCbCrImage()->SetDataNoCopy(data);
image->AsPlanarYCbCrImage()->AdoptData(data);
}
graphicBuffer->unlock();

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

@ -342,7 +342,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(unsigned char* buffer,
data.mPicSize = IntSize(mWidth, mHeight);
data.mStereoMode = StereoMode::MONO;
if (!image->SetData(data)) {
if (!image->CopyData(data)) {
MOZ_ASSERT(false);
return 0;
}

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

@ -144,7 +144,7 @@ GrallocImage::SetData(const Data& aData)
}
void
GrallocImage::SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
GrallocImage::AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
{
mTextureClient = aGraphicBuffer;
mSize = aSize;

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

@ -63,11 +63,12 @@ public:
*/
virtual bool SetData(const Data& aData);
using RecyclingPlanarYCbCrImage::AdoptData;
/**
* Share the SurfaceDescriptor without making the copy, in order
* to support functioning in all different layer managers.
*/
void SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
void AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
// From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
enum {

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

@ -534,12 +534,6 @@ RecyclingPlanarYCbCrImage::CopyData(const Data& aData)
return true;
}
bool
RecyclingPlanarYCbCrImage::SetData(const Data &aData)
{
return CopyData(aData);
}
gfxImageFormat
PlanarYCbCrImage::GetOffscreenFormat()
{
@ -549,7 +543,7 @@ PlanarYCbCrImage::GetOffscreenFormat()
}
bool
PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
PlanarYCbCrImage::AdoptData(const Data &aData)
{
mData = aData;
mSize = aData.mPicSize;

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

@ -727,16 +727,16 @@ public:
* This makes a copy of the data buffers, in order to support functioning
* in all different layer managers.
*/
virtual bool SetData(const Data& aData) = 0;
virtual bool CopyData(const Data& aData) = 0;
/**
* This doesn't make a copy of the data buffers. Can be used when mBuffer is
* pre allocated with AllocateAndGetNewBuffer(size) and then SetDataNoCopy is
* pre allocated with AllocateAndGetNewBuffer(size) and then AdoptData is
* called to only update the picture size, planes etc. fields in mData.
* The GStreamer media backend uses this to decode into PlanarYCbCrImage(s)
* directly.
*/
virtual bool SetDataNoCopy(const Data &aData);
virtual bool AdoptData(const Data &aData);
/**
* This allocates and returns a new buffer
@ -793,16 +793,10 @@ class RecyclingPlanarYCbCrImage: public PlanarYCbCrImage {
public:
explicit RecyclingPlanarYCbCrImage(BufferRecycleBin *aRecycleBin) : mRecycleBin(aRecycleBin) {}
virtual ~RecyclingPlanarYCbCrImage() override;
virtual bool SetData(const Data& aData) override;
virtual bool CopyData(const Data& aData) override;
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
protected:
/**
* Make a copy of the YCbCr data into local storage.
*
* @param aData Input image data.
*/
bool CopyData(const Data& aData);
/**
* Return a buffer to store image data in.

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

@ -49,7 +49,7 @@ public:
}
}
virtual bool SetData(const Data& aData) override;
virtual bool CopyData(const Data& aData) override;
virtual void SetDelayedConversion(bool aDelayed) override { mDelayedConversion = aDelayed; }
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
@ -86,9 +86,9 @@ public:
};
bool
BasicPlanarYCbCrImage::SetData(const Data& aData)
BasicPlanarYCbCrImage::CopyData(const Data& aData)
{
RecyclingPlanarYCbCrImage::SetData(aData);
RecyclingPlanarYCbCrImage::CopyData(aData);
if (mDelayedConversion) {
return false;

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

@ -82,7 +82,7 @@ SharedPlanarYCbCrImage::GetAsSourceSurface()
}
bool
SharedPlanarYCbCrImage::SetData(const PlanarYCbCrData& aData)
SharedPlanarYCbCrImage::CopyData(const PlanarYCbCrData& aData)
{
// If mTextureClient has not already been allocated (through Allocate(aData))
// allocate it. This code path is slower than the one used when Allocate has
@ -140,9 +140,9 @@ SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
}
bool
SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
SharedPlanarYCbCrImage::AdoptData(const Data &aData)
{
// SetDataNoCopy is used to update YUV plane offsets without (re)allocating
// AdoptData is used to update YUV plane offsets without (re)allocating
// memory previously allocated with AllocateAndGetNewBuffer().
MOZ_ASSERT(mTextureClient, "This Image should have already allocated data");

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

@ -34,8 +34,8 @@ public:
virtual uint8_t* GetBuffer() override;
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual bool SetData(const PlanarYCbCrData& aData) override;
virtual bool SetDataNoCopy(const Data &aData) override;
virtual bool CopyData(const PlanarYCbCrData& aData) override;
virtual bool AdoptData(const Data &aData) override;
virtual bool Allocate(PlanarYCbCrData& aData);
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;

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

@ -529,7 +529,7 @@ public:
gfx::IntSize picSize(buffer->GetSize());
nsAutoPtr<layers::GrallocImage> grallocImage(new layers::GrallocImage());
grallocImage->SetData(buffer, picSize);
grallocImage->AdoptData(buffer, picSize);
// Get timestamp of the frame about to render.
int64_t timestamp = -1;
@ -1004,8 +1004,8 @@ WebrtcOMXH264VideoEncoder::Encode(const webrtc::I420VideoFrame& aInputImage,
yuvData.mPicSize = yuvData.mYSize;
yuvData.mStereoMode = StereoMode::MONO;
layers::RecyclingPlanarYCbCrImage img(nullptr);
// SetDataNoCopy() doesn't need AllocateAndGetNewBuffer(); OMXVideoEncoder is ok with this
img.SetDataNoCopy(yuvData);
// AdoptData() doesn't need AllocateAndGetNewBuffer(); OMXVideoEncoder is ok with this
img.AdoptData(yuvData);
CODEC_LOGD("Encode frame: %dx%d, timestamp %u (%lld), renderTimeMs %" PRIu64,
aInputImage.width(), aInputImage.height(),

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

@ -2234,7 +2234,7 @@ public:
yuvData.mPicSize = IntSize(width_, height_);
yuvData.mStereoMode = StereoMode::MONO;
if (!yuvImage->SetData(yuvData)) {
if (!yuvImage->CopyData(yuvData)) {
MOZ_ASSERT(false);
return;
}