Bug 1024983 - Stop addrefing and releasing excessively in the Moz2D code in functions that return a TemporaryRef. r=mstange

This commit is contained in:
Jonathan Watt 2014-06-13 17:09:23 +01:00
parent 87cff0b293
commit 344fb8cd20
25 changed files with 136 additions and 172 deletions

View File

@ -12,13 +12,7 @@ namespace gfx {
TemporaryRef<DataSourceSurface>
DataSourceSurface::GetDataSurface()
{
RefPtr<DataSourceSurface> temp;
if (GetType() == SurfaceType::DATA) {
temp = this;
} else {
temp = new DataSourceSurfaceWrapper(this);
}
return temp;
return (GetType() == SurfaceType::DATA) ? this : new DataSourceSurfaceWrapper(this);
}
}

View File

@ -170,9 +170,8 @@ DrawTargetCG::Snapshot()
if (!mSnapshot) {
if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
return new SourceSurfaceCGIOSurfaceContext(this);
} else {
mSnapshot = new SourceSurfaceCGBitmapContext(this);
}
mSnapshot = new SourceSurfaceCGBitmapContext(this);
}
return mSnapshot;
@ -185,10 +184,9 @@ DrawTargetCG::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aForma
// to add that in somehow, but at a higher level
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
if (newTarget->Init(GetType(), aSize, aFormat)) {
return newTarget;
} else {
return nullptr;
return newTarget.forget();
}
return nullptr;
}
TemporaryRef<SourceSurface>
@ -199,11 +197,11 @@ DrawTargetCG::CreateSourceSurfaceFromData(unsigned char *aData,
{
RefPtr<SourceSurfaceCG> newSurf = new SourceSurfaceCG();
if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
return nullptr;
}
return newSurf;
return newSurf.forget();
}
// This function returns a retained CGImage that needs to be released after
@ -1447,8 +1445,7 @@ DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aForm
TemporaryRef<PathBuilder>
DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const
{
RefPtr<PathBuilderCG> pb = new PathBuilderCG(aFillRule);
return pb;
return new PathBuilderCG(aFillRule);
}
void*

View File

@ -976,9 +976,7 @@ DrawTargetCairo::PopClip()
TemporaryRef<PathBuilder>
DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FillRule::FILL_WINDING */) const
{
RefPtr<PathBuilderCairo> builder = new PathBuilderCairo(aFillRule);
return builder;
return new PathBuilderCairo(aFillRule);
}
void
@ -998,9 +996,7 @@ TemporaryRef<GradientStops>
DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
ExtendMode aExtendMode) const
{
RefPtr<GradientStopsCairo> stops = new GradientStopsCairo(aStops, aNumStops,
aExtendMode);
return stops;
return new GradientStopsCairo(aStops, aNumStops, aExtendMode);
}
TemporaryRef<FilterNode>
@ -1059,7 +1055,7 @@ DrawTargetCairo::CreateSourceSurfaceFromData(unsigned char *aData,
RefPtr<SourceSurfaceCairo> source_surf = new SourceSurfaceCairo(surf, aSize, aFormat);
cairo_surface_destroy(surf);
return source_surf;
return source_surf.forget();
}
#ifdef CAIRO_HAS_XLIB_SURFACE
@ -1156,10 +1152,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
IntPoint(0, 0));
dt->Flush();
RefPtr<SourceSurface> surf =
new SourceSurfaceCairo(csurf, size, format);
return surf;
return new SourceSurfaceCairo(csurf, size, format);
#endif
return aSurface;
@ -1175,9 +1168,7 @@ DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurf
return nullptr;
}
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
RefPtr<SourceSurfaceCairo> source =
new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat);
return source;
return new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat);
}
return nullptr;
@ -1193,7 +1184,7 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo
if (!cairo_surface_status(similar)) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
target->InitAlreadyReferenced(similar, aSize);
return target;
return target.forget();
}
return nullptr;
@ -1234,7 +1225,7 @@ DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFor
if (aSigma == 0.0F) {
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
target->InitAlreadyReferenced(similar, aSize);
return target;
return target.forget();
}
cairo_surface_t* blursurf = cairo_image_surface_create(CAIRO_FORMAT_A8,
@ -1257,7 +1248,7 @@ DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFor
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
target->InitAlreadyReferenced(tee, aSize);
return target;
return target.forget();
}
bool

View File

@ -1198,7 +1198,7 @@ DrawTargetD2D::CreateSourceSurfaceFromData(unsigned char *aData,
return nullptr;
}
return newSurf;
return newSurf.forget();
}
TemporaryRef<SourceSurface>
@ -1222,9 +1222,9 @@ DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
data->Unmap();
if (!success) {
return data;
return data.forget();
}
return newSurf;
return newSurf.forget();
}
TemporaryRef<SourceSurface>
@ -1244,7 +1244,7 @@ DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurfac
return nullptr;
}
return newSurf;
return newSurf.forget();
}
TemporaryRef<DrawTarget>
@ -1258,7 +1258,7 @@ DrawTargetD2D::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aForm
return nullptr;
}
return newTarget;
return newTarget.forget();
}
TemporaryRef<PathBuilder>
@ -1498,7 +1498,7 @@ DrawTargetD2D::GetCachedLayer()
}
mCurrentCachedLayer++;
return layer;
return layer.forget();
}
void
@ -1982,7 +1982,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm
return nullptr;
}
return rt;
return rt.forget();
}
void
@ -2282,7 +2282,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
if (!IsPatternSupportedByD2D(aPattern)) {
RefPtr<ID2D1SolidColorBrush> colBrush;
mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
return colBrush;
return colBrush.forget();
}
if (aPattern.GetType() == PatternType::COLOR) {
@ -2292,8 +2292,9 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
color.b, color.a),
D2D1::BrushProperties(aAlpha),
byRef(colBrush));
return colBrush;
} else if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
return colBrush.forget();
}
if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
RefPtr<ID2D1LinearGradientBrush> gradBrush;
const LinearGradientPattern *pat =
static_cast<const LinearGradientPattern*>(&aPattern);
@ -2313,7 +2314,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
mRT->CreateSolidColorBrush(d2dStops.back().color,
D2D1::BrushProperties(aAlpha),
byRef(colBrush));
return colBrush;
return colBrush.forget();
}
mRT->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties(D2DPoint(pat->mBegin),
@ -2321,8 +2322,9 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
stops->mStopCollection,
byRef(gradBrush));
return gradBrush;
} else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
return gradBrush.forget();
}
if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
RefPtr<ID2D1RadialGradientBrush> gradBrush;
const RadialGradientPattern *pat =
static_cast<const RadialGradientPattern*>(&aPattern);
@ -2343,8 +2345,9 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
stops->mStopCollection,
byRef(gradBrush));
return gradBrush;
} else if (aPattern.GetType() == PatternType::SURFACE) {
return gradBrush.forget();
}
if (aPattern.GetType() == PatternType::SURFACE) {
RefPtr<ID2D1BitmapBrush> bmBrush;
const SurfacePattern *pat =
static_cast<const SurfacePattern*>(&aPattern);
@ -2401,7 +2404,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
byRef(bmBrush));
return bmBrush;
return bmBrush.forget();
}
gfxWarning() << "Invalid pattern type detected.";
@ -2477,7 +2480,7 @@ DrawTargetD2D::CreateGradientTexture(const GradientStopsD2D *aStops)
RefPtr<ID3D10Texture2D> tex;
mDevice->CreateTexture2D(&desc, &data, byRef(tex));
return tex;
return tex.forget();
}
TemporaryRef<ID3D10Texture2D>
@ -2542,7 +2545,7 @@ DrawTargetD2D::CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, cons
return nullptr;
}
return tex;
return tex.forget();
}
void

View File

@ -533,7 +533,7 @@ DrawTargetD2D1::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
return nullptr;
}
return dt;
return dt.forget();
}
TemporaryRef<PathBuilder>
@ -797,7 +797,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
if (!IsPatternSupportedByD2D(aPattern)) {
RefPtr<ID2D1SolidColorBrush> colBrush;
mDC->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
return colBrush;
return colBrush.forget();
}
if (aPattern.GetType() == PatternType::COLOR) {
@ -807,8 +807,9 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
color.b, color.a),
D2D1::BrushProperties(aAlpha),
byRef(colBrush));
return colBrush;
} else if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
return colBrush.forget();
}
if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
RefPtr<ID2D1LinearGradientBrush> gradBrush;
const LinearGradientPattern *pat =
static_cast<const LinearGradientPattern*>(&aPattern);
@ -828,7 +829,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
mDC->CreateSolidColorBrush(d2dStops.back().color,
D2D1::BrushProperties(aAlpha),
byRef(colBrush));
return colBrush;
return colBrush.forget();
}
mDC->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties(D2DPoint(pat->mBegin),
@ -836,8 +837,9 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
stops->mStopCollection,
byRef(gradBrush));
return gradBrush;
} else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
return gradBrush.forget();
}
if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
RefPtr<ID2D1RadialGradientBrush> gradBrush;
const RadialGradientPattern *pat =
static_cast<const RadialGradientPattern*>(&aPattern);
@ -855,11 +857,12 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2DPoint(pat->mCenter1 - pat->mCenter2),
pat->mRadius2, pat->mRadius2),
D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
stops->mStopCollection,
byRef(gradBrush));
stops->mStopCollection,
byRef(gradBrush));
return gradBrush;
} else if (aPattern.GetType() == PatternType::SURFACE) {
return gradBrush.forget();
}
if (aPattern.GetType() == PatternType::SURFACE) {
const SurfacePattern *pat =
static_cast<const SurfacePattern*>(&aPattern);
@ -881,7 +884,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
D2DInterpolationMode(pat->mFilter)),
D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
byRef(imageBrush));
return imageBrush;
return imageBrush.forget();
}
gfxWarning() << "Invalid pattern type detected.";
@ -909,16 +912,13 @@ DrawTargetD2D1::GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTrans
gfxWarning() << "Invalid surface type.";
return nullptr;
}
image = CreatePartialBitmapForSurface(dataSurf, mTransform, mSize, aExtendMode,
aSourceTransform, mDC);
return image;
return CreatePartialBitmapForSurface(dataSurf, mTransform, mSize, aExtendMode,
aSourceTransform, mDC);
}
break;
}
return image;
return image.forget();
}
TemporaryRef<SourceSurface>
@ -943,7 +943,7 @@ DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const
data->Unmap();
if (!bitmap) {
return data;
return data.forget();
}
return new SourceSurfaceD2D1(bitmap.get(), mDC, data->GetFormat(), data->GetSize());

View File

@ -371,7 +371,7 @@ DrawTargetRecording::Snapshot()
mRecorder->RecordEvent(RecordedSnapshot(retSurf, this));
return retSurf;
return retSurf.forget();
}
void
@ -416,7 +416,7 @@ DrawTargetRecording::CreateFilter(FilterType aType)
mRecorder->RecordEvent(RecordedFilterNodeCreation(retNode, aType));
return retNode;
return retNode.forget();
}
void
@ -470,7 +470,7 @@ DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char *aData,
mRecorder->RecordEvent(RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat));
return retSurf;
return retSurf.forget();
}
TemporaryRef<SourceSurface>
@ -503,7 +503,7 @@ DrawTargetRecording::OptimizeSourceSurface(SourceSurface *aSurface) const
dataSurf->GetSize(), dataSurf->GetFormat()));
}
return retSurf;
return retSurf.forget();
}
TemporaryRef<SourceSurface>
@ -531,17 +531,14 @@ DrawTargetRecording::CreateSourceSurfaceFromNativeSurface(const NativeSurface &a
dataSurf->GetSize(), dataSurf->GetFormat()));
}
return retSurf;
return retSurf.forget();
}
TemporaryRef<DrawTarget>
DrawTargetRecording::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{
RefPtr<DrawTarget> dt = mFinalDT->CreateSimilarDrawTarget(aSize, aFormat);
RefPtr<DrawTarget> retDT = new DrawTargetRecording(mRecorder.get(), dt);
return retDT;
return new DrawTargetRecording(mRecorder.get(), dt);
}
TemporaryRef<PathBuilder>
@ -562,7 +559,7 @@ DrawTargetRecording::CreateGradientStops(GradientStop *aStops,
mRecorder->RecordEvent(RecordedGradientStopsCreation(retStops, aStops, aNumStops, aExtendMode));
return retStops;
return retStops.forget();
}
void

View File

@ -135,7 +135,7 @@ DrawTargetSkia::Snapshot()
return nullptr;
}
return snapshot;
return snapshot.forget();
}
static void
@ -587,7 +587,7 @@ DrawTargetSkia::CreateSourceSurfaceFromData(unsigned char *aData,
return nullptr;
}
return newSurf;
return newSurf.forget();
}
TemporaryRef<DrawTarget>
@ -597,7 +597,7 @@ DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
if (!target->Init(aSize, aFormat)) {
return nullptr;
}
return target;
return target.forget();
}
bool
@ -638,7 +638,7 @@ DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
map.mStride,
dataSurf->GetFormat());
dataSurf->Unmap();
return result;
return result.forget();
}
TemporaryRef<SourceSurface>
@ -808,8 +808,7 @@ DrawTargetSkia::GetNativeSurface(NativeSurfaceType aType)
TemporaryRef<PathBuilder>
DrawTargetSkia::CreatePathBuilder(FillRule aFillRule) const
{
RefPtr<PathBuilderSkia> pb = new PathBuilderSkia(aFillRule);
return pb;
return new PathBuilderSkia(aFillRule);
}
void

View File

@ -76,7 +76,7 @@ public:
}
surf->Unmap();
return surf;
return surf.forget();
}
private:
vector<RefPtr<SourceSurface>> mSnapshots;

View File

@ -299,9 +299,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
}
if (mRecorder && retVal) {
RefPtr<DrawTarget> recordDT;
recordDT = new DrawTargetRecording(mRecorder, retVal);
return recordDT;
return new DrawTargetRecording(mRecorder, retVal);
}
if (!retVal) {
@ -309,7 +307,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
}
return retVal;
return retVal.forget();
}
TemporaryRef<DrawTarget>
@ -347,7 +345,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
{
RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
if (newTarget->Init(aBackend, aData, aSize, aStride, aFormat))
return newTarget;
return newTarget.forget();
break;
}
#endif
@ -357,7 +355,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
RefPtr<DrawTargetCairo> newTarget;
newTarget = new DrawTargetCairo();
if (newTarget->Init(aData, aSize, aStride, aFormat)) {
retVal = newTarget;
retVal = newTarget.forget();
}
break;
}
@ -368,15 +366,14 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
}
if (mRecorder && retVal) {
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal, true);
return recordDT;
return new DrawTargetRecording(mRecorder, retVal, true);
}
if (!retVal) {
gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
}
return retVal;
return retVal.forget();
}
TemporaryRef<DrawTarget>
@ -388,7 +385,7 @@ Factory::CreateTiledDrawTarget(const TileSet& aTileSet)
return nullptr;
}
return dt;
return dt.forget();
}
TemporaryRef<ScaledFont>
@ -453,7 +450,7 @@ Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, c
// Therefore, we just reuse CreateScaledFontForNativeFont's implementation.
RefPtr<ScaledFont> font = CreateScaledFontForNativeFont(aNativeFont, aSize);
static_cast<ScaledFontBase*>(font.get())->SetCairoScaledFont(aScaledFont);
return font;
return font.forget();
#else
return nullptr;
#endif
@ -471,7 +468,7 @@ Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB)
retVal = new DrawTargetRecording(mRecorder, retVal);
}
return retVal;
return retVal.forget();
}
@ -489,7 +486,7 @@ Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceForma
retVal = new DrawTargetRecording(mRecorder, retVal, true);
}
return retVal;
return retVal.forget();
}
gfxWarning() << "Failed to create draw target for D3D10 texture.";
@ -527,7 +524,7 @@ Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
retVal = new DrawTargetRecording(mRecorder, retVal);
}
return retVal;
return retVal.forget();
}
void
@ -571,10 +568,7 @@ Factory::GetD2D1Device()
TemporaryRef<GlyphRenderingOptions>
Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
{
RefPtr<GlyphRenderingOptions> options =
new GlyphRenderingOptionsDWrite(aParams);
return options;
return new GlyphRenderingOptionsDWrite(aParams);
}
uint64_t
@ -607,7 +601,7 @@ Factory::CreateDrawTargetSkiaWithGrContext(GrContext* aGrContext,
if (!newTarget->InitWithGrContext(aGrContext, aSize, aFormat)) {
return nullptr;
}
return newTarget;
return newTarget.forget();
}
#endif // USE_SKIA_GPU
@ -626,7 +620,7 @@ Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHintin
options->SetHinting(aHinting);
options->SetAutoHinting(aAutoHinting);
return options;
return options.forget();
}
#endif
@ -644,10 +638,10 @@ Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSiz
if (mRecorder && retVal) {
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal, true);
return recordDT;
return recordDT.forget();
}
#endif
return retVal;
return retVal.forget();
}
#ifdef XP_MACOSX
@ -663,10 +657,9 @@ Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize
}
if (mRecorder && retVal) {
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal);
return recordDT;
return new DrawTargetRecording(mRecorder, retVal);
}
return retVal;
return retVal.forget();
}
#endif
@ -682,7 +675,7 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
RefPtr<SourceSurfaceRawData> newSurf = new SourceSurfaceRawData();
if (newSurf->InitWrappingData(aData, aSize, aStride, aFormat, false)) {
return newSurf;
return newSurf.forget();
}
return nullptr;
@ -698,7 +691,7 @@ Factory::CreateDataSourceSurface(const IntSize &aSize,
RefPtr<SourceSurfaceAlignedRawData> newSurf = new SourceSurfaceAlignedRawData();
if (newSurf->Init(aSize, aFormat)) {
return newSurf;
return newSurf.forget();
}
return nullptr;
@ -715,7 +708,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
RefPtr<SourceSurfaceAlignedRawData> newSurf = new SourceSurfaceAlignedRawData();
if (newSurf->InitWithStride(aSize, aFormat, aStride)) {
return newSurf;
return newSurf.forget();
}
return nullptr;

View File

@ -282,7 +282,7 @@ CloneAligned(DataSourceSurface* aSource)
if (copy) {
CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
}
return copy;
return copy.forget();
}
static void
@ -518,7 +518,7 @@ GetDataSurfaceInRect(SourceSurface *aSurface,
}
if (!aSurface) {
return target;
return target.forget();
}
RefPtr<DataSourceSurface> dataSource = aSurface->GetDataSurface();
@ -526,7 +526,7 @@ GetDataSurfaceInRect(SourceSurface *aSurface,
if (aEdgeMode == EDGE_MODE_WRAP) {
TileSurface(dataSource, target, intersectInDestSpace.TopLeft());
return target;
return target.forget();
}
CopyRect(dataSource, target, intersectInSourceSpace,
@ -536,7 +536,7 @@ GetDataSurfaceInRect(SourceSurface *aSurface,
DuplicateEdges(target, intersectInDestSpace);
}
return target;
return target.forget();
}
/* static */ TemporaryRef<FilterNode>
@ -623,7 +623,7 @@ FilterNodeSoftware::Create(FilterType aType)
filter = new FilterNodeLightingSoftware<DistantLightSoftware, SpecularLightingSoftware>("FilterNodeLightingSoftware<DistantLight, SpecularLighting>");
break;
}
return filter;
return filter.forget();
}
void
@ -857,7 +857,7 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
MOZ_ASSERT(!result || result->GetSize() == aRect.Size(), "wrong surface size");
return result;
return result.forget();
}
IntRect
@ -1022,7 +1022,7 @@ FilterNodeBlendSoftware::Render(const IntRect& aRect)
}
// Third case: one of them is transparent. Return the non-transparent one.
return input1 ? input1 : input2;
return input1 ? input1.forget() : input2.forget();
}
void
@ -1104,7 +1104,7 @@ FilterNodeTransformSoftware::Render(const IntRect& aRect)
Matrix transform = Matrix::Translation(srcRect.x, srcRect.y) * mMatrix *
Matrix::Translation(-aRect.x, -aRect.y);
if (transform.IsIdentity() && srcRect.Size() == aRect.Size()) {
return input;
return input.forget();
}
RefPtr<DrawTarget> dt =
@ -1119,7 +1119,7 @@ FilterNodeTransformSoftware::Render(const IntRect& aRect)
RefPtr<SourceSurface> result = dt->Snapshot();
RefPtr<DataSourceSurface> resultData = result->GetDataSurface();
return resultData;
return resultData.forget();
}
void
@ -1229,7 +1229,7 @@ ApplyMorphology(const IntRect& aSourceRect, DataSourceSurface* aInput,
tmpData, tmpStride, destData, destStride, destRect, ry, aOperator);
}
return dest;
return dest.forget();
}
TemporaryRef<DataSourceSurface>
@ -1248,7 +1248,7 @@ FilterNodeMorphologySoftware::Render(const IntRect& aRect)
int32_t ry = mRadii.height;
if (rx == 0 && ry == 0) {
return input;
return input.forget();
}
return ApplyMorphology(srcRect, input, aRect, rx, ry, mOperator);
@ -1325,7 +1325,7 @@ Premultiply(DataSourceSurface* aSurface)
FilterProcessing::DoPremultiplicationCalculation(
size, targetData, targetStride, inputData, inputStride);
return target;
return target.forget();
}
static TemporaryRef<DataSourceSurface>
@ -1350,7 +1350,7 @@ Unpremultiply(DataSourceSurface* aSurface)
FilterProcessing::DoUnpremultiplicationCalculation(
size, targetData, targetStride, inputData, inputStride);
return target;
return target.forget();
}
TemporaryRef<DataSourceSurface>
@ -1373,7 +1373,7 @@ FilterNodeColorMatrixSoftware::Render(const IntRect& aRect)
result = Premultiply(result);
}
return result;
return result.forget();
}
void
@ -1452,7 +1452,7 @@ FilterNodeFloodSoftware::Render(const IntRect& aRect)
MOZ_CRASH();
}
return target;
return target.forget();
}
// Override GetOutput to get around caching. Rendering simple floods is
@ -1564,7 +1564,7 @@ FilterNodeTileSoftware::Render(const IntRect& aRect)
}
}
return target;
return target.forget();
}
void
@ -1706,7 +1706,7 @@ FilterNodeComponentTransferSoftware::Render(const IntRect& aRect)
SurfaceFormat format = input->GetFormat();
if (format == SurfaceFormat::A8 && mDisableA) {
return input;
return input.forget();
}
RefPtr<DataSourceSurface> target =
@ -1721,7 +1721,7 @@ FilterNodeComponentTransferSoftware::Render(const IntRect& aRect)
TransferComponents<4>(input, target, lookupTables);
}
return target;
return target.forget();
}
void
@ -2426,7 +2426,7 @@ FilterNodeConvolveMatrixSoftware::DoRender(const IntRect& aRect,
}
delete[] intKernel;
return target;
return target.forget();
}
void
@ -2567,7 +2567,7 @@ FilterNodeDisplacementMapSoftware::Render(const IntRect& aRect)
}
}
return target;
return target.forget();
}
void
@ -2824,7 +2824,7 @@ FilterNodeCompositeSoftware::Render(const IntRect& aRect)
}
}
}
return dest;
return dest.forget();
}
void
@ -3429,7 +3429,7 @@ FilterNodeLightingSoftware<LightType, LightingType>::DoRender(const IntRect& aRe
}
}
return target;
return target.forget();
}
DiffuseLightingSoftware::DiffuseLightingSoftware()

View File

@ -26,7 +26,7 @@ FilterProcessing::ExtractAlpha(DataSourceSurface* aSource)
ExtractAlpha_Scalar(size, sourceData, sourceStride, alphaData, alphaStride);
}
return alpha;
return alpha.forget();
}
TemporaryRef<DataSourceSurface>
@ -162,7 +162,7 @@ FilterProcessing::CombineColorChannels(DataSourceSurface* aChannel0, DataSourceS
CombineColorChannels_Scalar(size, resultStride, resultData, channelStride, channel0Data, channel1Data, channel2Data, channel3Data);
}
return result;
return result.forget();
}
void

View File

@ -85,7 +85,7 @@ ApplyBlending_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
}
}
return target;
return target.forget();
}
TemporaryRef<DataSourceSurface>

View File

@ -355,7 +355,7 @@ GetTransformedGeometry(ID2D1Geometry *aGeometry, const D2D1_MATRIX_3X2_F &aTrans
aGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES,
aTransform, currentSink);
currentSink->Close();
return tmpGeometry;
return tmpGeometry.forget();
}
static TemporaryRef<ID2D1Geometry>
@ -368,7 +368,7 @@ IntersectGeometry(ID2D1Geometry *aGeometryA, ID2D1Geometry *aGeometryB)
aGeometryA->CombineWithGeometry(aGeometryB, D2D1_COMBINE_MODE_INTERSECT, nullptr, sink);
sink->Close();
return pathGeom;
return pathGeom.forget();
}
static TemporaryRef<ID2D1StrokeStyle>
@ -442,7 +442,7 @@ CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
gfxWarning() << "Failed to create Direct2D stroke style.";
}
return style;
return style.forget();
}
// This creates a (partially) uploaded bitmap for a DataSourceSurface. It
@ -525,7 +525,7 @@ CreatePartialBitmapForSurface(DataSourceSurface *aSurface, const Matrix &aDestin
aSourceTransform.Translate(uploadRect.x, uploadRect.y);
return bitmap;
return bitmap.forget();
} else {
int Bpp = BytesPerPixel(aSurface->GetFormat());
@ -571,7 +571,7 @@ CreatePartialBitmapForSurface(DataSourceSurface *aSurface, const Matrix &aDestin
aSourceTransform.Scale(Float(size.width / newSize.width),
Float(size.height / newSize.height));
return bitmap;
return bitmap.forget();
}
}

View File

@ -100,16 +100,14 @@ PathBuilderCG::EnsureActive(const Point &aPoint)
TemporaryRef<Path>
PathBuilderCG::Finish()
{
RefPtr<PathCG> path = new PathCG(mCGPath, mFillRule);
return path;
return new PathCG(mCGPath, mFillRule);
}
TemporaryRef<PathBuilder>
PathCG::CopyToBuilder(FillRule aFillRule) const
{
CGMutablePathRef path = CGPathCreateMutableCopy(mPath);
RefPtr<PathBuilderCG> builder = new PathBuilderCG(path, aFillRule);
return builder;
return new PathBuilderCG(path, aFillRule);
}
@ -169,8 +167,7 @@ PathCG::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) c
ta.transform = GfxMatrixToCGAffineTransform(aTransform);
CGPathApply(mPath, &ta, TransformApplier::TranformCGPathApplierFunc);
RefPtr<PathBuilderCG> builder = new PathBuilderCG(ta.path, aFillRule);
return builder;
return new PathBuilderCG(ta.path, aFillRule);
}
static void

View File

@ -167,7 +167,7 @@ PathCairo::CopyToBuilder(FillRule aFillRule) const
builder->mPathData = mPathData;
builder->mCurrentPoint = mCurrentPoint;
return builder;
return builder.forget();
}
TemporaryRef<PathBuilder>
@ -178,7 +178,7 @@ PathCairo::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule
AppendPathToBuilder(builder, &aTransform);
builder->mCurrentPoint = aTransform * mCurrentPoint;
return builder;
return builder.forget();
}
bool

View File

@ -353,7 +353,7 @@ PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule)
pathBuilder->mFigureActive = true;
}
return pathBuilder;
return pathBuilder.forget();
}
void

View File

@ -90,7 +90,7 @@ PathRecording::CopyToBuilder(FillRule aFillRule) const
RefPtr<PathBuilder> pathBuilder = mPath->CopyToBuilder(aFillRule);
RefPtr<PathBuilderRecording> recording = new PathBuilderRecording(pathBuilder, aFillRule);
recording->mPathOps = mPathOps;
return recording;
return recording.forget();
}
TemporaryRef<PathBuilder>
@ -113,7 +113,7 @@ PathRecording::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFill
}
recording->mPathOps.push_back(newPathOp);
}
return recording;
return recording.forget();
}
}

View File

@ -105,8 +105,7 @@ PathBuilderSkia::CurrentPoint() const
TemporaryRef<Path>
PathBuilderSkia::Finish()
{
RefPtr<PathSkia> path = new PathSkia(mPath, mFillRule);
return path;
return new PathSkia(mPath, mFillRule);
}
void
@ -124,8 +123,7 @@ PathSkia::CopyToBuilder(FillRule aFillRule) const
TemporaryRef<PathBuilder>
PathSkia::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) const
{
RefPtr<PathBuilderSkia> builder = new PathBuilderSkia(aTransform, mPath, aFillRule);
return builder;
return new PathBuilderSkia(aTransform, mPath, aFillRule);
}
bool

View File

@ -379,7 +379,7 @@ RadialGradientEffectD2D1::CreateGradientTexture()
gfxWarning() << "Failed to create resource texture: " << hr;
}
return tex;
return tex.forget();
}
}

View File

@ -118,7 +118,7 @@ ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *a
cairo_destroy(ctx);
}
return newPath;
return newPath.forget();
}
#endif
return nullptr;

View File

@ -96,9 +96,8 @@ ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aT
TemporaryRef<Path> ret = new PathCG(path, FillRule::FILL_WINDING);
CGPathRelease(path);
return ret;
} else {
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
}
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
}
void

View File

@ -43,9 +43,7 @@ SourceSurfaceCG::GetDataSurface()
// We also need to make sure that the returned surface has
// surface->GetType() == SurfaceType::DATA.
dataSurf = new DataSourceSurfaceWrapper(dataSurf);
return dataSurf;
return new DataSourceSurfaceWrapper(dataSurf);
}
static void releaseCallback(void *info, const void *data, size_t size) {

View File

@ -81,9 +81,7 @@ SourceSurfaceCairo::GetDataSurface()
// We also need to make sure that the returned surface has
// surface->GetType() == SurfaceType::DATA.
dataSurf = new DataSourceSurfaceWrapper(dataSurf);
return dataSurf;
return new DataSourceSurfaceWrapper(dataSurf);
}
cairo_surface_t*

View File

@ -45,7 +45,7 @@ SourceSurfaceD2D::GetDataSurface()
{
RefPtr<DataSourceSurfaceD2D> result = new DataSourceSurfaceD2D(this);
if (result->IsValid()) {
return result;
return result.forget();
}
return nullptr;
}

View File

@ -72,7 +72,7 @@ SourceSurfaceD2DTarget::GetDataSurface()
}
Factory::GetDirect3D10Device()->CopyResource(dataSurf->mTexture, mTexture);
return dataSurf;
return dataSurf.forget();
}
void*