1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef __mozilla_widget_nsShmImage_h__
8 #define __mozilla_widget_nsShmImage_h__
11 # define MOZ_HAVE_SHMIMAGE
14 #ifdef MOZ_HAVE_SHMIMAGE
16 #include "mozilla/gfx/2D.h"
17 #include "nsIWidget.h"
20 #include <X11/Xlib-xcb.h>
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 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsShmImage
)
30 already_AddRefed
<mozilla::gfx::DrawTarget
>
31 CreateDrawTarget(const mozilla::LayoutDeviceIntRegion
& aRegion
);
33 void Put(const mozilla::LayoutDeviceIntRegion
& aRegion
);
35 nsShmImage(Display
* aDisplay
,
45 bool CreateShmSegment();
46 void DestroyShmSegment();
48 bool CreateImage(const mozilla::gfx::IntSize
& aSize
);
51 void WaitIfPendingReply();
54 xcb_connection_t
* mConnection
;
59 mozilla::gfx::SurfaceFormat mFormat
;
60 mozilla::gfx::IntSize mSize
;
65 xcb_get_input_focus_cookie_t mSyncRequest
;
68 xcb_shm_seg_t mShmSeg
;
73 #endif // MOZ_HAVE_SHMIMAGE