gfx/ipc/SharedDIBSurface.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_gfx_SharedDIBSurface_h
     7 #define mozilla_gfx_SharedDIBSurface_h
     9 #include "gfxImageSurface.h"
    10 #include "SharedDIBWin.h"
    12 #include <windows.h>
    14 namespace mozilla {
    15 namespace gfx {
    17 /**
    18  * A SharedDIBSurface owns an underlying SharedDIBWin.
    19  */
    20 class SharedDIBSurface : public gfxImageSurface
    21 {
    22 public:
    23   typedef base::SharedMemoryHandle Handle;
    25   SharedDIBSurface() { }
    26   ~SharedDIBSurface() { }
    28   /**
    29    * Create this image surface backed by shared memory.
    30    */
    31   bool Create(HDC adc, uint32_t aWidth, uint32_t aHeight, bool aTransparent);
    33   /**
    34    * Attach this surface to shared memory from another process.
    35    */
    36   bool Attach(Handle aHandle, uint32_t aWidth, uint32_t aHeight,
    37               bool aTransparent);
    39   /**
    40    * After drawing to a surface via GDI, GDI must be flushed before the bitmap
    41    * is valid.
    42    */
    43   void Flush() { ::GdiFlush(); }
    45   HDC GetHDC() { return mSharedDIB.GetHDC(); }
    47   nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) {
    48     return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle);
    49   }
    51   static bool IsSharedDIBSurface(gfxASurface* aSurface);
    53 private:
    54   SharedDIBWin mSharedDIB;
    56   void InitSurface(uint32_t aWidth, uint32_t aHeight, bool aTransparent);
    57 };
    59 } // namespace gfx
    60 } // namespace mozilla
    62 #endif // mozilla_gfx_SharedDIBSurface_h

mercurial