Bug 1116905 - part 3 - remove dependence on implicit conversion from T* to TemporaryRef<T>, gfx changes; r=jrmuizel

This commit is contained in:
Nathan Froyd 2015-04-30 15:20:30 -04:00
parent ce6cd322c7
commit 9ab3ed5081
36 changed files with 113 additions and 94 deletions

View File

@ -12,7 +12,9 @@ namespace gfx {
TemporaryRef<DataSourceSurface> TemporaryRef<DataSourceSurface>
DataSourceSurface::GetDataSurface() DataSourceSurface::GetDataSurface()
{ {
return (GetType() == SurfaceType::DATA) ? this : new DataSourceSurfaceWrapper(this); RefPtr<DataSourceSurface> surface =
(GetType() == SurfaceType::DATA) ? this : new DataSourceSurfaceWrapper(this);
return surface.forget();
} }
} }

View File

@ -191,7 +191,7 @@ DrawTargetCG::Snapshot()
{ {
if (!mSnapshot) { if (!mSnapshot) {
if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) { if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
return new SourceSurfaceCGIOSurfaceContext(this); return MakeAndAddRef<SourceSurfaceCGIOSurfaceContext>(this);
} }
Flush(); Flush();
mSnapshot = new SourceSurfaceCGBitmapContext(this); mSnapshot = new SourceSurfaceCGBitmapContext(this);
@ -262,7 +262,8 @@ GetRetainedImageFromSourceSurface(SourceSurface *aSurface)
TemporaryRef<SourceSurface> TemporaryRef<SourceSurface>
DrawTargetCG::OptimizeSourceSurface(SourceSurface *aSurface) const DrawTargetCG::OptimizeSourceSurface(SourceSurface *aSurface) const
{ {
return aSurface; RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
} }
class UnboundnessFixer class UnboundnessFixer
@ -465,7 +466,7 @@ DrawTargetCG::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
ExtendMode aExtendMode) const ExtendMode aExtendMode) const
{ {
std::vector<GradientStop> stops(aStops, aStops+aNumStops); std::vector<GradientStop> stops(aStops, aStops+aNumStops);
return new GradientStopsCG(mColorSpace, stops, aExtendMode); return MakeAndAddRef<GradientStopsCG>(mColorSpace, stops, aExtendMode);
} }
static void static void
@ -1905,7 +1906,7 @@ DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aForm
TemporaryRef<PathBuilder> TemporaryRef<PathBuilder>
DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const DrawTargetCG::CreatePathBuilder(FillRule aFillRule) const
{ {
return new PathBuilderCG(aFillRule); return MakeAndAddRef<PathBuilderCG>(aFillRule);
} }
void* void*

View File

@ -1326,7 +1326,7 @@ DrawTargetCairo::PopClip()
TemporaryRef<PathBuilder> TemporaryRef<PathBuilder>
DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FillRule::FILL_WINDING */) const DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FillRule::FILL_WINDING */) const
{ {
return new PathBuilderCairo(aFillRule); return MakeAndAddRef<PathBuilderCairo>(aFillRule);
} }
void void
@ -1346,7 +1346,7 @@ TemporaryRef<GradientStops>
DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, DrawTargetCairo::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
ExtendMode aExtendMode) const ExtendMode aExtendMode) const
{ {
return new GradientStopsCairo(aStops, aNumStops, aExtendMode); return MakeAndAddRef<GradientStopsCairo>(aStops, aNumStops, aExtendMode);
} }
TemporaryRef<FilterNode> TemporaryRef<FilterNode>
@ -1400,21 +1400,22 @@ DestroyPixmap(void *data)
TemporaryRef<SourceSurface> TemporaryRef<SourceSurface>
DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
{ {
RefPtr<SourceSurface> surface(aSurface);
#ifdef CAIRO_HAS_XLIB_SURFACE #ifdef CAIRO_HAS_XLIB_SURFACE
cairo_surface_type_t ctype = cairo_surface_get_type(mSurface); cairo_surface_type_t ctype = cairo_surface_get_type(mSurface);
if (aSurface->GetType() == SurfaceType::CAIRO && if (aSurface->GetType() == SurfaceType::CAIRO &&
cairo_surface_get_type( cairo_surface_get_type(
static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface()) == ctype) { static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface()) == ctype) {
return aSurface; return surface.forget();
} }
if (ctype != CAIRO_SURFACE_TYPE_XLIB) { if (ctype != CAIRO_SURFACE_TYPE_XLIB) {
return aSurface; return surface.forget();
} }
IntSize size = aSurface->GetSize(); IntSize size = aSurface->GetSize();
if (!size.width || !size.height) { if (!size.width || !size.height) {
return aSurface; return surface.forget();
} }
// Although the dimension parameters in the xCreatePixmapReq wire protocol are // Although the dimension parameters in the xCreatePixmapReq wire protocol are
@ -1424,7 +1425,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
if (size.width > XLIB_IMAGE_SIDE_SIZE_LIMIT || if (size.width > XLIB_IMAGE_SIDE_SIZE_LIMIT ||
size.height > XLIB_IMAGE_SIDE_SIZE_LIMIT) { size.height > XLIB_IMAGE_SIDE_SIZE_LIMIT) {
return aSurface; return surface.forget();
} }
SurfaceFormat format = aSurface->GetFormat(); SurfaceFormat format = aSurface->GetFormat();
@ -1442,17 +1443,17 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
xrenderFormat = XRenderFindStandardFormat(dpy, PictStandardA8); xrenderFormat = XRenderFindStandardFormat(dpy, PictStandardA8);
break; break;
default: default:
return aSurface; return surface.forget();
} }
if (!xrenderFormat) { if (!xrenderFormat) {
return aSurface; return surface.forget();
} }
Drawable pixmap = XCreatePixmap(dpy, RootWindowOfScreen(screen), Drawable pixmap = XCreatePixmap(dpy, RootWindowOfScreen(screen),
size.width, size.height, size.width, size.height,
xrenderFormat->depth); xrenderFormat->depth);
if (!pixmap) { if (!pixmap) {
return aSurface; return surface.forget();
} }
ScopedDeletePtr<DestroyPixmapClosure> closure( ScopedDeletePtr<DestroyPixmapClosure> closure(
@ -1463,7 +1464,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
screen, xrenderFormat, screen, xrenderFormat,
size.width, size.height)); size.width, size.height));
if (!csurf || cairo_surface_status(csurf)) { if (!csurf || cairo_surface_status(csurf)) {
return aSurface; return surface.forget();
} }
cairo_surface_set_user_data(csurf, &gDestroyPixmapKey, cairo_surface_set_user_data(csurf, &gDestroyPixmapKey,
@ -1471,7 +1472,7 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
RefPtr<DrawTargetCairo> dt = new DrawTargetCairo(); RefPtr<DrawTargetCairo> dt = new DrawTargetCairo();
if (!dt->Init(csurf, size, &format)) { if (!dt->Init(csurf, size, &format)) {
return aSurface; return surface.forget();
} }
dt->CopySurface(aSurface, dt->CopySurface(aSurface,
@ -1479,10 +1480,10 @@ DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
IntPoint(0, 0)); IntPoint(0, 0));
dt->Flush(); dt->Flush();
return new SourceSurfaceCairo(csurf, size, format); surface = new SourceSurfaceCairo(csurf, size, format);
#endif #endif
return aSurface; return surface.forget();
} }
TemporaryRef<SourceSurface> TemporaryRef<SourceSurface>
@ -1495,7 +1496,7 @@ DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurf
return nullptr; return nullptr;
} }
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface); cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
return new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat); return MakeAndAddRef<SourceSurfaceCairo>(surf, aSurface.mSize, aSurface.mFormat);
} }
return nullptr; return nullptr;

View File

@ -1207,7 +1207,8 @@ DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
{ {
if (aSurface->GetType() == SurfaceType::D2D1_BITMAP || if (aSurface->GetType() == SurfaceType::D2D1_BITMAP ||
aSurface->GetType() == SurfaceType::D2D1_DRAWTARGET) { aSurface->GetType() == SurfaceType::D2D1_DRAWTARGET) {
return aSurface; RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
} }
RefPtr<DataSourceSurface> data = aSurface->GetDataSurface(); RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
@ -1284,7 +1285,7 @@ DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
sink->SetFillMode(D2D1_FILL_MODE_WINDING); sink->SetFillMode(D2D1_FILL_MODE_WINDING);
} }
return new PathBuilderD2D(sink, path, aFillRule, BackendType::DIRECT2D); return MakeAndAddRef<PathBuilderD2D>(sink, path, aFillRule, BackendType::DIRECT2D);
} }
TemporaryRef<GradientStops> TemporaryRef<GradientStops>
@ -1310,7 +1311,7 @@ DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, E
return nullptr; return nullptr;
} }
return new GradientStopsD2D(stopCollection, Factory::GetDirect3D11Device()); return MakeAndAddRef<GradientStopsD2D>(stopCollection, Factory::GetDirect3D11Device());
} }
TemporaryRef<FilterNode> TemporaryRef<FilterNode>

View File

@ -657,7 +657,7 @@ DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData,
return nullptr; return nullptr;
} }
return new SourceSurfaceD2D1(bitmap.get(), mDC, aFormat, aSize); return MakeAndAddRef<SourceSurfaceD2D1>(bitmap.get(), mDC, aFormat, aSize);
} }
TemporaryRef<DrawTarget> TemporaryRef<DrawTarget>
@ -694,7 +694,7 @@ DrawTargetD2D1::CreatePathBuilder(FillRule aFillRule) const
sink->SetFillMode(D2D1_FILL_MODE_WINDING); sink->SetFillMode(D2D1_FILL_MODE_WINDING);
} }
return new PathBuilderD2D(sink, path, aFillRule, BackendType::DIRECT2D1_1); return MakeAndAddRef<PathBuilderD2D>(sink, path, aFillRule, BackendType::DIRECT2D1_1);
} }
TemporaryRef<GradientStops> TemporaryRef<GradientStops>
@ -725,7 +725,7 @@ DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops,
return nullptr; return nullptr;
} }
return new GradientStopsD2D(stopCollection, Factory::GetDirect3D11Device()); return MakeAndAddRef<GradientStopsD2D>(stopCollection, Factory::GetDirect3D11Device());
} }
TemporaryRef<FilterNode> TemporaryRef<FilterNode>
@ -1459,7 +1459,8 @@ TemporaryRef<SourceSurface>
DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const
{ {
if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) { if (aSurface->GetType() == SurfaceType::D2D1_1_IMAGE) {
return aSurface; RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
} }
RefPtr<DataSourceSurface> data = aSurface->GetDataSurface(); RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
@ -1484,7 +1485,7 @@ DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const
return data.forget(); return data.forget();
} }
return new SourceSurfaceD2D1(bitmap.get(), mDC, data->GetFormat(), data->GetSize()); return MakeAndAddRef<SourceSurfaceD2D1>(bitmap.get(), mDC, data->GetFormat(), data->GetSize());
} }
void void

View File

@ -192,7 +192,7 @@ DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
return nullptr; return nullptr;
} }
return new DrawTargetDual(dtA, dtB); return MakeAndAddRef<DrawTargetDual>(dtA, dtB);
} }
} }

View File

@ -45,7 +45,9 @@ public:
virtual DrawTargetType GetType() const override { return mA->GetType(); } virtual DrawTargetType GetType() const override { return mA->GetType(); }
virtual BackendType GetBackendType() const override { return mA->GetBackendType(); } virtual BackendType GetBackendType() const override { return mA->GetBackendType(); }
virtual TemporaryRef<SourceSurface> Snapshot() override { return new SourceSurfaceDual(mA, mB); } virtual TemporaryRef<SourceSurface> Snapshot() override {
return MakeAndAddRef<SourceSurfaceDual>(mA, mB);
}
virtual IntSize GetSize() override { return mA->GetSize(); } virtual IntSize GetSize() override { return mA->GetSize(); }
FORWARD_FUNCTION(Flush) FORWARD_FUNCTION(Flush)

View File

@ -541,14 +541,14 @@ TemporaryRef<DrawTarget>
DrawTargetRecording::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const DrawTargetRecording::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
{ {
RefPtr<DrawTarget> dt = mFinalDT->CreateSimilarDrawTarget(aSize, aFormat); RefPtr<DrawTarget> dt = mFinalDT->CreateSimilarDrawTarget(aSize, aFormat);
return new DrawTargetRecording(mRecorder.get(), dt); return MakeAndAddRef<DrawTargetRecording>(mRecorder.get(), dt);
} }
TemporaryRef<PathBuilder> TemporaryRef<PathBuilder>
DrawTargetRecording::CreatePathBuilder(FillRule aFillRule) const DrawTargetRecording::CreatePathBuilder(FillRule aFillRule) const
{ {
RefPtr<PathBuilder> builder = mFinalDT->CreatePathBuilder(aFillRule); RefPtr<PathBuilder> builder = mFinalDT->CreatePathBuilder(aFillRule);
return new PathBuilderRecording(builder, aFillRule); return MakeAndAddRef<PathBuilderRecording>(builder, aFillRule);
} }
TemporaryRef<GradientStops> TemporaryRef<GradientStops>

View File

@ -704,7 +704,8 @@ TemporaryRef<SourceSurface>
DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
{ {
if (aSurface->GetType() == SurfaceType::SKIA) { if (aSurface->GetType() == SurfaceType::SKIA) {
return aSurface; RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
} }
if (!UsingSkiaGPU()) { if (!UsingSkiaGPU()) {
@ -741,13 +742,13 @@ DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurfa
return nullptr; return nullptr;
} }
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface); cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
return new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat); return MakeAndAddRef<SourceSurfaceCairo>(surf, aSurface.mSize, aSurface.mFormat);
#if USE_SKIA_GPU #if USE_SKIA_GPU
} else if (aSurface.mType == NativeSurfaceType::OPENGL_TEXTURE && UsingSkiaGPU()) { } else if (aSurface.mType == NativeSurfaceType::OPENGL_TEXTURE && UsingSkiaGPU()) {
RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia(); RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia();
unsigned int texture = (unsigned int)((uintptr_t)aSurface.mSurface); unsigned int texture = (unsigned int)((uintptr_t)aSurface.mSurface);
if (newSurf->InitFromTexture((DrawTargetSkia*)this, texture, aSurface.mSize, aSurface.mFormat)) { if (newSurf->InitFromTexture((DrawTargetSkia*)this, texture, aSurface.mSize, aSurface.mFormat)) {
return newSurf; return newSurf.forget();
} }
return nullptr; return nullptr;
#endif #endif
@ -928,7 +929,7 @@ DrawTargetSkia::GetNativeSurface(NativeSurfaceType aType)
TemporaryRef<PathBuilder> TemporaryRef<PathBuilder>
DrawTargetSkia::CreatePathBuilder(FillRule aFillRule) const DrawTargetSkia::CreatePathBuilder(FillRule aFillRule) const
{ {
return new PathBuilderSkia(aFillRule); return MakeAndAddRef<PathBuilderSkia>(aFillRule);
} }
void void
@ -981,7 +982,7 @@ DrawTargetSkia::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, Ex
} }
std::stable_sort(stops.begin(), stops.end()); std::stable_sort(stops.begin(), stops.end());
return new GradientStopsSkia(stops, aNumStops, aExtendMode); return MakeAndAddRef<GradientStopsSkia>(stops, aNumStops, aExtendMode);
} }
TemporaryRef<FilterNode> TemporaryRef<FilterNode>

View File

@ -51,7 +51,7 @@ DrawTargetTiled::Init(const TileSet& aTiles)
TemporaryRef<SourceSurface> TemporaryRef<SourceSurface>
DrawTargetTiled::Snapshot() DrawTargetTiled::Snapshot()
{ {
return new SnapshotTiled(mTiles, mRect); return MakeAndAddRef<SnapshotTiled>(mTiles, mRect);
} }
// Skip the mClippedOut check since this is only used for Flush() which // Skip the mClippedOut check since this is only used for Flush() which

View File

@ -337,7 +337,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
} }
if (mRecorder && retVal) { if (mRecorder && retVal) {
return new DrawTargetRecording(mRecorder, retVal); return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal);
} }
if (!retVal) { if (!retVal) {
@ -351,7 +351,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
TemporaryRef<DrawTarget> TemporaryRef<DrawTarget>
Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT) Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT)
{ {
return new DrawTargetRecording(aRecorder, aDT); return MakeAndAddRef<DrawTargetRecording>(aRecorder, aDT);
} }
TemporaryRef<DrawTarget> TemporaryRef<DrawTarget>
@ -406,7 +406,7 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
} }
if (mRecorder && retVal) { if (mRecorder && retVal) {
return new DrawTargetRecording(mRecorder, retVal, true); return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal, true);
} }
if (!retVal) { if (!retVal) {
@ -478,25 +478,25 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
#ifdef WIN32 #ifdef WIN32
case NativeFontType::DWRITE_FONT_FACE: case NativeFontType::DWRITE_FONT_FACE:
{ {
return new ScaledFontDWrite(static_cast<IDWriteFontFace*>(aNativeFont.mFont), aSize); return MakeAndAddRef<ScaledFontDWrite>(static_cast<IDWriteFontFace*>(aNativeFont.mFont), aSize);
} }
#if defined(USE_CAIRO) || defined(USE_SKIA) #if defined(USE_CAIRO) || defined(USE_SKIA)
case NativeFontType::GDI_FONT_FACE: case NativeFontType::GDI_FONT_FACE:
{ {
return new ScaledFontWin(static_cast<LOGFONT*>(aNativeFont.mFont), aSize); return MakeAndAddRef<ScaledFontWin>(static_cast<LOGFONT*>(aNativeFont.mFont), aSize);
} }
#endif #endif
#endif #endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
case NativeFontType::MAC_FONT_FACE: case NativeFontType::MAC_FONT_FACE:
{ {
return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize); return MakeAndAddRef<ScaledFontMac>(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
} }
#endif #endif
#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE) #if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE)
case NativeFontType::CAIRO_FONT_FACE: case NativeFontType::CAIRO_FONT_FACE:
{ {
return new ScaledFontCairo(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize); return MakeAndAddRef<ScaledFontCairo>(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize);
} }
#endif #endif
default: default:
@ -514,7 +514,7 @@ Factory::CreateScaledFontForTrueTypeData(uint8_t *aData, uint32_t aSize,
#ifdef WIN32 #ifdef WIN32
case FontType::DWRITE: case FontType::DWRITE:
{ {
return new ScaledFontDWrite(aData, aSize, aFaceIndex, aGlyphSize); return MakeAndAddRef<ScaledFontDWrite>(aData, aSize, aFaceIndex, aGlyphSize);
} }
#endif #endif
default: default:
@ -706,7 +706,7 @@ Factory::SupportsD2D1()
TemporaryRef<GlyphRenderingOptions> TemporaryRef<GlyphRenderingOptions>
Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams) Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
{ {
return new GlyphRenderingOptionsDWrite(aParams); return MakeAndAddRef<GlyphRenderingOptionsDWrite>(aParams);
} }
uint64_t uint64_t
@ -780,8 +780,7 @@ Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSiz
} }
if (mRecorder && retVal) { if (mRecorder && retVal) {
RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal, true); return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal, true);
return recordDT.forget();
} }
#endif #endif
return retVal.forget(); return retVal.forget();
@ -800,7 +799,7 @@ Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize
} }
if (mRecorder && retVal) { if (mRecorder && retVal) {
return new DrawTargetRecording(mRecorder, retVal); return MakeAndAddRef<DrawTargetRecording>(mRecorder, retVal);
} }
return retVal.forget(); return retVal.forget();
} }
@ -808,7 +807,7 @@ Factory::CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize
TemporaryRef<GlyphRenderingOptions> TemporaryRef<GlyphRenderingOptions>
Factory::CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor) Factory::CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor)
{ {
return new GlyphRenderingOptionsCG(aFontSmoothingBackgroundColor); return MakeAndAddRef<GlyphRenderingOptionsCG>(aFontSmoothingBackgroundColor);
} }
#endif #endif
@ -873,7 +872,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
TemporaryRef<DrawEventRecorder> TemporaryRef<DrawEventRecorder>
Factory::CreateEventRecorderForFile(const char *aFilename) Factory::CreateEventRecorderForFile(const char *aFilename)
{ {
return new DrawEventRecorderFile(aFilename); return MakeAndAddRef<DrawEventRecorderFile>(aFilename);
} }
void void

View File

@ -541,7 +541,7 @@ TemporaryRef<FilterNode>
FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType) FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType)
{ {
if (aType == FilterType::CONVOLVE_MATRIX) { if (aType == FilterType::CONVOLVE_MATRIX) {
return new FilterNodeConvolveD2D1(aDC); return MakeAndAddRef<FilterNodeConvolveD2D1>(aDC);
} }
RefPtr<ID2D1Effect> effect; RefPtr<ID2D1Effect> effect;

View File

@ -1302,7 +1302,8 @@ static TemporaryRef<DataSourceSurface>
Premultiply(DataSourceSurface* aSurface) Premultiply(DataSourceSurface* aSurface)
{ {
if (aSurface->GetFormat() == SurfaceFormat::A8) { if (aSurface->GetFormat() == SurfaceFormat::A8) {
return aSurface; RefPtr<DataSourceSurface> surface(aSurface);
return surface.forget();
} }
IntSize size = aSurface->GetSize(); IntSize size = aSurface->GetSize();
@ -1327,7 +1328,8 @@ static TemporaryRef<DataSourceSurface>
Unpremultiply(DataSourceSurface* aSurface) Unpremultiply(DataSourceSurface* aSurface)
{ {
if (aSurface->GetFormat() == SurfaceFormat::A8) { if (aSurface->GetFormat() == SurfaceFormat::A8) {
return aSurface; RefPtr<DataSourceSurface> surface(aSurface);
return surface.forget();
} }
IntSize size = aSurface->GetSize(); IntSize size = aSurface->GetSize();

View File

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

View File

@ -125,7 +125,7 @@ PathBuilderCairo::CurrentPoint() const
TemporaryRef<Path> TemporaryRef<Path>
PathBuilderCairo::Finish() PathBuilderCairo::Finish()
{ {
return new PathCairo(mFillRule, mPathData, mCurrentPoint); return MakeAndAddRef<PathCairo>(mFillRule, mPathData, mCurrentPoint);
} }
PathCairo::PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint) PathCairo::PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint)

View File

@ -303,7 +303,7 @@ PathBuilderD2D::Finish()
return nullptr; return nullptr;
} }
return new PathD2D(mGeometry, mFigureActive, mCurrentPoint, mFillRule, mBackendType); return MakeAndAddRef<PathD2D>(mGeometry, mFigureActive, mCurrentPoint, mFillRule, mBackendType);
} }
TemporaryRef<PathBuilder> TemporaryRef<PathBuilder>

View File

@ -73,7 +73,7 @@ TemporaryRef<Path>
PathBuilderRecording::Finish() PathBuilderRecording::Finish()
{ {
RefPtr<Path> path = mPathBuilder->Finish(); RefPtr<Path> path = mPathBuilder->Finish();
return new PathRecording(path, mPathOps, mFillRule); return MakeAndAddRef<PathRecording>(path, mPathOps, mFillRule);
} }
PathRecording::~PathRecording() PathRecording::~PathRecording()

View File

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

View File

@ -80,7 +80,7 @@ ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *a
#ifdef USE_SKIA #ifdef USE_SKIA
if (aTarget->GetBackendType() == BackendType::SKIA) { if (aTarget->GetBackendType() == BackendType::SKIA) {
SkPath path = GetSkiaPathForGlyphs(aBuffer); SkPath path = GetSkiaPathForGlyphs(aBuffer);
return new PathSkia(path, FillRule::FILL_WINDING); return MakeAndAddRef<PathSkia>(path, FillRule::FILL_WINDING);
} }
#endif #endif
#ifdef USE_CAIRO #ifdef USE_CAIRO

View File

@ -94,9 +94,9 @@ ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aT
CGPathAddPath(path, &matrix, glyphPath); CGPathAddPath(path, &matrix, glyphPath);
CGPathRelease(glyphPath); CGPathRelease(glyphPath);
} }
TemporaryRef<Path> ret = new PathCG(path, FillRule::FILL_WINDING); RefPtr<Path> ret = new PathCG(path, FillRule::FILL_WINDING);
CGPathRelease(path); CGPathRelease(path);
return ret; return ret.forget();
} }
return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget); return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
} }

View File

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

View File

@ -127,7 +127,8 @@ public:
// //
// For more information see bug 925448. // For more information see bug 925448.
DrawTargetWillChange(); DrawTargetWillChange();
return this; RefPtr<DataSourceSurface> copy(this);
return copy.forget();
} }
CGImageRef GetImage() { EnsureImage(); return mImage; } CGImageRef GetImage() { EnsureImage(); return mImage; }

View File

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

View File

@ -66,7 +66,7 @@ SourceSurfaceD2D1::GetDataSurface()
return nullptr; return nullptr;
} }
return new DataSourceSurfaceD2D1(softwareBitmap, mFormat); return MakeAndAddRef<DataSourceSurfaceD2D1>(softwareBitmap, mFormat);
} }
void void

View File

@ -347,7 +347,7 @@ SurfaceFactory::NewShSurfHandle(const gfx::IntSize& size)
// is no longer being used. // is no longer being used.
surf->WaitForBufferOwnership(); surf->WaitForBufferOwnership();
return new ShSurfHandle(this, Move(surf)); return MakeAndAddRef<ShSurfHandle>(this, Move(surf));
} }
// Auto-deletes surfs of the wrong type. // Auto-deletes surfs of the wrong type.

View File

@ -287,7 +287,7 @@ CreateTexturedEffect(TextureSource* aSource,
if (aSourceOnWhite) { if (aSourceOnWhite) {
MOZ_ASSERT(aSource->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 || MOZ_ASSERT(aSource->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
aSourceOnWhite->GetFormat() == gfx::SurfaceFormat::B8G8R8X8); aSourceOnWhite->GetFormat() == gfx::SurfaceFormat::B8G8R8X8);
return new EffectComponentAlpha(aSource, aSourceOnWhite, aFilter); return MakeAndAddRef<EffectComponentAlpha>(aSource, aSourceOnWhite, aFilter);
} }
return CreateTexturedEffect(aSource->GetFormat(), return CreateTexturedEffect(aSource->GetFormat(),

View File

@ -458,7 +458,8 @@ TemporaryRef<gfx::SourceSurface>
PlanarYCbCrImage::GetAsSourceSurface() PlanarYCbCrImage::GetAsSourceSurface()
{ {
if (mSourceSurface) { if (mSourceSurface) {
return mSourceSurface.get(); RefPtr<gfx::SourceSurface> surface(mSourceSurface);
return surface.forget();
} }
gfx::IntSize size(mSize); gfx::IntSize size(mSize);

View File

@ -804,7 +804,8 @@ public:
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() override
{ {
return mSourceSurface.get(); RefPtr<gfx::SourceSurface> surface(mSourceSurface);
return surface.forget();
} }
virtual TextureClient* GetTextureClient(CompositableClient* aClient) override; virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;

View File

@ -136,7 +136,8 @@ BasicPlanarYCbCrImage::GetAsSourceSurface()
NS_ASSERTION(NS_IsMainThread(), "Must be main thread"); NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
if (mSourceSurface) { if (mSourceSurface) {
return mSourceSurface.get(); RefPtr<gfx::SourceSurface> surface(mSourceSurface);
return surface.forget();
} }
if (!mDecodedBuffer) { if (!mDecodedBuffer) {
@ -165,7 +166,7 @@ BasicPlanarYCbCrImage::GetAsSourceSurface()
mRecycleBin->RecycleBuffer(mDecodedBuffer.forget(), mSize.height * mStride); mRecycleBin->RecycleBuffer(mDecodedBuffer.forget(), mSize.height * mStride);
mSourceSurface = surface; mSourceSurface = surface;
return mSourceSurface.get(); return surface.forget();
} }

View File

@ -40,16 +40,18 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
#ifndef MOZ_WIDGET_GONK #ifndef MOZ_WIDGET_GONK
if (XRE_GetProcessType() != GeckoProcessType_Default) { if (XRE_GetProcessType() != GeckoProcessType_Default) {
NS_WARNING("Most platforms still need an optimized way to share GL cross process."); NS_WARNING("Most platforms still need an optimized way to share GL cross process.");
return new CanvasClient2D(aForwarder, aFlags); return MakeAndAddRef<CanvasClient2D>(aForwarder, aFlags);
} }
#endif #endif
switch (aType) { switch (aType) {
case CanvasClientTypeShSurf: case CanvasClientTypeShSurf:
return new CanvasClientSharedSurface(aForwarder, aFlags); return MakeAndAddRef<CanvasClientSharedSurface>(aForwarder, aFlags);
break;
default: default:
return new CanvasClient2D(aForwarder, aFlags); return MakeAndAddRef<CanvasClient2D>(aForwarder, aFlags);
break;
} }
} }
@ -167,7 +169,7 @@ TexClientFromShSurf(ISurfaceAllocator* aAllocator, SharedSurface* surf,
#endif #endif
default: default:
return new SharedSurfaceTextureClient(aAllocator, flags, surf); return MakeAndAddRef<SharedSurfaceTextureClient>(aAllocator, flags, surf);
} }
} }

View File

@ -91,9 +91,9 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
} }
if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) { if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) {
return new ContentClientDoubleBuffered(aForwarder); return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
} }
return new ContentClientSingleBuffered(aForwarder); return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);
} }
void void

View File

@ -198,7 +198,8 @@ TextureClientRecycleAllocatorImp::CreateOrRecycleForDrawing(
mInUseClients[textureHolder->GetTextureClient()] = textureHolder; mInUseClients[textureHolder->GetTextureClient()] = textureHolder;
} }
textureHolder->GetTextureClient()->SetRecycleCallback(TextureClientRecycleAllocatorImp::RecycleCallback, this); textureHolder->GetTextureClient()->SetRecycleCallback(TextureClientRecycleAllocatorImp::RecycleCallback, this);
return textureHolder->GetTextureClient(); RefPtr<TextureClient> client(textureHolder->GetTextureClient());
return client.forget();
} }
void void

View File

@ -188,7 +188,7 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags); return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSharedSurfaceDescriptor: case SurfaceDescriptor::TSharedSurfaceDescriptor:
return new SharedSurfaceTextureHost(aFlags, aDesc.get_SharedSurfaceDescriptor()); return MakeAndAddRef<SharedSurfaceTextureHost>(aFlags, aDesc.get_SharedSurfaceDescriptor());
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) { if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {

View File

@ -97,7 +97,7 @@ CompositorD3D9::GetMaxTextureSize() const
TemporaryRef<DataTextureSource> TemporaryRef<DataTextureSource>
CompositorD3D9::CreateDataTextureSource(TextureFlags aFlags) CompositorD3D9::CreateDataTextureSource(TextureFlags aFlags)
{ {
return new DataTextureSourceD3D9(SurfaceFormat::UNKNOWN, this, aFlags); return MakeAndAddRef<DataTextureSourceD3D9>(SurfaceFormat::UNKNOWN, this, aFlags);
} }
TemporaryRef<CompositingRenderTarget> TemporaryRef<CompositingRenderTarget>

View File

@ -135,7 +135,7 @@ public:
red = modf(i * 0.03f, &tmp); red = modf(i * 0.03f, &tmp);
EffectChain effects; EffectChain effects;
gfxRGBA color(red, 0.4f, 0.4f, 1.0f); gfxRGBA color(red, 0.4f, 0.4f, 1.0f);
return new EffectSolidColor(gfx::Color(color.r, return MakeAndAddRef<EffectSolidColor>(gfx::Color(color.r,
color.g, color.g,
color.b, color.b,
color.a)); color.a));
@ -161,7 +161,7 @@ public:
red = modf(i * 0.03f, &tmp); red = modf(i * 0.03f, &tmp);
EffectChain effects; EffectChain effects;
gfxRGBA color(red, 0.4f, 0.4f, 1.0f); gfxRGBA color(red, 0.4f, 0.4f, 1.0f);
return new EffectSolidColor(gfx::Color(color.r, return MakeAndAddRef<EffectSolidColor>(gfx::Color(color.r,
color.g, color.g,
color.b, color.b,
color.a)); color.a));

View File

@ -331,7 +331,8 @@ gfxUtils::CreatePremultipliedDataSurface(DataSourceSurface* srcSurf)
DataSourceSurface::MappedSurface destMap; DataSourceSurface::MappedSurface destMap;
if (!MapSrcAndCreateMappedDest(srcSurf, &destSurf, &srcMap, &destMap)) { if (!MapSrcAndCreateMappedDest(srcSurf, &destSurf, &srcMap, &destMap)) {
MOZ_ASSERT(false, "MapSrcAndCreateMappedDest failed."); MOZ_ASSERT(false, "MapSrcAndCreateMappedDest failed.");
return srcSurf; RefPtr<DataSourceSurface> surface(srcSurf);
return surface.forget();
} }
PremultiplyData(srcMap.mData, srcMap.mStride, PremultiplyData(srcMap.mData, srcMap.mStride,
@ -351,7 +352,8 @@ gfxUtils::CreateUnpremultipliedDataSurface(DataSourceSurface* srcSurf)
DataSourceSurface::MappedSurface destMap; DataSourceSurface::MappedSurface destMap;
if (!MapSrcAndCreateMappedDest(srcSurf, &destSurf, &srcMap, &destMap)) { if (!MapSrcAndCreateMappedDest(srcSurf, &destSurf, &srcMap, &destMap)) {
MOZ_ASSERT(false, "MapSrcAndCreateMappedDest failed."); MOZ_ASSERT(false, "MapSrcAndCreateMappedDest failed.");
return srcSurf; RefPtr<DataSourceSurface> surface(srcSurf);
return surface.forget();
} }
UnpremultiplyData(srcMap.mData, srcMap.mStride, UnpremultiplyData(srcMap.mData, srcMap.mStride,