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 gfx_SharedDIB_h__ michael@0: #define gfx_SharedDIB_h__ michael@0: michael@0: #include "base/shared_memory.h" michael@0: #include "nscore.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class SharedDIB michael@0: { michael@0: public: michael@0: typedef base::SharedMemoryHandle Handle; michael@0: michael@0: public: michael@0: SharedDIB(); michael@0: ~SharedDIB(); michael@0: michael@0: // Create and allocate a new shared dib. michael@0: nsresult Create(uint32_t aSize); michael@0: michael@0: // Destroy or release resources associated with this dib. michael@0: nsresult Close(); michael@0: michael@0: // Returns true if this object contains a valid dib. michael@0: bool IsValid(); michael@0: michael@0: // Wrap a new shared dib around allocated shared memory. Note aHandle must point michael@0: // to a memory section large enough to hold a dib of size aSize, otherwise this michael@0: // will fail. michael@0: nsresult Attach(Handle aHandle, uint32_t aSize); michael@0: michael@0: // Returns a SharedMemoryHandle suitable for sharing with another process. michael@0: nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle *aChildHandle); michael@0: michael@0: protected: michael@0: base::SharedMemory *mShMem; michael@0: }; michael@0: michael@0: } // gfx michael@0: } // mozilla michael@0: michael@0: #endif