Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 GFX_WINDOWSSURFACE_H
7 #define GFX_WINDOWSSURFACE_H
9 #include "gfxASurface.h"
10 #include "gfxImageSurface.h"
12 /* include windows.h for the HWND and HDC definitions that we need. */
13 #include <windows.h>
15 struct IDirect3DSurface9;
17 /* undefine LoadImage because our code uses that name */
18 #undef LoadImage
20 class gfxContext;
22 class gfxWindowsSurface : public gfxASurface {
23 public:
24 enum {
25 FLAG_TAKE_DC = (1 << 0),
26 FLAG_FOR_PRINTING = (1 << 1),
27 FLAG_IS_TRANSPARENT = (1 << 2)
28 };
30 gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
31 gfxWindowsSurface(HDC dc, uint32_t flags = 0);
33 // Create from a shared d3d9surface
34 gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
36 // Create a DIB surface
37 gfxWindowsSurface(const gfxIntSize& size,
38 gfxImageFormat imageFormat = gfxImageFormat::RGB24);
40 // Create a DDB surface; dc may be nullptr to use the screen DC
41 gfxWindowsSurface(HDC dc,
42 const gfxIntSize& size,
43 gfxImageFormat imageFormat = gfxImageFormat::RGB24);
45 gfxWindowsSurface(cairo_surface_t *csurf);
47 virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
48 const gfxIntSize& aSize);
50 void InitWithDC(uint32_t flags);
52 virtual ~gfxWindowsSurface();
54 HDC GetDC();
56 HDC GetDCWithClip(gfxContext *);
58 already_AddRefed<gfxImageSurface> GetAsImageSurface();
60 nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
61 nsresult EndPrinting();
62 nsresult AbortPrinting();
63 nsresult BeginPage();
64 nsresult EndPage();
66 virtual int32_t GetDefaultContextFlags() const;
68 const gfxIntSize GetSize() const;
70 void MovePixels(const nsIntRect& aSourceRect,
71 const nsIntPoint& aDestTopLeft)
72 {
73 FastMovePixels(aSourceRect, aDestTopLeft);
74 }
76 // The memory used by this surface lives in this process's address space,
77 // but not in the heap.
78 virtual gfxMemoryLocation GetMemoryLocation() const;
80 private:
81 void MakeInvalid(gfxIntSize& size);
83 bool mOwnsDC;
84 bool mForPrinting;
86 HDC mDC;
87 HWND mWnd;
88 };
90 #endif /* GFX_WINDOWSSURFACE_H */