gfx/ipc/SharedDIBSurface.h

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:76a98eba52ed
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 mozilla_gfx_SharedDIBSurface_h
7 #define mozilla_gfx_SharedDIBSurface_h
8
9 #include "gfxImageSurface.h"
10 #include "SharedDIBWin.h"
11
12 #include <windows.h>
13
14 namespace mozilla {
15 namespace gfx {
16
17 /**
18 * A SharedDIBSurface owns an underlying SharedDIBWin.
19 */
20 class SharedDIBSurface : public gfxImageSurface
21 {
22 public:
23 typedef base::SharedMemoryHandle Handle;
24
25 SharedDIBSurface() { }
26 ~SharedDIBSurface() { }
27
28 /**
29 * Create this image surface backed by shared memory.
30 */
31 bool Create(HDC adc, uint32_t aWidth, uint32_t aHeight, bool aTransparent);
32
33 /**
34 * Attach this surface to shared memory from another process.
35 */
36 bool Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight,
37 bool aTransparent);
38
39 /**
40 * After drawing to a surface via GDI, GDI must be flushed before the bitmap
41 * is valid.
42 */
43 void Flush() { ::GdiFlush(); }
44
45 HDC GetHDC() { return mSharedDIB.GetHDC(); }
46
47 nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) {
48 return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle);
49 }
50
51 static bool IsSharedDIBSurface(gfxASurface* aSurface);
52
53 private:
54 SharedDIBWin mSharedDIB;
55
56 void InitSurface(uint32_t aWidth, uint32_t aHeight, bool aTransparent);
57 };
58
59 } // namespace gfx
60 } // namespace mozilla
61
62 #endif // mozilla_gfx_SharedDIBSurface_h

mercurial