1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/ipc/SharedDIBSurface.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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 mozilla_gfx_SharedDIBSurface_h 1.10 +#define mozilla_gfx_SharedDIBSurface_h 1.11 + 1.12 +#include "gfxImageSurface.h" 1.13 +#include "SharedDIBWin.h" 1.14 + 1.15 +#include <windows.h> 1.16 + 1.17 +namespace mozilla { 1.18 +namespace gfx { 1.19 + 1.20 +/** 1.21 + * A SharedDIBSurface owns an underlying SharedDIBWin. 1.22 + */ 1.23 +class SharedDIBSurface : public gfxImageSurface 1.24 +{ 1.25 +public: 1.26 + typedef base::SharedMemoryHandle Handle; 1.27 + 1.28 + SharedDIBSurface() { } 1.29 + ~SharedDIBSurface() { } 1.30 + 1.31 + /** 1.32 + * Create this image surface backed by shared memory. 1.33 + */ 1.34 + bool Create(HDC adc, uint32_t aWidth, uint32_t aHeight, bool aTransparent); 1.35 + 1.36 + /** 1.37 + * Attach this surface to shared memory from another process. 1.38 + */ 1.39 + bool Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight, 1.40 + bool aTransparent); 1.41 + 1.42 + /** 1.43 + * After drawing to a surface via GDI, GDI must be flushed before the bitmap 1.44 + * is valid. 1.45 + */ 1.46 + void Flush() { ::GdiFlush(); } 1.47 + 1.48 + HDC GetHDC() { return mSharedDIB.GetHDC(); } 1.49 + 1.50 + nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) { 1.51 + return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle); 1.52 + } 1.53 + 1.54 + static bool IsSharedDIBSurface(gfxASurface* aSurface); 1.55 + 1.56 +private: 1.57 + SharedDIBWin mSharedDIB; 1.58 + 1.59 + void InitSurface(uint32_t aWidth, uint32_t aHeight, bool aTransparent); 1.60 +}; 1.61 + 1.62 +} // namespace gfx 1.63 +} // namespace mozilla 1.64 + 1.65 +#endif // mozilla_gfx_SharedDIBSurface_h