Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef gfx_SharedDIB_h__ |
michael@0 | 7 | #define gfx_SharedDIB_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "base/shared_memory.h" |
michael@0 | 10 | #include "nscore.h" |
michael@0 | 11 | |
michael@0 | 12 | namespace mozilla { |
michael@0 | 13 | namespace gfx { |
michael@0 | 14 | |
michael@0 | 15 | class SharedDIB |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | typedef base::SharedMemoryHandle Handle; |
michael@0 | 19 | |
michael@0 | 20 | public: |
michael@0 | 21 | SharedDIB(); |
michael@0 | 22 | ~SharedDIB(); |
michael@0 | 23 | |
michael@0 | 24 | // Create and allocate a new shared dib. |
michael@0 | 25 | nsresult Create(uint32_t aSize); |
michael@0 | 26 | |
michael@0 | 27 | // Destroy or release resources associated with this dib. |
michael@0 | 28 | nsresult Close(); |
michael@0 | 29 | |
michael@0 | 30 | // Returns true if this object contains a valid dib. |
michael@0 | 31 | bool IsValid(); |
michael@0 | 32 | |
michael@0 | 33 | // Wrap a new shared dib around allocated shared memory. Note aHandle must point |
michael@0 | 34 | // to a memory section large enough to hold a dib of size aSize, otherwise this |
michael@0 | 35 | // will fail. |
michael@0 | 36 | nsresult Attach(Handle aHandle, uint32_t aSize); |
michael@0 | 37 | |
michael@0 | 38 | // Returns a SharedMemoryHandle suitable for sharing with another process. |
michael@0 | 39 | nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle *aChildHandle); |
michael@0 | 40 | |
michael@0 | 41 | protected: |
michael@0 | 42 | base::SharedMemory *mShMem; |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | } // gfx |
michael@0 | 46 | } // mozilla |
michael@0 | 47 | |
michael@0 | 48 | #endif |