michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_gfx_SharedDIBSurface_h michael@0: #define mozilla_gfx_SharedDIBSurface_h michael@0: michael@0: #include "gfxImageSurface.h" michael@0: #include "SharedDIBWin.h" michael@0: michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: /** michael@0: * A SharedDIBSurface owns an underlying SharedDIBWin. michael@0: */ michael@0: class SharedDIBSurface : public gfxImageSurface michael@0: { michael@0: public: michael@0: typedef base::SharedMemoryHandle Handle; michael@0: michael@0: SharedDIBSurface() { } michael@0: ~SharedDIBSurface() { } michael@0: michael@0: /** michael@0: * Create this image surface backed by shared memory. michael@0: */ michael@0: bool Create(HDC adc, uint32_t aWidth, uint32_t aHeight, bool aTransparent); michael@0: michael@0: /** michael@0: * Attach this surface to shared memory from another process. michael@0: */ michael@0: bool Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight, michael@0: bool aTransparent); michael@0: michael@0: /** michael@0: * After drawing to a surface via GDI, GDI must be flushed before the bitmap michael@0: * is valid. michael@0: */ michael@0: void Flush() { ::GdiFlush(); } michael@0: michael@0: HDC GetHDC() { return mSharedDIB.GetHDC(); } michael@0: michael@0: nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) { michael@0: return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle); michael@0: } michael@0: michael@0: static bool IsSharedDIBSurface(gfxASurface* aSurface); michael@0: michael@0: private: michael@0: SharedDIBWin mSharedDIB; michael@0: michael@0: void InitSurface(uint32_t aWidth, uint32_t aHeight, bool aTransparent); michael@0: }; michael@0: michael@0: } // namespace gfx michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_gfx_SharedDIBSurface_h