From 3b81e9dd7d90e0385a781d034de62ad6af0a9a32 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Mon, 18 Apr 2016 20:12:41 -0700 Subject: [PATCH] Bug 1262278 - Rename PlanarYCbCrImage::SetData and PlanarYCbCrImage::SetDataNoCopy r=nical --- dom/camera/GonkCameraControl.cpp | 2 +- dom/media/MediaData.cpp | 6 +++--- dom/media/MediaStreamGraph.cpp | 2 +- dom/media/VideoSegment.cpp | 4 ++-- dom/media/android/AndroidMediaReader.cpp | 2 +- dom/media/gtest/TestVideoTrackEncoder.cpp | 6 +++--- dom/media/omx/OMXCodecWrapper.cpp | 2 +- dom/media/webrtc/MediaEngineDefault.cpp | 2 +- dom/media/webrtc/MediaEngineGonkVideoSource.cpp | 4 ++-- dom/media/webrtc/MediaEngineRemoteVideoSource.cpp | 2 +- gfx/layers/GrallocImages.cpp | 2 +- gfx/layers/GrallocImages.h | 3 ++- gfx/layers/ImageContainer.cpp | 8 +------- gfx/layers/ImageContainer.h | 14 ++++---------- gfx/layers/basic/BasicImages.cpp | 6 +++--- gfx/layers/ipc/SharedPlanarYCbCrImage.cpp | 6 +++--- gfx/layers/ipc/SharedPlanarYCbCrImage.h | 4 ++-- .../src/media-conduit/WebrtcOMXH264VideoCodec.cpp | 6 +++--- .../signaling/src/mediapipeline/MediaPipeline.cpp | 2 +- 19 files changed, 36 insertions(+), 47 deletions(-) diff --git a/dom/camera/GonkCameraControl.cpp b/dom/camera/GonkCameraControl.cpp index 280a77391c08..4f5e6f225ebc 100644 --- a/dom/camera/GonkCameraControl.cpp +++ b/dom/camera/GonkCameraControl.cpp @@ -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, diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp index 8b3e8ff69e82..2f845812b590 100644 --- a/dom/media/MediaData.cpp +++ b/dom/media/MediaData.cpp @@ -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 image = new layers::GrallocImage(); - image->SetData(aBuffer, aPicture.Size()); + image->AdoptData(aBuffer, aPicture.Size()); v->mImage = image; return v.forget(); diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 9994336df25a..a38000f58a17 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -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 { diff --git a/dom/media/VideoSegment.cpp b/dom/media/VideoSegment.cpp index 48fa78eb1058..83555e8b4f25 100644 --- a/dom/media/VideoSegment.cpp +++ b/dom/media/VideoSegment.cpp @@ -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; } diff --git a/dom/media/android/AndroidMediaReader.cpp b/dom/media/android/AndroidMediaReader.cpp index 34d3c5b4a8f1..1b8658e346d1 100644 --- a/dom/media/android/AndroidMediaReader.cpp +++ b/dom/media/android/AndroidMediaReader.cpp @@ -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; } diff --git a/dom/media/gtest/TestVideoTrackEncoder.cpp b/dom/media/gtest/TestVideoTrackEncoder.cpp index ab742e4d990c..b0b79a89f18a 100644 --- a/dom/media/gtest/TestVideoTrackEncoder.cpp +++ b/dom/media/gtest/TestVideoTrackEncoder.cpp @@ -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; } diff --git a/dom/media/omx/OMXCodecWrapper.cpp b/dom/media/omx/OMXCodecWrapper.cpp index b6e3f566bab0..9d696d1b9dd2 100644 --- a/dom/media/omx/OMXCodecWrapper.cpp +++ b/dom/media/omx/OMXCodecWrapper.cpp @@ -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(img)->GetData(); NS_ENSURE_TRUE(yuv->mYChannel, NS_ERROR_INVALID_ARG); diff --git a/dom/media/webrtc/MediaEngineDefault.cpp b/dom/media/webrtc/MediaEngineDefault.cpp index 9a9bd9fd3390..2c631831f1d9 100644 --- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -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 diff --git a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp index f31d06de72ae..4550f29ce846 100644 --- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp @@ -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(); diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index b3c48c8e74d9..ebccc4936611 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -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; } diff --git a/gfx/layers/GrallocImages.cpp b/gfx/layers/GrallocImages.cpp index 8c3f1de1d99b..52633c09b10e 100644 --- a/gfx/layers/GrallocImages.cpp +++ b/gfx/layers/GrallocImages.cpp @@ -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; diff --git a/gfx/layers/GrallocImages.h b/gfx/layers/GrallocImages.h index 5c40e8742be1..c32e71eba591 100644 --- a/gfx/layers/GrallocImages.h +++ b/gfx/layers/GrallocImages.h @@ -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 { diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 8762033309ed..ed1d4621142f 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -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; diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 28882577f934..6e7dcedaa337 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -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. diff --git a/gfx/layers/basic/BasicImages.cpp b/gfx/layers/basic/BasicImages.cpp index 73592f532da5..43f408073e67 100644 --- a/gfx/layers/basic/BasicImages.cpp +++ b/gfx/layers/basic/BasicImages.cpp @@ -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 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; diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp index aa2c3bbe698e..13c7746c0d82 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp @@ -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"); diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.h b/gfx/layers/ipc/SharedPlanarYCbCrImage.h index d15071fc1c4f..ecdca1bd30fb 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.h +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.h @@ -34,8 +34,8 @@ public: virtual uint8_t* GetBuffer() override; virtual already_AddRefed 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; diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp index 4291ebd184ba..7bb03370e43f 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp @@ -529,7 +529,7 @@ public: gfx::IntSize picSize(buffer->GetSize()); nsAutoPtr 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(), diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 43735737d3b9..357b1db72052 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -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; }