Bug 1492908 [wpt PR 13122] - Update wpt metadata, a=testonly
[gecko.git] / gfx / thebes / PrintTargetEMF.h
blob45531acea70beb3f3bacbf8b884bded9d68b906e
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. */
13 #include <windows.h>
15 namespace mozilla {
16 namespace widget {
17 class PDFiumProcessParent;
21 namespace mozilla {
22 namespace gfx {
24 /**
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
34 public:
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,
43 int32_t aStartPage,
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; }
61 private:
62 PrintTargetEMF(HDC aDC, const IntSize& aSize);
63 ~PrintTargetEMF() override;
65 nsString mTitle;
66 RefPtr<PrintTargetSkPDF> mTargetForCurrentPage;
67 nsCOMPtr<nsIFile> mPDFFileForOnePage;
68 RefPtr<PrintTargetSkPDF> mRefTarget;
69 PDFiumProcessParent* mPDFiumProcess;
70 HDC mPrinterDC;
71 bool mChannelBroken;
74 } // namespace gfx
75 } // namespace mozilla
77 #endif /* MOZILLA_GFX_PRINTTARGETEMF_H */