Bug 1252198 - use UniquePtr instead of ScopedFreePtr in MediaEngineTabVideoSource; r=gerald

UniquePtr is more standard than ScopedFreePtr; using standard constructs
whenever possible is preferable.  In this case, we're allocating a
simple block of memory, so we can allocate an |unsigned char[]| via
MakeUnique for the same effect.
This commit is contained in:
Nathan Froyd 2016-02-29 10:20:01 -05:00
parent 7daf2ed79a
commit 3f6ef6aa59
2 changed files with 5 additions and 3 deletions

View File

@ -7,6 +7,7 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "nsGlobalWindow.h"
#include "nsIDOMClientRect.h"
#include "nsIDocShell.h"
@ -247,7 +248,7 @@ MediaEngineTabVideoSource::Draw() {
if (mDataSize < static_cast<size_t>(stride * size.height)) {
mDataSize = stride * size.height;
mData = static_cast<unsigned char*>(malloc(mDataSize));
mData = MakeUniqueFallible<unsigned char[]>(mDataSize);
}
if (!mData) {
return;
@ -278,7 +279,7 @@ MediaEngineTabVideoSource::Draw() {
RefPtr<layers::ImageContainer> container = layers::LayerManager::CreateImageContainer();
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(BackendType::CAIRO,
mData.rwget(),
mData.get(),
size,
stride,
SurfaceFormat::B8G8R8X8);

View File

@ -7,6 +7,7 @@
#include "ImageContainer.h"
#include "nsITimer.h"
#include "mozilla/Monitor.h"
#include "mozilla/UniquePtr.h"
#include "nsITabSource.h"
namespace mozilla {
@ -85,7 +86,7 @@ private:
int32_t mViewportWidth;
int32_t mViewportHeight;
int32_t mTimePerFrame;
ScopedFreePtr<unsigned char> mData;
UniquePtr<unsigned char[]> mData;
size_t mDataSize;
nsCOMPtr<nsPIDOMWindowOuter> mWindow;
RefPtr<layers::SourceSurfaceImage> mImage;