1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/ipc/SharedDIB.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef gfx_SharedDIB_h__ 1.10 +#define gfx_SharedDIB_h__ 1.11 + 1.12 +#include "base/shared_memory.h" 1.13 +#include "nscore.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace gfx { 1.17 + 1.18 +class SharedDIB 1.19 +{ 1.20 +public: 1.21 + typedef base::SharedMemoryHandle Handle; 1.22 + 1.23 +public: 1.24 + SharedDIB(); 1.25 + ~SharedDIB(); 1.26 + 1.27 + // Create and allocate a new shared dib. 1.28 + nsresult Create(uint32_t aSize); 1.29 + 1.30 + // Destroy or release resources associated with this dib. 1.31 + nsresult Close(); 1.32 + 1.33 + // Returns true if this object contains a valid dib. 1.34 + bool IsValid(); 1.35 + 1.36 + // Wrap a new shared dib around allocated shared memory. Note aHandle must point 1.37 + // to a memory section large enough to hold a dib of size aSize, otherwise this 1.38 + // will fail. 1.39 + nsresult Attach(Handle aHandle, uint32_t aSize); 1.40 + 1.41 + // Returns a SharedMemoryHandle suitable for sharing with another process. 1.42 + nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle *aChildHandle); 1.43 + 1.44 +protected: 1.45 + base::SharedMemory *mShMem; 1.46 +}; 1.47 + 1.48 +} // gfx 1.49 +} // mozilla 1.50 + 1.51 +#endif