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/. */
5 
6 #ifndef MOZILLA_GFX_PRINTTARGETCG_H
7 #define MOZILLA_GFX_PRINTTARGETCG_H
8 
9 #include <Carbon/Carbon.h>
10 #include "PrintTarget.h"
11 
12 namespace mozilla {
13 namespace gfx {
14 
15 /**
16  * CoreGraphics printing target.
17  *
18  * Note that a CGContextRef obtained from PMSessionGetCGGraphicsContext is
19  * valid only for the current page.  As a consequence instances of this class
20  * should only be used to print a single page.
21  */
22 class PrintTargetCG final : public PrintTarget
23 {
24 public:
25   static already_AddRefed<PrintTargetCG>
26   CreateOrNull(const IntSize& aSize, gfxImageFormat aFormat);
27 
28   static already_AddRefed<PrintTargetCG>
29   CreateOrNull(CGContextRef aContext, const IntSize& aSize);
30 
31   virtual already_AddRefed<DrawTarget>
32   GetReferenceDrawTarget(DrawEventRecorder* aRecorder) final;
33 
34 private:
35   PrintTargetCG(cairo_surface_t* aCairoSurface,
36                 const IntSize& aSize);
37 };
38 
39 } // namespace gfx
40 } // namespace mozilla
41 
42 #endif /* MOZILLA_GFX_PRINTTARGETCG_H */
43