1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_GFX_PRINTTARGETEMF_H
7 #define MOZILLA_GFX_PRINTTARGETEMF_H
9 #include "PrintTargetSkPDF.h"
10 #include "mozilla/ipc/Shmem.h"
12 /* include windows.h for the HDC definitions that we need. */
17 class PDFiumProcessParent
;
25 * A new subclass of PrintTarget.
26 * 1. It uses PrintTargetSkPDF to generate one PDF file for one page.
27 * 2. It then passes the FileDescriptor of that generated PDF file to the
28 * PDFium process for EMF conversion.
29 * 3. After getting the converted EMF contents from the PDFium process, it then
30 * draws it onto the printer DC to finish one page printing task.
32 class PrintTargetEMF final
: public mozilla::gfx::PrintTarget
35 typedef gfx::IntSize IntSize
;
36 typedef mozilla::widget::PDFiumProcessParent PDFiumProcessParent
;
38 static already_AddRefed
<PrintTargetEMF
>
39 CreateOrNull(HDC aDC
, const IntSize
& aSizeInPoints
);
41 nsresult
BeginPrinting(const nsAString
& aTitle
,
42 const nsAString
& aPrintToFileName
,
44 int32_t aEndPage
) final
;
45 nsresult
EndPrinting() final
;
46 nsresult
AbortPrinting() final
;
47 nsresult
BeginPage() final
;
48 nsresult
EndPage() final
;
50 already_AddRefed
<DrawTarget
>
51 MakeDrawTarget(const IntSize
& aSize
,
52 DrawEventRecorder
* aRecorder
= nullptr) final
;
54 already_AddRefed
<DrawTarget
>
55 GetReferenceDrawTarget() final
;
57 void ConvertToEMFDone(const nsresult
& aResult
, mozilla::ipc::Shmem
&& aEMF
);
58 bool IsSyncPagePrinting() const final
{ return false; }
59 void ChannelIsBroken() { mChannelBroken
= true; }
62 PrintTargetEMF(HDC aDC
, const IntSize
& aSize
);
63 ~PrintTargetEMF() override
;
66 RefPtr
<PrintTargetSkPDF
> mTargetForCurrentPage
;
67 nsCOMPtr
<nsIFile
> mPDFFileForOnePage
;
68 RefPtr
<PrintTargetSkPDF
> mRefTarget
;
69 PDFiumProcessParent
* mPDFiumProcess
;
75 } // namespace mozilla
77 #endif /* MOZILLA_GFX_PRINTTARGETEMF_H */