Bug 1399787 - Part 11.d. Using PrintTargetEMF on windows if skia-pdf is enable.
MozReview-Commit-ID: Hx94fqGJFz6
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -31,16 +31,17 @@
#include "nsIDOMWindow.h"
#include "mozilla/Services.h"
#include "nsWindowsHelpers.h"
#include "mozilla/gfx/Logging.h"
#ifdef MOZ_ENABLE_SKIA_PDF
#include "mozilla/gfx/PrintTargetSkPDF.h"
+#include "mozilla/gfx/PrintTargetEMF.h"
#include "nsIUUIDGenerator.h"
#include "nsDirectoryServiceDefs.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#endif
static mozilla::LazyLogModule kWidgetPrintingLogMod("printing-widget");
#define PR_PL(_p1) MOZ_LOG(kWidgetPrintingLogMod, mozilla::LogLevel::Debug, _p1)
@@ -222,17 +223,24 @@ already_AddRefed<PrintTarget> nsDeviceCo
mPrintSettings->GetToFileName(filename);
nsAutoCString printFile(NS_ConvertUTF16toUTF8(filename).get());
auto skStream = MakeUnique<SkFILEWStream>(printFile.get());
return PrintTargetSkPDF::CreateOrNull(Move(skStream), size);
}
if (mDevMode) {
- // TBD: Implement a new PrintTarget to serve EMF OOP.
+ NS_WARNING_ASSERTION(!mDriverName.IsEmpty(), "No driver!");
+ HDC dc = ::CreateDCW(mDriverName.get(), mDeviceName.get(), nullptr, mDevMode);
+ if (!dc) {
+ gfxCriticalError(gfxCriticalError::DefaultOptions(false))
+ << "Failed to create device context in GetSurfaceForPrinter";
+ return nullptr;
+ }
+ return PrintTargetEMF::CreateOrNull(dc, size);
}
}
#endif
if (mOutputFormat == nsIPrintSettings::kOutputFormatPDF) {
nsString filename;
mPrintSettings->GetToFileName(filename);