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

View File

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

View File

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

View File

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

View File

@ -192,7 +192,7 @@ DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
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 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(); }
FORWARD_FUNCTION(Flush)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -130,14 +130,14 @@ PathBuilderCG::EnsureActive(const Point &aPoint)
TemporaryRef<Path>
PathBuilderCG::Finish()
{
return new PathCG(mCGPath, mFillRule);
return MakeAndAddRef<PathCG>(mCGPath, mFillRule);
}
TemporaryRef<PathBuilder>
PathCG::CopyToBuilder(FillRule aFillRule) const
{
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);
CGPathApply(mPath, &ta, TransformApplier::TranformCGPathApplierFunc);
return new PathBuilderCG(ta.path, aFillRule);
return MakeAndAddRef<PathBuilderCG>(ta.path, aFillRule);
}
static void

View File

@ -125,7 +125,7 @@ PathBuilderCairo::CurrentPoint() const
TemporaryRef<Path>
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,16 +40,18 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
#ifndef MOZ_WIDGET_GONK
if (XRE_GetProcessType() != GeckoProcessType_Default) {
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
switch (aType) {
case CanvasClientTypeShSurf:
return new CanvasClientSharedSurface(aForwarder, aFlags);
return MakeAndAddRef<CanvasClientSharedSurface>(aForwarder, aFlags);
break;
default:
return new CanvasClient2D(aForwarder, aFlags);
return MakeAndAddRef<CanvasClient2D>(aForwarder, aFlags);
break;
}
}
@ -167,7 +169,7 @@ TexClientFromShSurf(ISurfaceAllocator* aAllocator, SharedSurface* surf,
#endif
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")) {
return new ContentClientDoubleBuffered(aForwarder);
return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
}
return new ContentClientSingleBuffered(aForwarder);
return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);
}
void

View File

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

View File

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

View File

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

View File

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

View File

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