LCOV - code coverage report
Current view: top level - widget - nsShmImage.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  *
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef __mozilla_widget_nsShmImage_h__
       8             : #define __mozilla_widget_nsShmImage_h__
       9             : 
      10             : #if defined(MOZ_X11)
      11             : #  define MOZ_HAVE_SHMIMAGE
      12             : #endif
      13             : 
      14             : #ifdef MOZ_HAVE_SHMIMAGE
      15             : 
      16             : #include "mozilla/gfx/2D.h"
      17             : #include "nsIWidget.h"
      18             : #include "Units.h"
      19             : 
      20             : #include <X11/Xlib-xcb.h>
      21             : #include <xcb/shm.h>
      22             : 
      23             : class nsShmImage {
      24             :   // bug 1168843, compositor thread may create shared memory instances that are destroyed by main thread on shutdown, so this must use thread-safe RC to avoid hitting assertion
      25           2 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsShmImage)
      26             : 
      27             : public:
      28             :   static bool UseShm();
      29             : 
      30             :   already_AddRefed<mozilla::gfx::DrawTarget>
      31             :     CreateDrawTarget(const mozilla::LayoutDeviceIntRegion& aRegion);
      32             : 
      33             :   void Put(const mozilla::LayoutDeviceIntRegion& aRegion);
      34             : 
      35             :   nsShmImage(Display* aDisplay,
      36             :              Drawable aWindow,
      37             :              Visual* aVisual,
      38             :              unsigned int aDepth);
      39             : 
      40             : private:
      41             :   ~nsShmImage();
      42             : 
      43             :   bool InitExtension();
      44             : 
      45             :   bool CreateShmSegment();
      46             :   void DestroyShmSegment();
      47             : 
      48             :   bool CreateImage(const mozilla::gfx::IntSize& aSize);
      49             :   void DestroyImage();
      50             : 
      51             :   void WaitIfPendingReply();
      52             : 
      53             :   Display*                     mDisplay;
      54             :   xcb_connection_t*            mConnection;
      55             :   Window                       mWindow;
      56             :   Visual*                      mVisual;
      57             :   unsigned int                 mDepth;
      58             : 
      59             :   mozilla::gfx::SurfaceFormat  mFormat;
      60             :   mozilla::gfx::IntSize        mSize;
      61             :   int                          mStride;
      62             : 
      63             :   xcb_pixmap_t                 mPixmap;
      64             :   xcb_gcontext_t               mGC;
      65             :   xcb_get_input_focus_cookie_t mSyncRequest;
      66             :   bool                         mRequestPending;
      67             : 
      68             :   xcb_shm_seg_t                mShmSeg;
      69             :   int                          mShmId;
      70             :   uint8_t*                     mShmAddr;
      71             : };
      72             : 
      73             : #endif // MOZ_HAVE_SHMIMAGE
      74             : 
      75             : #endif

Generated by: LCOV version 1.13