Bug 1160485 - remove implicit conversion from RefPtr<T> to TemporaryRef<T>; r=ehsan

Having this implicit conversion means that we can silently do extra
refcounting when it's completely unnecessary.  It's also an obstacle to
making RefPtr more nsRefPtr-like, so let's get rid of it.
This commit is contained in:
Nathan Froyd 2015-05-01 09:14:16 -04:00
parent 6e617deb41
commit f61c010661
77 changed files with 216 additions and 197 deletions

View File

@ -5636,15 +5636,18 @@ CanvasPath::GetPath(const CanvasWindingRule& winding, const DrawTarget* aTarget)
if (mPath &&
(mPath->GetBackendType() == aTarget->GetBackendType()) &&
(mPath->GetFillRule() == fillRule)) {
return mPath;
RefPtr<gfx::Path> path(mPath);
return path.forget();
}
if (!mPath) {
// if there is no path, there must be a pathbuilder
MOZ_ASSERT(mPathBuilder);
mPath = mPathBuilder->Finish();
if (!mPath)
return mPath;
if (!mPath) {
RefPtr<gfx::Path> path(mPath);
return path.forget();
}
mPathBuilder = nullptr;
}
@ -5659,7 +5662,8 @@ CanvasPath::GetPath(const CanvasWindingRule& winding, const DrawTarget* aTarget)
mPath = tmpPathBuilder->Finish();
}
return mPath;
RefPtr<gfx::Path> path(mPath);
return path.forget();
}
void

View File

@ -209,7 +209,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
mDecoderStateMachine,
&MediaDecoderStateMachine::SetDormant,
true);
mDecoderStateMachine->TaskQueue()->Dispatch(event);
mDecoderStateMachine->TaskQueue()->Dispatch(event.forget());
if (IsEnded()) {
mWasEndedWhenEnteredDormant = true;
@ -225,7 +225,7 @@ void MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
mDecoderStateMachine,
&MediaDecoderStateMachine::SetDormant,
false);
mDecoderStateMachine->TaskQueue()->Dispatch(event);
mDecoderStateMachine->TaskQueue()->Dispatch(event.forget());
}
}

View File

@ -277,7 +277,7 @@ MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
// again. We don't just decode straight in a loop here, as that
// would hog the decode task queue.
RefPtr<nsIRunnable> task(new ReRequestVideoWithSkipTask(this, aTimeThreshold));
mTaskQueue->Dispatch(task);
mTaskQueue->Dispatch(task.forget());
return p;
}
}
@ -313,7 +313,7 @@ MediaDecoderReader::RequestAudioData()
// consumed. (|mVideoSinkBufferCount| > 0)
if (AudioQueue().GetSize() == 0 && mTaskQueue) {
RefPtr<nsIRunnable> task(new ReRequestAudioTask(this));
mTaskQueue->Dispatch(task);
mTaskQueue->Dispatch(task.forget());
return p;
}
}

View File

@ -1017,7 +1017,7 @@ MediaFormatReader::Output(TrackType aTrack, MediaData* aSample)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArgs<TrackType, StorensRefPtrPassByPtr<MediaData>>(
this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample);
GetTaskQueue()->Dispatch(task);
GetTaskQueue()->Dispatch(task.forget());
}
void
@ -1026,7 +1026,7 @@ MediaFormatReader::DrainComplete(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyDrainComplete, aTrack);
GetTaskQueue()->Dispatch(task);
GetTaskQueue()->Dispatch(task.forget());
}
void
@ -1035,7 +1035,7 @@ MediaFormatReader::InputExhausted(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyInputExhausted, aTrack);
GetTaskQueue()->Dispatch(task);
GetTaskQueue()->Dispatch(task.forget());
}
void
@ -1044,7 +1044,7 @@ MediaFormatReader::Error(TrackType aTrack)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethodWithArg<TrackType>(
this, &MediaFormatReader::NotifyError, aTrack);
GetTaskQueue()->Dispatch(task);
GetTaskQueue()->Dispatch(task.forget());
}
void
@ -1362,7 +1362,7 @@ MediaFormatReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int6
NS_NewRunnableMethodWithArgs<int32_t, uint64_t>(
this, &MediaFormatReader::NotifyDemuxer,
aLength, aOffset);
GetTaskQueue()->Dispatch(task);
GetTaskQueue()->Dispatch(task.forget());
}
} // namespace mozilla

View File

@ -139,7 +139,7 @@ AudioSinkInputPin::GetConnectedPinSeeking()
return nullptr;
RefPtr<IMediaSeeking> seeking;
peer->QueryInterface(static_cast<IMediaSeeking**>(byRef(seeking)));
return seeking;
return seeking.forget();
}
HRESULT

View File

@ -298,7 +298,7 @@ GetUnconnectedPin(IBaseFilter* aFilter, PIN_DIRECTION aPinDir)
bool matches = FALSE;
if (SUCCEEDED(MatchUnconnectedPin(pin, aPinDir, &matches)) &&
matches) {
return pin;
return pin.forget();
}
}

View File

@ -551,7 +551,7 @@ TrackBuffer::QueueInitializeDecoder(SourceBufferDecoder* aDecoder)
&TrackBuffer::InitializeDecoder,
aDecoder);
// We need to initialize the reader on its own task queue
aDecoder->GetReader()->GetTaskQueue()->Dispatch(task);
aDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget());
return true;
}
@ -1041,7 +1041,7 @@ TrackBuffer::RemoveDecoder(SourceBufferDecoder* aDecoder)
mInitializedDecoders.RemoveElement(aDecoder);
mDecoders.RemoveElement(aDecoder);
}
aDecoder->GetReader()->GetTaskQueue()->Dispatch(task);
aDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget());
}
bool

View File

@ -334,7 +334,7 @@ MediaCodecReader::DispatchAudioTask()
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(this,
&MediaCodecReader::DecodeAudioDataTask);
mAudioTrack.mTaskQueue->Dispatch(task);
mAudioTrack.mTaskQueue->Dispatch(task.forget());
}
}
@ -346,7 +346,7 @@ MediaCodecReader::DispatchVideoTask(int64_t aTimeThreshold)
NS_NewRunnableMethodWithArg<int64_t>(this,
&MediaCodecReader::DecodeVideoFrameTask,
aTimeThreshold);
mVideoTrack.mTaskQueue->Dispatch(task);
mVideoTrack.mTaskQueue->Dispatch(task.forget());
}
}
@ -797,7 +797,7 @@ MediaCodecReader::TextureClientRecycleCallback(TextureClient* aClient)
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(this,
&MediaCodecReader::WaitFenceAndReleaseOutputBuffer);
mVideoTrack.mReleaseBufferTaskQueue->Dispatch(task);
mVideoTrack.mReleaseBufferTaskQueue->Dispatch(task.forget());
}
}
@ -1931,7 +1931,7 @@ MediaCodecReader::VideoCodecCanceled()
if (mVideoTrack.mTaskQueue) {
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(this, &MediaCodecReader::ReleaseCriticalResources);
mVideoTrack.mTaskQueue->Dispatch(task);
mVideoTrack.mTaskQueue->Dispatch(task.forget());
}
}

View File

@ -119,7 +119,7 @@ MediaOmxCommonDecoder::PauseStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::SetDormant,
true);
GetStateMachine()->TaskQueue()->Dispatch(event);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
}
void
@ -148,7 +148,7 @@ MediaOmxCommonDecoder::ResumeStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::Seek,
target);
GetStateMachine()->TaskQueue()->Dispatch(event);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
mNextState = mPlayState;
ChangeState(PLAY_STATE_LOADING);
@ -158,7 +158,7 @@ MediaOmxCommonDecoder::ResumeStateMachine()
GetStateMachine(),
&MediaDecoderStateMachine::SetDormant,
false);
GetStateMachine()->TaskQueue()->Dispatch(event);
GetStateMachine()->TaskQueue()->Dispatch(event.forget());
UpdateLogicalPosition();
}

View File

@ -69,7 +69,7 @@ public:
// with it, so the OutputEvent stores it in an nsAutoPtr and deletes
// it once it's run.
RefPtr<nsIRunnable> r(new OutputEvent(aSample, mCallback, mCreator));
mTaskQueue->Dispatch(r);
mTaskQueue->Dispatch(r.forget());
return NS_OK;
}

View File

@ -74,7 +74,7 @@ MFTDecoder::GetAttributes()
RefPtr<IMFAttributes> attr;
HRESULT hr = mDecoder->GetAttributes(byRef(attr));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
return attr;
return attr.forget();
}
HRESULT

View File

@ -507,7 +507,12 @@ AsyncDecodeWebAudio(const char* aContentType, uint8_t* aBuffer,
WebAudioDecodeJob::UnknownError);
NS_DispatchToMainThread(event);
} else {
task->Reader()->GetTaskQueue()->Dispatch(task);
// If we did this without a temporary:
// task->Reader()->GetTaskQueue()->Dispatch(task.forget())
// we might evaluate the task.forget() before calling Reader(). Enforce
// a non-crashy order-of-operations.
MediaTaskQueue* taskQueue = task->Reader()->GetTaskQueue();
taskQueue->Dispatch(task.forget());
}
}

View File

@ -56,7 +56,7 @@ TemporaryRef<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronously
loader = entry->mLoader;
if (loader) { // existing entry
MOZ_ASSERT(sampleRate == loader->databaseSampleRate());
return loader;
return loader.forget();
}
loader = new HRTFDatabaseLoader(sampleRate);
@ -64,7 +64,7 @@ TemporaryRef<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronously
loader->loadAsynchronously();
return loader;
return loader.forget();
}
HRTFDatabaseLoader::HRTFDatabaseLoader(float sampleRate)

View File

@ -89,7 +89,8 @@ nsSVGPathGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
// looking at the global variable that the pref's stored in.
if (cacheable && mCachedPath) {
if (aDrawTarget.GetBackendType() == mCachedPath->GetBackendType()) {
return mCachedPath;
RefPtr<Path> path(mCachedPath);
return path.forget();
}
}
RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder(aFillRule);

View File

@ -164,7 +164,7 @@ MozMtpDatabase::GetEntry(MtpObjectHandle aHandle)
if (aHandle > 0 && aHandle < mDb.Length()) {
entry = mDb[aHandle];
}
return entry;
return entry.forget();
}
void

View File

@ -75,7 +75,8 @@ TemporaryRef<Volume>
VolumeManager::GetVolume(size_t aIndex)
{
MOZ_ASSERT(aIndex < NumVolumes());
return sVolumeManager->mVolumeArray[aIndex];
RefPtr<Volume> vol = sVolumeManager->mVolumeArray[aIndex];
return vol.forget();
}
//static
@ -135,7 +136,7 @@ VolumeManager::FindVolumeByName(const nsCSubstring& aName)
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
RefPtr<Volume> vol = GetVolume(volIndex);
if (vol->Name().Equals(aName)) {
return vol;
return vol.forget();
}
}
return nullptr;
@ -147,12 +148,12 @@ VolumeManager::FindAddVolumeByName(const nsCSubstring& aName)
{
RefPtr<Volume> vol = FindVolumeByName(aName);
if (vol) {
return vol;
return vol.forget();
}
// No volume found, create and add a new one.
vol = new Volume(aName);
sVolumeManager->mVolumeArray.AppendElement(vol);
return vol;
return vol.forget();
}
//static

View File

@ -21,7 +21,7 @@ DrawTarget::CreateCaptureDT(const IntSize& aSize)
return nullptr;
}
return dt;
return dt.forget();
}
void

View File

@ -197,7 +197,8 @@ DrawTargetCG::Snapshot()
mSnapshot = new SourceSurfaceCGBitmapContext(this);
}
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
TemporaryRef<DrawTarget>

View File

@ -658,7 +658,8 @@ TemporaryRef<SourceSurface>
DrawTargetCairo::Snapshot()
{
if (mSnapshot) {
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
IntSize size = GetSize();
@ -667,7 +668,8 @@ DrawTargetCairo::Snapshot()
size,
GfxFormatForCairoSurface(mSurface),
this);
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
bool

View File

@ -227,7 +227,8 @@ DrawTargetD2D::Snapshot()
Flush();
}
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
void
@ -326,7 +327,7 @@ DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface,
break;
}
return bitmap;
return bitmap.forget();
}
TemporaryRef<ID2D1Image>
@ -337,7 +338,7 @@ DrawTargetD2D::GetImageForSurface(SourceSurface *aSurface)
Rect r(Point(), Size(aSurface->GetSize()));
image = GetBitmapForSurface(aSurface, r);
return image;
return image.forget();
}
void
@ -1868,7 +1869,8 @@ DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
{
if (mCurrentClippedGeometry) {
*aClipBounds = mCurrentClipBounds;
return mCurrentClippedGeometry;
RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
return clippedGeometry.forget();
}
mCurrentClipBounds = IntRect(IntPoint(0, 0), mSize);
@ -1947,7 +1949,8 @@ DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
}
mCurrentClippedGeometry = pathGeom.forget();
*aClipBounds = mCurrentClipBounds;
return mCurrentClippedGeometry;
RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
return clippedGeometry.forget();
}
TemporaryRef<ID2D1RenderTarget>

View File

@ -69,7 +69,8 @@ TemporaryRef<SourceSurface>
DrawTargetD2D1::Snapshot()
{
if (mSnapshot) {
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
PopAllClips();
@ -77,7 +78,8 @@ DrawTargetD2D1::Snapshot()
mSnapshot = new SourceSurfaceD2D1(mBitmap, mDC, mFormat, mSize, this);
return mSnapshot;
RefPtr<SourceSurface> snapshot(mSnapshot);
return snapshot.forget();
}
void
@ -1134,7 +1136,8 @@ DrawTargetD2D1::GetClippedGeometry(IntRect *aClipBounds)
{
if (mCurrentClippedGeometry) {
*aClipBounds = mCurrentClipBounds;
return mCurrentClippedGeometry;
RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
return clippedGeometry.forget();
}
MOZ_ASSERT(mPushedClips.size());
@ -1215,7 +1218,8 @@ DrawTargetD2D1::GetClippedGeometry(IntRect *aClipBounds)
}
mCurrentClippedGeometry = pathGeom.forget();
*aClipBounds = mCurrentClipBounds;
return mCurrentClippedGeometry;
RefPtr<ID2D1Geometry> clippedGeometry(mCurrentClippedGeometry);
return clippedGeometry.forget();
}
TemporaryRef<ID2D1Geometry>
@ -1233,7 +1237,7 @@ DrawTargetD2D1::GetInverseClippedGeometry()
rectGeom->CombineWithGeometry(geom, D2D1_COMBINE_MODE_EXCLUDE, D2D1::IdentityMatrix(), sink);
sink->Close();
return inverseGeom;
return inverseGeom.forget();
}
void
@ -1295,7 +1299,7 @@ DrawTargetD2D1::GetSolidColorBrush(const D2D_COLOR_F& aColor)
{
RefPtr<ID2D1SolidColorBrush> brush = mSolidColorBrush;
brush->SetColor(aColor);
return brush;
return brush.forget();
}
TemporaryRef<ID2D1Brush>

View File

@ -652,7 +652,7 @@ Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceForma
retVal = new DrawTargetRecording(mRecorder, retVal, true);
}
return retVal;
return retVal.forget();
}
gfxWarning() << "Failed to create draw target for D3D11 texture.";

View File

@ -95,7 +95,7 @@ ConvertToB8G8R8A8_SIMD(SourceSurface* aSurface)
output = nullptr;
break;
}
return output;
return output.forget();
}
template<typename u8x16_t>
@ -334,7 +334,7 @@ ApplyBlending_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
}
}
return target;
return target.forget();
}
template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
@ -608,7 +608,7 @@ ApplyColorMatrix_SIMD(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
}
}
return target;
return target.forget();
}
// source / dest: bgra bgra
@ -1074,7 +1074,7 @@ ApplyArithmeticCombine_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInpu
}
}
return target;
return target.forget();
}
} // namespace mozilla

View File

@ -353,7 +353,7 @@ SVGTurbulenceRenderer<Type,Stitch,f32x4_t,i32x4_t,u8x16_t>::Render(const IntSize
}
}
return target;
return target.forget();
}
} // namespace gfx

View File

@ -269,7 +269,7 @@ D3D9SurfaceImage::GetAsSourceSurface()
systemMemorySurface->UnlockRect();
surface->Unmap();
return surface;
return surface.forget();
}
} /* layers */

View File

@ -268,7 +268,7 @@ CreateTexturedEffect(gfx::SurfaceFormat aFormat,
break;
}
return result;
return result.forget();
}
/**

View File

@ -407,7 +407,7 @@ GrallocImage::GetAsSourceSurface()
rv = ConvertOmxYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface, mData);
if (rv == OK) {
surface->Unmap();
return surface;
return surface.forget();
}
rv = ConvertVendorYUVFormatToRGB565(graphicBuffer, surface, &mappedSurface);
@ -417,7 +417,7 @@ GrallocImage::GetAsSourceSurface()
return nullptr;
}
return surface;
return surface.forget();
}
android::sp<android::GraphicBuffer>

View File

@ -95,7 +95,7 @@ InitTextures(IDirect3DDevice9* aDevice,
return nullptr;
}
return result;
return result.forget();
}
static void

View File

@ -51,5 +51,5 @@ MacIOSurfaceImage::GetAsSourceSurface()
dataSurface->Unmap();
mSurface->Unlock();
return dataSurface;
return dataSurface.forget();
}

View File

@ -191,7 +191,7 @@ SourceRotatedBuffer::GetSourceSurface(ContextSource aSource) const
}
MOZ_ASSERT(surf);
return surf;
return surf.forget();
}
/* static */ bool

View File

@ -38,7 +38,7 @@ DIBTextureClient::CreateSimilar(TextureFlags aFlags,
return nullptr;
}
return tex;
return tex.forget();
}
bool

View File

@ -46,7 +46,7 @@ TextureClientX11::CreateSimilar(TextureFlags aFlags,
return nullptr;
}
return tex;
return tex.forget();
}
bool

View File

@ -23,8 +23,7 @@ CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorMacIOSurface) {
const SurfaceDescriptorMacIOSurface& desc =
aDesc.get_SurfaceDescriptorMacIOSurface();
RefPtr<TextureHost> result = new MacIOSurfaceTextureHostBasic(aFlags, desc);
return result;
return MakeAndAddRef<MacIOSurfaceTextureHostBasic>(aFlags, desc);
}
#endif
return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);

View File

@ -120,8 +120,7 @@ TextureInfo ImageClientSingle::GetTextureInfo() const
TemporaryRef<AsyncTransactionTracker>
ImageClientSingle::PrepareFlushAllImages()
{
RefPtr<AsyncTransactionTracker> status = new RemoveTextureFromCompositableTracker();
return status;
return MakeAndAddRef<RemoveTextureFromCompositableTracker>();
}
void

View File

@ -405,7 +405,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
MOZ_ASSERT(!texture || texture->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?");
if (texture && texture->AllocateForSurface(aSize, aAllocFlags)) {
return texture;
return texture.forget();
}
if (aAllocFlags & ALLOC_DISALLOW_BUFFERTEXTURECLIENT) {
@ -423,7 +423,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
return nullptr;
}
return texture;
return texture.forget();
}
// static
@ -443,7 +443,7 @@ TextureClient::CreateForRawBufferAccess(ISurfaceAllocator* aAllocator,
return nullptr;
}
}
return texture;
return texture.forget();
}
// static
@ -469,7 +469,7 @@ TextureClient::CreateForYCbCr(ISurfaceAllocator* aAllocator,
return nullptr;
}
return texture;
return texture.forget();
}
// static
@ -494,7 +494,7 @@ TextureClient::CreateWithBufferSize(ISurfaceAllocator* aAllocator,
return nullptr;
}
return texture;
return texture.forget();
}
TextureClient::TextureClient(ISurfaceAllocator* aAllocator, TextureFlags aFlags)
@ -759,8 +759,7 @@ BufferTextureClient::CreateSimilar(TextureFlags aFlags,
mAllocator, mFormat, mSize, mBackend, mFlags | aFlags, aAllocFlags
);
RefPtr<TextureClient> newTex = newBufferTex.get();
return newTex;
return newBufferTex.forget();
}
bool
@ -947,8 +946,7 @@ SyncObject::CreateSyncObject(SyncHandle aHandle)
}
#ifdef XP_WIN
RefPtr<SyncObject> syncObject = new SyncObjectD3D11(aHandle);
return syncObject;
return MakeAndAddRef<SyncObjectD3D11>(aHandle);
#else
MOZ_ASSERT_UNREACHABLE();
return nullptr;

View File

@ -288,7 +288,7 @@ public:
RefPtr<gfx::SourceSurface> surf = BorrowDrawTarget()->Snapshot();
RefPtr<gfx::DataSourceSurface> data = surf->GetDataSurface();
Unlock();
return data;
return data.forget();
}
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);

View File

@ -96,7 +96,7 @@ TextureClientPool::GetTextureClient()
#endif
TCP_LOG("TexturePool %p giving %p from pool; size %u outstanding %u\n",
this, textureClient.get(), mTextureClients.size(), mOutstandingClients);
return textureClient;
return textureClient.forget();
}
// We're increasing the number of outstanding TextureClients without reusing a
@ -122,7 +122,7 @@ TextureClientPool::GetTextureClient()
#endif
TCP_LOG("TexturePool %p giving new %p; size %u outstanding %u\n",
this, textureClient.get(), mTextureClients.size(), mOutstandingClients);
return textureClient;
return textureClient.forget();
}
void

View File

@ -206,7 +206,7 @@ CompositableHost::Create(const TextureInfo& aTextureInfo)
default:
NS_ERROR("Unknown CompositableType");
}
return result;
return result.forget();
}
void

View File

@ -200,8 +200,7 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
#ifdef MOZ_X11
case SurfaceDescriptor::TSurfaceDescriptorX11: {
const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
RefPtr<TextureHost> result = new X11TextureHost(aFlags, desc);
return result;
return MakeAndAddRef<X11TextureHost>(aFlags, desc);
}
#endif
@ -254,7 +253,7 @@ CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
NS_WARNING("No backend independent TextureHost for this descriptor type");
}
}
return result;
return result.forget();
}
void

View File

@ -465,7 +465,7 @@ CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect,
mContext->ClearRenderTargetView(rt->mRTView, clear);
}
return rt;
return rt.forget();
}
TemporaryRef<CompositingRenderTarget>
@ -524,7 +524,7 @@ CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect,
new CompositingRenderTargetD3D11(texture, aRect.TopLeft());
rt->SetSize(aRect.Size());
return rt;
return rt.forget();
}
void

View File

@ -167,7 +167,7 @@ CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
NS_WARNING("Unsupported SurfaceDescriptor type");
}
}
return result;
return result.forget();
}
TextureClientD3D11::TextureClientD3D11(ISurfaceAllocator* aAllocator,
@ -225,7 +225,7 @@ TextureClientD3D11::Create(ISurfaceAllocator* aAllocator,
aFlags);
texture->mTexture = aTexture;
texture->mSize = aSize;
return texture;
return texture.forget();
}
TemporaryRef<TextureClient>
@ -239,7 +239,7 @@ TextureClientD3D11::CreateSimilar(TextureFlags aFlags,
return nullptr;
}
return tex;
return tex.forget();
}
void
@ -575,7 +575,7 @@ DXGIYCbCrTextureClient::Create(ISurfaceAllocator* aAllocator,
texture->mSize = aSize;
texture->mSizeY = aSizeY;
texture->mSizeCbCr = aSizeCbCr;
return texture;
return texture.forget();
}
bool

View File

@ -125,10 +125,7 @@ CompositorD3D9::CreateRenderTarget(const gfx::IntRect &aRect,
return nullptr;
}
RefPtr<CompositingRenderTargetD3D9> rt =
new CompositingRenderTargetD3D9(texture, aInit, aRect);
return rt;
return MakeAndAddRef<CompositingRenderTargetD3D9>(texture, aInit, aRect);
}
TemporaryRef<CompositingRenderTarget>
@ -192,12 +189,9 @@ CompositorD3D9::CreateRenderTargetFromSource(const gfx::IntRect &aRect,
}
}
RefPtr<CompositingRenderTargetD3D9> rt =
new CompositingRenderTargetD3D9(texture,
return MakeAndAddRef<CompositingRenderTargetD3D9>(texture,
INIT_MODE_NONE,
aRect);
return rt;
}
void

View File

@ -844,7 +844,7 @@ DeviceManagerD3D9::CreateTexture(const IntSize &aSize,
RegisterTextureHost(aTextureHost);
}
return result;
return result.forget();
}
#ifdef DEBUG

View File

@ -198,7 +198,7 @@ TextureSourceD3D9::InitTextures(DeviceManagerD3D9* aDeviceManager,
return nullptr;
}
return result;
return result.forget();
}
/**
@ -246,7 +246,7 @@ TextureSourceD3D9::DataToTexture(DeviceManagerD3D9* aDeviceManager,
FinishTextures(aDeviceManager, texture, surface);
return texture;
return texture.forget();
}
TemporaryRef<IDirect3DTexture9>
@ -270,7 +270,7 @@ TextureSourceD3D9::TextureToTexture(DeviceManagerD3D9* aDeviceManager,
return nullptr;
}
return texture;
return texture.forget();
}
TemporaryRef<IDirect3DTexture9>
@ -311,7 +311,7 @@ TextureSourceD3D9::SurfaceToTexture(DeviceManagerD3D9* aDeviceManager,
FinishTextures(aDeviceManager, texture, surface);
return texture;
return texture.forget();
}
DataTextureSourceD3D9::DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
@ -585,7 +585,7 @@ CairoTextureClientD3D9::CreateSimilar(TextureFlags aFlags, TextureAllocationFlag
return nullptr;
}
return tex;
return tex.forget();
}
bool
@ -782,7 +782,7 @@ SharedTextureClientD3D9::Create(ISurfaceAllocator* aAllocator,
if (texture->mTexture) {
gfxWindowsPlatform::sD3D9SharedTextureUsed += texture->mDesc.Width * texture->mDesc.Height * 4;
}
return texture;
return texture.forget();
}
bool

View File

@ -241,8 +241,7 @@ public:
}
TemporaryRef<Effect> CreateEffect(size_t i) {
RefPtr<TexturedEffect> effect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT, true);
return effect;
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT, true);
}
};
@ -285,8 +284,7 @@ public:
}
virtual TemporaryRef<Effect> CreateEffect(size_t i) {
RefPtr<TexturedEffect> effect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT, true);
return effect;
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT, true);
}
};
@ -328,8 +326,7 @@ public:
}
virtual TemporaryRef<Effect> CreateEffect(size_t i) {
RefPtr<TexturedEffect> effect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT);
return effect;
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT);
}
};
@ -370,8 +367,7 @@ public:
}
virtual TemporaryRef<Effect> CreateEffect(size_t i) {
RefPtr<TexturedEffect> effect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT);
return effect;
return CreateTexturedEffect(SurfaceFormat::B8G8R8A8, mTexture, Filter::POINT);
}
};
#endif

View File

@ -1424,9 +1424,7 @@ CompositorOGL::Resume()
TemporaryRef<DataTextureSource>
CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
{
RefPtr<DataTextureSource> result =
new TextureImageTextureSourceOGL(this, aFlags);
return result;
return MakeAndAddRef<TextureImageTextureSourceOGL>(this, aFlags);
}
bool

View File

@ -60,7 +60,7 @@ GrallocTextureClientOGL::CreateSimilar(TextureFlags aFlags,
return nullptr;
}
return tex;
return tex.forget();
}
bool

View File

@ -33,7 +33,7 @@ MacIOSurfaceTextureClientOGL::Create(ISurfaceAllocator* aAllocator,
MOZ_ASSERT(texture->IsValid());
MOZ_ASSERT(!texture->IsAllocated());
texture->mSurface = aSurface;
return texture;
return texture.forget();
}
bool

View File

@ -103,7 +103,7 @@ namespace FilterWrappers {
{
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::UNPREMULTIPLY);
filter->SetInput(IN_UNPREMULTIPLY_IN, aInput);
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -111,7 +111,7 @@ namespace FilterWrappers {
{
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::PREMULTIPLY);
filter->SetInput(IN_PREMULTIPLY_IN, aInput);
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -126,7 +126,7 @@ namespace FilterWrappers {
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_TABLE_B, glinearRGBTosRGBMap, 256);
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_DISABLE_A, true);
transfer->SetInput(IN_DISCRETE_TRANSFER_IN, aInput);
return transfer;
return transfer.forget();
}
static TemporaryRef<FilterNode>
@ -141,7 +141,7 @@ namespace FilterWrappers {
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_TABLE_B, gsRGBToLinearRGBMap, 256);
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_DISABLE_A, true);
transfer->SetInput(IN_DISCRETE_TRANSFER_IN, aInput);
return transfer;
return transfer.forget();
}
static TemporaryRef<FilterNode>
@ -150,7 +150,7 @@ namespace FilterWrappers {
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::CROP);
filter->SetAttribute(ATT_CROP_RECT, Rect(aRect));
filter->SetInput(IN_CROP_IN, aInputFilter);
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -159,7 +159,7 @@ namespace FilterWrappers {
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::TRANSFORM);
filter->SetAttribute(ATT_TRANSFORM_MATRIX, Matrix::Translation(aOffset.x, aOffset.y));
filter->SetInput(IN_TRANSFORM_IN, aInputFilter);
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -171,7 +171,7 @@ namespace FilterWrappers {
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::GAUSSIAN_BLUR);
filter->SetAttribute(ATT_GAUSSIAN_BLUR_STD_DEVIATION, stdX);
filter->SetInput(IN_GAUSSIAN_BLUR_IN, aInputFilter);
return filter;
return filter.forget();
}
RefPtr<FilterNode> filterH = aDT->CreateFilter(FilterType::DIRECTIONAL_BLUR);
RefPtr<FilterNode> filterV = aDT->CreateFilter(FilterType::DIRECTIONAL_BLUR);
@ -181,7 +181,7 @@ namespace FilterWrappers {
filterV->SetAttribute(ATT_DIRECTIONAL_BLUR_STD_DEVIATION, stdY);
filterH->SetInput(IN_DIRECTIONAL_BLUR_IN, aInputFilter);
filterV->SetInput(IN_DIRECTIONAL_BLUR_IN, filterH);
return filterV;
return filterV.forget();
}
static TemporaryRef<FilterNode>
@ -189,7 +189,7 @@ namespace FilterWrappers {
{
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::FLOOD);
filter->SetAttribute(ATT_FLOOD_COLOR, Color(0,0,0,0));
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -200,7 +200,7 @@ namespace FilterWrappers {
filter->SetAttribute(ATT_TRANSFORM_MATRIX,
Matrix::Translation(aSurfacePosition.x, aSurfacePosition.y));
filter->SetInput(IN_TRANSFORM_IN, aSurface);
return filter;
return filter.forget();
}
static TemporaryRef<FilterNode>
@ -216,7 +216,7 @@ namespace FilterWrappers {
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_TABLE_B, &zero, 1);
transfer->SetAttribute(ATT_DISCRETE_TRANSFER_DISABLE_A, true);
transfer->SetInput(IN_DISCRETE_TRANSFER_IN, aInput);
return transfer;
return transfer.forget();
}
}
@ -280,7 +280,8 @@ FilterCachedColorModels::ForColorModel(ColorModel aColorModel)
if (!mFilterForColorModel[aColorModel.ToIndex()]) {
mFilterForColorModel[aColorModel.ToIndex()] = WrapForColorModel(aColorModel);
}
return mFilterForColorModel[aColorModel.ToIndex()];
RefPtr<FilterNode> filter(mFilterForColorModel[aColorModel.ToIndex()]);
return filter.forget();
}
TemporaryRef<FilterNode>
@ -698,7 +699,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetInput(IN_BLEND_IN, aSources[0]);
filter->SetInput(IN_BLEND_IN2, aSources[1]);
}
return filter;
return filter.forget();
}
case PrimitiveType::ColorMatrix:
@ -707,7 +708,8 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
uint32_t type = atts.GetUint(eColorMatrixType);
const nsTArray<float>& values = atts.GetFloats(eColorMatrixValues);
if (NS_FAILED(ComputeColorMatrix(type, values, colorMatrix))) {
return aSources[0];
RefPtr<FilterNode> filter(aSources[0]);
return filter.forget();
}
Matrix5x4 matrix(colorMatrix[0], colorMatrix[5], colorMatrix[10], colorMatrix[15],
colorMatrix[1], colorMatrix[6], colorMatrix[11], colorMatrix[16],
@ -718,7 +720,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetAttribute(ATT_COLOR_MATRIX_MATRIX, matrix);
filter->SetAttribute(ATT_COLOR_MATRIX_ALPHA_MODE, (uint32_t)ALPHA_MODE_STRAIGHT);
filter->SetInput(IN_COLOR_MATRIX_IN, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::Morphology:
@ -745,7 +747,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetAttribute(ATT_MORPHOLOGY_RADII, IntSize(rx, ry));
filter->SetAttribute(ATT_MORPHOLOGY_OPERATOR, (uint32_t)op);
filter->SetInput(IN_MORPHOLOGY_IN, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::Flood:
@ -753,7 +755,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
Color color = atts.GetColor(eFloodColor);
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::FLOOD);
filter->SetAttribute(ATT_FLOOD_COLOR, color);
return filter;
return filter.forget();
}
case PrimitiveType::Tile:
@ -761,7 +763,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::TILE);
filter->SetAttribute(ATT_TILE_SOURCE_RECT, aSourceRegions[0]);
filter->SetInput(IN_TILE_IN, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::ComponentTransfer:
@ -789,7 +791,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
}
}
return lastFilter;
return lastFilter.forget();
}
case PrimitiveType::ConvolveMatrix:
@ -820,7 +822,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetAttribute(ATT_CONVOLVE_MATRIX_PRESERVE_ALPHA,
atts.GetBool(eConvolveMatrixPreserveAlpha));
filter->SetInput(IN_CONVOLVE_MATRIX_IN, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::Offset:
@ -847,7 +849,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
(uint32_t)channel[atts.GetUint(eDisplacementMapYChannel)]);
filter->SetInput(IN_DISPLACEMENT_MAP_IN, aSources[0]);
filter->SetInput(IN_DISPLACEMENT_MAP_IN2, aSources[1]);
return filter;
return filter.forget();
}
case PrimitiveType::Turbulence:
@ -898,7 +900,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetInput(IN_COMPOSITE_IN_START, aSources[1]);
filter->SetInput(IN_COMPOSITE_IN_START + 1, aSources[0]);
}
return filter;
return filter.forget();
}
case PrimitiveType::Merge:
@ -907,14 +909,15 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
return nullptr;
}
if (aSources.Length() == 1) {
return aSources[0];
RefPtr<FilterNode> filter(aSources[0]);
return filter.forget();
}
RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::COMPOSITE);
filter->SetAttribute(ATT_COMPOSITE_OPERATOR, (uint32_t)COMPOSITE_OPERATOR_OVER);
for (size_t i = 0; i < aSources.Length(); i++) {
filter->SetInput(IN_COMPOSITE_IN_START + i, aSources[i]);
}
return filter;
return filter.forget();
}
case PrimitiveType::GaussianBlur:
@ -949,7 +952,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetAttribute(ATT_COMPOSITE_OPERATOR, (uint32_t)COMPOSITE_OPERATOR_OVER);
filter->SetInput(IN_COMPOSITE_IN_START, composite);
filter->SetInput(IN_COMPOSITE_IN_START + 1, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::DiffuseLighting:
@ -1021,7 +1024,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
filter->SetInput(IN_LIGHTING_IN, aSources[0]);
return filter;
return filter.forget();
}
case PrimitiveType::Image:
@ -1040,7 +1043,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
transform->SetInput(IN_TRANSFORM_IN, inputImage);
transform->SetAttribute(ATT_TRANSFORM_MATRIX, TM);
transform->SetAttribute(ATT_TRANSFORM_FILTER, atts.GetUint(eImageFilter));
return transform;
return transform.forget();
}
case PrimitiveType::ToAlpha:

View File

@ -125,7 +125,7 @@ static TemporaryRef<Compositor> CreateTestCompositor(LayersBackend backend, Mock
abort();
}
return compositor;
return compositor.forget();
}
/**
@ -172,10 +172,8 @@ static std::vector<LayersBackend> GetPlatformBackends()
static TemporaryRef<DrawTarget> CreateDT()
{
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
IntSize(gCompWidth, gCompHeight), SurfaceFormat::B8G8R8A8);
return dt;
}
static bool CompositeAndCompare(nsRefPtr<LayerManagerComposite> layerManager, DrawTarget* refDT)

View File

@ -204,7 +204,8 @@ gfxContext::ClosePath()
TemporaryRef<Path> gfxContext::GetPath()
{
EnsurePath();
return mPath;
RefPtr<Path> path(mPath);
return path.forget();
}
void gfxContext::SetPath(Path* path)
@ -949,7 +950,7 @@ gfxContext::PopGroupToSurface(Matrix* aTransform)
deviceOffsetTranslation.PreTranslate(deviceOffset.x, deviceOffset.y);
*aTransform = deviceOffsetTranslation * mat;
return src;
return src.forget();
}
void

View File

@ -674,7 +674,8 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
{
bool wantCairo = aTarget->GetBackendType() == BackendType::CAIRO;
if (mAzureScaledFont && mAzureScaledFontIsCairo == wantCairo) {
return mAzureScaledFont;
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
return scaledFont.forget();
}
NativeFont nativeFont;
@ -692,5 +693,6 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
mAzureScaledFontIsCairo = wantCairo;
return mAzureScaledFont;
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
return scaledFont.forget();
}

View File

@ -437,7 +437,8 @@ gfxMacFont::GetScaledFont(DrawTarget *aTarget)
mAzureScaledFont = mozilla::gfx::Factory::CreateScaledFontWithCairo(nativeFont, GetAdjustedSize(), mScaledFont);
}
return mAzureScaledFont;
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
return scaledFont.forget();
}
TemporaryRef<mozilla::gfx::GlyphRenderingOptions>

View File

@ -858,7 +858,8 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa
SourceSurfaceUserData *surf = static_cast<SourceSurfaceUserData*>(userData);
if (surf->mSrcSurface->IsValid() && surf->mBackendType == aTarget->GetBackendType()) {
return surf->mSrcSurface;
RefPtr<SourceSurface> srcSurface(surf->mSrcSurface);
return srcSurface.forget();
}
// We can just continue here as when setting new user data the destroy
// function will be called for the old user data.
@ -1025,10 +1026,8 @@ gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
NativeFont nativeFont;
nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
nativeFont.mFont = aFont->GetCairoScaledFont();
RefPtr<ScaledFont> scaledFont =
Factory::CreateScaledFontForNativeFont(nativeFont,
return Factory::CreateScaledFontForNativeFont(nativeFont,
aFont->GetAdjustedSize());
return scaledFont;
}
int

View File

@ -341,7 +341,7 @@ gfxUtils::CreatePremultipliedDataSurface(DataSourceSurface* srcSurf)
srcSurf->GetSize().height);
UnmapSrcDest(srcSurf, destSurf);
return destSurf;
return destSurf.forget();
}
TemporaryRef<DataSourceSurface>
@ -362,7 +362,7 @@ gfxUtils::CreateUnpremultipliedDataSurface(DataSourceSurface* srcSurf)
srcSurf->GetSize().height);
UnmapSrcDest(srcSurf, destSurf);
return destSurf;
return destSurf.forget();
}
void
@ -719,8 +719,7 @@ PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
pb->LineTo(Point(r->x, r->YMost()));
pb->Close();
}
RefPtr<Path> path = pb->Finish();
return path;
return pb->Finish();
}
static void

View File

@ -2092,7 +2092,7 @@ gfxWindowsPlatform::CreateD3D11DecoderDevice()
multi->SetMultithreadProtected(TRUE);
return device;
return device.forget();
}
static bool

View File

@ -61,7 +61,8 @@ public:
}
TemporaryRef<SourceSurface> Surface() {
return mSurface;
RefPtr<SourceSurface> surf(mSurface);
return surf.forget();
}
private:

View File

@ -719,7 +719,7 @@ RasterImage::CopyFrame(uint32_t aWhichFrame, uint32_t aFlags)
target->Flush();
surf->Unmap();
return surf;
return surf.forget();
}
//******************************************************************************

View File

@ -66,7 +66,7 @@ CreateLockedSurface(VolatileBuffer* vbuf,
}
surf->AddUserData(&kVolatileBuffer, vbufptr, VolatileBufferRelease);
return surf;
return surf.forget();
}
static TemporaryRef<VolatileBuffer>
@ -76,7 +76,7 @@ AllocateBufferForImage(const IntSize& size, SurfaceFormat format)
RefPtr<VolatileBuffer> buf = new VolatileBuffer();
if (buf->Init(stride * size.height,
1 << gfxAlphaRecovery::GoodAlignmentLog2())) {
return buf;
return buf.forget();
}
return nullptr;
@ -1055,14 +1055,16 @@ imgFrame::GetSurfaceInternal()
if (mOptSurface) {
if (mOptSurface->IsValid()) {
return mOptSurface;
RefPtr<SourceSurface> surf(mOptSurface);
return surf.forget();
} else {
mOptSurface = nullptr;
}
}
if (mImageSurface) {
return mImageSurface;
RefPtr<SourceSurface> surf(mImageSurface);
return surf.forget();
}
if (!mVBuf) {

View File

@ -1092,7 +1092,7 @@ nsCSSBorderRenderer::CreateCornerGradient(mozilla::css::Corner aCorner,
aPoint2 = tmp;
gs = gfxGradientCache::GetOrCreateGradientStops(aDT, rawStops, ExtendMode::CLAMP);
}
return gs;
return gs.forget();
}
typedef struct { Float a, b; } twoFloats;

View File

@ -332,7 +332,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
}
*aMaskTransform = ToMatrix(maskSurfaceMatrix);
return destMaskSurface;
return destMaskSurface.forget();
}
nsresult

View File

@ -285,8 +285,6 @@ public:
operator T*() const { return mPtr; }
T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mPtr; }
T& operator*() const { return *mPtr; }
template<typename U>
operator TemporaryRef<U>() { return TemporaryRef<U>(mPtr); }
private:
void assign(T* aVal)

View File

@ -36,7 +36,8 @@ struct Bar : public Foo {};
TemporaryRef<Foo>
NewFoo()
{
return RefPtr<Foo>(new Foo());
RefPtr<Foo> f(new Foo());
return f.forget();
}
TemporaryRef<Foo>

View File

@ -170,7 +170,7 @@ LoadedElf::Create(const char *path, void *base_addr)
static_cast<void *>(elf));
ElfLoader::Singleton.Register(elf);
return elf;
return elf.forget();
}
bool

View File

@ -263,7 +263,7 @@ CustomElf::Load(Mappable *mappable, const char *path, int flags)
}
DEBUG_LOG("CustomElf::Load(\"%s\", 0x%x) = %p", path, flags,
static_cast<void *>(elf));
return elf;
return elf.forget();
}
CustomElf::~CustomElf()

View File

@ -346,7 +346,7 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent)
/* Handle dlopen(nullptr) directly. */
if (!path) {
handle = SystemElf::Load(nullptr, flags);
return handle;
return handle.forget();
}
/* TODO: Handle relative paths correctly */

View File

@ -54,7 +54,7 @@ Zip::Create(const char *filename, void *mapped, size_t size)
}
ZipCollection::Singleton.Register(zip);
return zip;
return zip.forget();
}
Zip::Zip(const char *filename, void *mapped, size_t size)

View File

@ -1562,7 +1562,8 @@ nsNSSComponent::GetDefaultCertVerifier()
{
MutexAutoLock lock(mutex);
MOZ_ASSERT(mNSSInitialized);
return mDefaultCertVerifier;
RefPtr<SharedCertVerifier> certVerifier(mDefaultCertVerifier);
return certVerifier.forget();
}
namespace mozilla { namespace psm {

View File

@ -2601,7 +2601,7 @@ nsChildView::StartRemoteDrawing()
return nullptr;
}
return drawTarget;
return drawTarget.forget();
}
void
@ -2718,7 +2718,7 @@ RectTextureImage::BeginUpdate(const nsIntSize& aNewSize,
mInUpdate = true;
RefPtr<gfx::DrawTarget> drawTarget = mUpdateDrawTarget;
return drawTarget;
return drawTarget.forget();
}
#define NSFoundationVersionWithProperStrideSupportForSubtextureUpload NSFoundationVersionNumber10_6_3

View File

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2013 Mozilla Foundation
@ -136,7 +137,8 @@ GonkBufferQueue::getTextureClientFromBuffer(ANativeWindowBuffer* buffer)
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
if (mSlots[i].mGraphicBuffer != NULL && mSlots[i].mGraphicBuffer->handle == buffer->handle) {
return mSlots[i].mTextureClient;
RefPtr<TextureClient> client(mSlots[i].mTextureClient);
return client.forget();
}
}
ST_LOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle);

View File

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2013 Mozilla Foundation
@ -128,7 +129,8 @@ GonkBufferQueue::getTextureClientFromBuffer(ANativeWindowBuffer* buffer)
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
if (mSlots[i].mGraphicBuffer != NULL && mSlots[i].mGraphicBuffer->handle == buffer->handle) {
return mSlots[i].mTextureClient;
RefPtr<TextureClient> client(mSlots[i].mTextureClient);
return client.forget();
}
}
ALOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle);

View File

@ -531,7 +531,8 @@ GonkBufferQueueConsumer::getTextureClientFromBuffer(ANativeWindowBuffer* buffer)
for (int i = 0; i < GonkBufferQueueDefs::NUM_BUFFER_SLOTS; i++) {
if (mSlots[i].mGraphicBuffer != NULL && mSlots[i].mGraphicBuffer->handle == buffer->handle) {
return mSlots[i].mTextureClient;
RefPtr<TextureClient> client(mSlots[i].mTextureClient);
return client.forget();
}
}
ALOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle);

View File

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012-2013 Mozilla Foundation
@ -409,7 +410,8 @@ GonkNativeWindow::getTextureClientFromBuffer(ANativeWindowBuffer* buffer)
return nullptr;
}
return mSlots[buf].mTextureClient;
RefPtr<TextureClient> client(mSlots[buf].mTextureClient);
return client.forget();
}
status_t GonkNativeWindow::queueBuffer(int buf, int64_t timestamp,
@ -487,7 +489,8 @@ GonkNativeWindow::getCurrentBuffer() {
mDequeueCondition.signal();
mSlots[buf].mTextureClient->SetRecycleCallback(GonkNativeWindow::RecycleCallback, this);
return mSlots[buf].mTextureClient;
RefPtr<TextureClient> client(mSlots[buf].mTextureClient);
return client.forget();
}

View File

@ -126,7 +126,7 @@ GonkNativeWindow::getCurrentBuffer() {
return NULL;
}
textureClient->SetRecycleCallback(GonkNativeWindow::RecycleCallback, this);
return textureClient;
return textureClient.forget();
}
/* static */ void

View File

@ -126,7 +126,7 @@ GonkNativeWindow::getCurrentBuffer() {
return NULL;
}
textureClient->SetRecycleCallback(GonkNativeWindow::RecycleCallback, this);
return textureClient;
return textureClient.forget();
}
/* static */ void

View File

@ -137,7 +137,7 @@ GonkNativeWindow::getCurrentBuffer() {
return NULL;
}
textureClient->SetRecycleCallback(GonkNativeWindow::RecycleCallback, this);
return textureClient;
return textureClient.forget();
}
/* static */ void

View File

@ -728,7 +728,8 @@ nsWindow::StartRemoteDrawing()
mBackBuffer = mFramebufferTarget->CreateSimilarDrawTarget(
mFramebufferTarget->GetSize(), mFramebufferTarget->GetFormat());
}
return mBackBuffer;
RefPtr<DrawTarget> buffer(mBackBuffer);
return buffer.forget();
}
void