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_IS_TRANSPARENT = (1 << 2)
26     };
27 
28     gfxWindowsSurface(HDC dc, uint32_t flags = 0);
29 
30     // Create from a shared d3d9surface
31     gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
32 
33     // Create a DIB surface
34     gfxWindowsSurface(const mozilla::gfx::IntSize& size,
35                       gfxImageFormat imageFormat = mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32);
36 
37     gfxWindowsSurface(cairo_surface_t *csurf);
38 
39     virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
40                                                                const mozilla::gfx::IntSize& aSize);
41 
42     void InitWithDC(uint32_t flags);
43 
44     virtual ~gfxWindowsSurface();
45 
46     HDC GetDC();
47 
48     already_AddRefed<gfxImageSurface> GetAsImageSurface();
49 
50     const mozilla::gfx::IntSize GetSize() const;
51 
52 private:
53     void MakeInvalid(mozilla::gfx::IntSize& size);
54 
55     bool mOwnsDC;
56 
57     HDC mDC;
58     HWND mWnd;
59 };
60 
61 #endif /* GFX_WINDOWSSURFACE_H */
62