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/. */
6 #ifndef mozilla_gfx_SharedDIBSurface_h
7 #define mozilla_gfx_SharedDIBSurface_h
9 #include "gfxImageSurface.h"
10 #include "SharedDIBWin.h"
18 * A SharedDIBSurface owns an underlying SharedDIBWin.
20 class SharedDIBSurface
: public gfxImageSurface
23 typedef base::SharedMemoryHandle Handle
;
25 SharedDIBSurface() { }
26 ~SharedDIBSurface() { }
29 * Create this image surface backed by shared memory.
31 bool Create(HDC adc
, uint32_t aWidth
, uint32_t aHeight
, bool aTransparent
);
34 * Attach this surface to shared memory from another process.
36 bool Attach(Handle aHandle
, uint32_t aWidth
, uint32_t aHeight
,
40 * After drawing to a surface via GDI, GDI must be flushed before the bitmap
43 void Flush() { ::GdiFlush(); }
45 HDC
GetHDC() { return mSharedDIB
.GetHDC(); }
47 nsresult
ShareToProcess(base::ProcessHandle aChildProcess
, Handle
* aChildHandle
) {
48 return mSharedDIB
.ShareToProcess(aChildProcess
, aChildHandle
);
51 static bool IsSharedDIBSurface(gfxASurface
* aSurface
);
54 SharedDIBWin mSharedDIB
;
56 void InitSurface(uint32_t aWidth
, uint32_t aHeight
, bool aTransparent
);
60 } // namespace mozilla
62 #endif // mozilla_gfx_SharedDIBSurface_h