1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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 #include "mozilla/ipc/SharedMemorySysV.h"
12 #if defined(MOZ_X11) && defined(MOZ_HAVE_SHAREDMEMORYSYSV)
13 # define MOZ_HAVE_SHMIMAGE
16 #ifdef MOZ_HAVE_SHMIMAGE
18 #include "nsIWidget.h"
20 #include "nsAutoPtr.h"
22 #include "mozilla/X11Util.h"
24 #include <X11/Xutil.h>
25 #include <X11/extensions/XShm.h>
27 #if defined(MOZ_WIDGET_GTK)
28 #define DISPLAY gdk_x11_get_default_xdisplay
29 #elif defined(MOZ_WIDGET_QT)
30 #define DISPLAY mozilla::DefaultXDisplay
38 NS_INLINE_DECL_REFCOUNTING(nsShmImage
)
40 typedef mozilla::ipc::SharedMemorySysV SharedMemorySysV
;
43 typedef gfxImageFormat Format
;
46 static already_AddRefed
<nsShmImage
>
47 Create(const gfxIntSize
& aSize
, Visual
* aVisual
, unsigned int aDepth
);
48 static already_AddRefed
<gfxASurface
>
49 EnsureShmImage(const gfxIntSize
& aSize
, Visual
* aVisual
, unsigned int aDepth
,
50 nsRefPtr
<nsShmImage
>& aImage
);
55 mozilla::FinishX(DISPLAY());
57 XShmDetach(DISPLAY(), &mInfo
);
59 XDestroyImage(mImage
);
64 already_AddRefed
<gfxASurface
> AsSurface();
66 #if (MOZ_WIDGET_GTK == 2)
67 void Put(GdkWindow
* aWindow
, GdkRectangle
* aRects
, GdkRectangle
* aEnd
);
68 #elif (MOZ_WIDGET_GTK == 3)
69 void Put(GdkWindow
* aWindow
, cairo_rectangle_list_t
* aRects
);
70 #elif defined(MOZ_WIDGET_QT)
71 void Put(QWindow
* aWindow
, QRect
& aRect
);
74 gfxIntSize
Size() const { return mSize
; }
80 { mInfo
.shmid
= SharedMemorySysV::NULLHandle(); }
82 nsRefPtr
<SharedMemorySysV
> mSegment
;
84 XShmSegmentInfo mInfo
;
90 #endif // MOZ_HAVE_SHMIMAGE