gfx/thebes/gfxWindowsSurface.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:1926f0efab99
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 GFX_WINDOWSSURFACE_H
7 #define GFX_WINDOWSSURFACE_H
8
9 #include "gfxASurface.h"
10 #include "gfxImageSurface.h"
11
12 /* include windows.h for the HWND and HDC definitions that we need. */
13 #include <windows.h>
14
15 struct IDirect3DSurface9;
16
17 /* undefine LoadImage because our code uses that name */
18 #undef LoadImage
19
20 class gfxContext;
21
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 };
29
30 gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
31 gfxWindowsSurface(HDC dc, uint32_t flags = 0);
32
33 // Create from a shared d3d9surface
34 gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
35
36 // Create a DIB surface
37 gfxWindowsSurface(const gfxIntSize& size,
38 gfxImageFormat imageFormat = gfxImageFormat::RGB24);
39
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);
44
45 gfxWindowsSurface(cairo_surface_t *csurf);
46
47 virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
48 const gfxIntSize& aSize);
49
50 void InitWithDC(uint32_t flags);
51
52 virtual ~gfxWindowsSurface();
53
54 HDC GetDC();
55
56 HDC GetDCWithClip(gfxContext *);
57
58 already_AddRefed<gfxImageSurface> GetAsImageSurface();
59
60 nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
61 nsresult EndPrinting();
62 nsresult AbortPrinting();
63 nsresult BeginPage();
64 nsresult EndPage();
65
66 virtual int32_t GetDefaultContextFlags() const;
67
68 const gfxIntSize GetSize() const;
69
70 void MovePixels(const nsIntRect& aSourceRect,
71 const nsIntPoint& aDestTopLeft)
72 {
73 FastMovePixels(aSourceRect, aDestTopLeft);
74 }
75
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;
79
80 private:
81 void MakeInvalid(gfxIntSize& size);
82
83 bool mOwnsDC;
84 bool mForPrinting;
85
86 HDC mDC;
87 HWND mWnd;
88 };
89
90 #endif /* GFX_WINDOWSSURFACE_H */

mercurial