Bug 922942 - Use Moz2D for android snapshots. r=roc

This commit is contained in:
Matt Woodrow 2013-10-15 16:23:20 +13:00
parent 8fcf41be6c
commit e74644cd8e

View File

@ -25,7 +25,9 @@
#include "nsIThreadManager.h" #include "nsIThreadManager.h"
#include "mozilla/dom/mobilemessage/PSms.h" #include "mozilla/dom/mobilemessage/PSms.h"
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "mozilla/gfx/2D.h"
#include "gfxUtils.h" #include "gfxUtils.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
@ -44,6 +46,7 @@
#endif #endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::gfx;
NS_IMPL_ISUPPORTS0(nsFilePickerCallback) NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
@ -1848,7 +1851,20 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
ALOG_BRIDGE("Error creating gfxImageSurface"); ALOG_BRIDGE("Error creating gfxImageSurface");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsRefPtr<gfxContext> context = new gfxContext(surf);
nsRefPtr<gfxContext> context;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, IntSize(bufW, bufH));
if (!dt) {
ALOG_BRIDGE("Error creating DrawTarget");
return NS_ERROR_FAILURE;
}
context = new gfxContext(dt);
} else {
context = new gfxContext(surf);
}
gfxPoint pt(0, 0); gfxPoint pt(0, 0);
context->Translate(pt); context->Translate(pt);
context->Scale(scale * bufW / srcW, scale * bufH / srcH); context->Scale(scale * bufW / srcW, scale * bufH / srcH);