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_SharedDIBWin_h__ michael@0: #define gfx_SharedDIBWin_h__ michael@0: michael@0: #include michael@0: michael@0: #include "SharedDIB.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class SharedDIBWin : public SharedDIB michael@0: { michael@0: public: michael@0: SharedDIBWin(); michael@0: ~SharedDIBWin(); michael@0: michael@0: // Allocate a new win32 dib section compatible with an hdc. The dib will michael@0: // be selected into the hdc on return. michael@0: nsresult Create(HDC aHdc, uint32_t aWidth, uint32_t aHeight, michael@0: bool aTransparent); michael@0: michael@0: // Wrap a dib section around an existing shared memory object. aHandle should michael@0: // point to a section large enough for the dib's memory, otherwise this call michael@0: // will fail. michael@0: nsresult Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight, michael@0: bool aTransparent); michael@0: michael@0: // Destroy or release resources associated with this dib. michael@0: nsresult Close(); michael@0: michael@0: // Return the HDC of the shared dib. michael@0: HDC GetHDC() { return mSharedHdc; } michael@0: michael@0: // Return the bitmap bits. michael@0: void* GetBits() { return mBitmapBits; } michael@0: michael@0: private: michael@0: HDC mSharedHdc; michael@0: HBITMAP mSharedBmp; michael@0: HGDIOBJ mOldObj; michael@0: void* mBitmapBits; michael@0: michael@0: uint32_t SetupBitmapHeader(uint32_t aWidth, uint32_t aHeight, michael@0: bool aTransparent, BITMAPV4HEADER *aHeader); michael@0: nsresult SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr); michael@0: }; michael@0: michael@0: } // gfx michael@0: } // mozilla michael@0: michael@0: #endif