diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index ef56217e1932..2906c4a74271 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -724,14 +724,19 @@ DrawTargetCairo::CopySurface(SourceSurface *aSurface, AutoPrepareForDrawing prep(this, mContext); AutoClearDeviceOffset clear(aSurface); - if (!aSurface || aSurface->GetType() != SURFACE_CAIRO) { + if (!aSurface) { gfxWarning() << "Unsupported surface type specified"; return; } - cairo_surface_t* surf = static_cast(aSurface)->GetSurface(); + cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aSurface); + if (!surf) { + gfxWarning() << "Unsupported surface type specified"; + return; + } CopySurfaceInternal(surf, aSource, aDest); + cairo_surface_destroy(surf); } void diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 12a76a29b028..c209c80788dc 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -763,26 +763,7 @@ DrawTargetD2D::CopySurface(SourceSurface *aSurface, mRT->Clear(D2D1::ColorF(0, 0.0f)); mRT->PopAxisAlignedClip(); - RefPtr bitmap; - - switch (aSurface->GetType()) { - case SURFACE_D2D1_BITMAP: - { - SourceSurfaceD2D *srcSurf = static_cast(aSurface); - bitmap = srcSurf->GetBitmap(); - } - break; - case SURFACE_D2D1_DRAWTARGET: - { - SourceSurfaceD2DTarget *srcSurf = static_cast(aSurface); - bitmap = srcSurf->GetBitmap(mRT); - AddDependencyOnSource(srcSurf); - } - break; - default: - return; - } - + RefPtr bitmap = GetBitmapForSurface(aSurface, srcRect); if (!bitmap) { return; }