|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
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_SharedDIBWin_h__ |
|
7 #define gfx_SharedDIBWin_h__ |
|
8 |
|
9 #include <windows.h> |
|
10 |
|
11 #include "SharedDIB.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace gfx { |
|
15 |
|
16 class SharedDIBWin : public SharedDIB |
|
17 { |
|
18 public: |
|
19 SharedDIBWin(); |
|
20 ~SharedDIBWin(); |
|
21 |
|
22 // Allocate a new win32 dib section compatible with an hdc. The dib will |
|
23 // be selected into the hdc on return. |
|
24 nsresult Create(HDC aHdc, uint32_t aWidth, uint32_t aHeight, |
|
25 bool aTransparent); |
|
26 |
|
27 // Wrap a dib section around an existing shared memory object. aHandle should |
|
28 // point to a section large enough for the dib's memory, otherwise this call |
|
29 // will fail. |
|
30 nsresult Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight, |
|
31 bool aTransparent); |
|
32 |
|
33 // Destroy or release resources associated with this dib. |
|
34 nsresult Close(); |
|
35 |
|
36 // Return the HDC of the shared dib. |
|
37 HDC GetHDC() { return mSharedHdc; } |
|
38 |
|
39 // Return the bitmap bits. |
|
40 void* GetBits() { return mBitmapBits; } |
|
41 |
|
42 private: |
|
43 HDC mSharedHdc; |
|
44 HBITMAP mSharedBmp; |
|
45 HGDIOBJ mOldObj; |
|
46 void* mBitmapBits; |
|
47 |
|
48 uint32_t SetupBitmapHeader(uint32_t aWidth, uint32_t aHeight, |
|
49 bool aTransparent, BITMAPV4HEADER *aHeader); |
|
50 nsresult SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr); |
|
51 }; |
|
52 |
|
53 } // gfx |
|
54 } // mozilla |
|
55 |
|
56 #endif |