From 5161d422faabefe490ed851a0319bbb1cd1df56f Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Thu, 20 Sep 2012 21:24:12 +0000 Subject: [PATCH] Bug 722269: Make DrawTargetD2D::DrawSurface deal with any SourceSurface convertible to a DataSourceSurface. r=joedrew --- gfx/2d/DrawTargetD2D.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 07e5dd68c4bb..0c17d6ee6ea2 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -291,9 +291,15 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface, AddDependencyOnSource(srcSurf); } break; - case SURFACE_DATA: + default: { - DataSourceSurface *srcSurf = static_cast(aSurface); + RefPtr srcSurf = aSurface->GetDataSurface(); + + if (!srcSurf) { + gfxDebug() << "Not able to deal with non-data source surface."; + return; + } + if (aSource.width > rt->GetMaximumBitmapSize() || aSource.height > rt->GetMaximumBitmapSize()) { gfxDebug() << "Bitmap source larger than texture size specified. DrawBitmap will silently fail."; @@ -315,8 +321,6 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface, srcRect.y -= (uint32_t)aSource.y; } break; - default: - break; } rt->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(srcRect));