From 21a12a201c3772a81188548a96afa3c76922f6f0 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Fri, 8 Nov 2013 14:39:34 +1300 Subject: [PATCH] Bug 934842. CopySurface for data source surfaces. r=Bas --- gfx/2d/DrawTargetCairo.cpp | 9 +++++++-- gfx/2d/DrawTargetD2D.cpp | 21 +-------------------- 2 files changed, 8 insertions(+), 22 deletions(-) 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; }