no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / widget / gtk / nsShmImage.h
blob2d92c39e0dc124391fbdf7d141cec363d326fe59
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__
10 #if defined(MOZ_X11)
11 # define MOZ_HAVE_SHMIMAGE
12 #endif
14 #ifdef MOZ_HAVE_SHMIMAGE
16 # include "mozilla/gfx/2D.h"
17 # include "nsIWidget.h"
18 # include "Units.h"
20 # include <X11/Xlib-xcb.h>
21 # include <xcb/shm.h>
23 class nsShmImage {
24 // bug 1168843, compositor thread may create shared memory instances that are
25 // destroyed by main thread on shutdown, so this must use thread-safe RC to
26 // avoid hitting assertion
27 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsShmImage)
29 public:
30 static bool UseShm();
32 already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget(
33 const mozilla::LayoutDeviceIntRegion& aRegion);
35 void Put(const mozilla::LayoutDeviceIntRegion& aRegion);
37 nsShmImage(Display* aDisplay, Drawable aWindow, Visual* aVisual,
38 unsigned int aDepth);
40 private:
41 ~nsShmImage();
43 bool InitExtension();
45 bool CreateShmSegment();
46 void DestroyShmSegment();
48 bool CreateImage(const mozilla::gfx::IntSize& aSize);
49 void DestroyImage();
51 void WaitIfPendingReply();
53 Display* mDisplay;
54 xcb_connection_t* mConnection;
55 Window mWindow;
56 Visual* mVisual;
57 unsigned int mDepth;
59 mozilla::gfx::SurfaceFormat mFormat;
60 mozilla::gfx::IntSize mSize;
61 int mStride;
63 xcb_pixmap_t mPixmap;
64 xcb_gcontext_t mGC;
65 xcb_get_input_focus_cookie_t mSyncRequest;
66 bool mRequestPending;
68 xcb_shm_seg_t mShmSeg;
69 int mShmId;
70 uint8_t* mShmAddr;
73 #endif // MOZ_HAVE_SHMIMAGE
75 #endif