2012-07-31 06:54:21 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2010-10-27 08:56:31 +04:00
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-27 08:56:31 +04:00
|
|
|
|
|
|
|
#ifndef __mozilla_widget_nsShmImage_h__
|
|
|
|
#define __mozilla_widget_nsShmImage_h__
|
|
|
|
|
2011-04-03 06:14:00 +04:00
|
|
|
#include "mozilla/ipc/SharedMemorySysV.h"
|
2010-10-27 08:56:31 +04:00
|
|
|
|
|
|
|
#if defined(MOZ_X11) && defined(MOZ_HAVE_SHAREDMEMORYSYSV)
|
|
|
|
# define MOZ_HAVE_SHMIMAGE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_HAVE_SHMIMAGE
|
|
|
|
|
|
|
|
#include "nsIWidget.h"
|
2013-09-25 00:45:14 +04:00
|
|
|
#include "gfxTypes.h"
|
2013-09-25 00:45:13 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2010-10-27 08:56:31 +04:00
|
|
|
|
2012-03-23 03:24:40 +04:00
|
|
|
#include "mozilla/X11Util.h"
|
2010-10-27 08:56:31 +04:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
|
2013-06-04 16:23:29 +04:00
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
2010-10-27 08:56:31 +04:00
|
|
|
#define DISPLAY gdk_x11_get_default_xdisplay
|
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
2012-03-23 03:24:40 +04:00
|
|
|
#define DISPLAY mozilla::DefaultXDisplay
|
2010-10-27 08:56:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
class QRect;
|
2014-02-21 06:08:53 +04:00
|
|
|
class QWindow;
|
2013-09-25 00:45:14 +04:00
|
|
|
class gfxASurface;
|
2010-10-27 08:56:31 +04:00
|
|
|
|
|
|
|
class nsShmImage {
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsShmImage)
|
|
|
|
|
2010-11-05 10:17:07 +03:00
|
|
|
typedef mozilla::ipc::SharedMemorySysV SharedMemorySysV;
|
|
|
|
|
2010-10-27 08:56:31 +04:00
|
|
|
public:
|
2013-09-25 00:45:13 +04:00
|
|
|
typedef gfxImageFormat Format;
|
2010-10-27 08:56:31 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool UseShm();
|
2010-10-27 08:56:31 +04:00
|
|
|
static already_AddRefed<nsShmImage>
|
|
|
|
Create(const gfxIntSize& aSize, Visual* aVisual, unsigned int aDepth);
|
|
|
|
static already_AddRefed<gfxASurface>
|
|
|
|
EnsureShmImage(const gfxIntSize& aSize, Visual* aVisual, unsigned int aDepth,
|
|
|
|
nsRefPtr<nsShmImage>& aImage);
|
|
|
|
|
2014-06-20 15:08:25 +04:00
|
|
|
private:
|
2010-10-27 08:56:31 +04:00
|
|
|
~nsShmImage() {
|
|
|
|
if (mImage) {
|
2012-07-31 06:54:21 +04:00
|
|
|
mozilla::FinishX(DISPLAY());
|
2010-10-27 08:56:31 +04:00
|
|
|
if (mXAttached) {
|
|
|
|
XShmDetach(DISPLAY(), &mInfo);
|
|
|
|
}
|
|
|
|
XDestroyImage(mImage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 15:08:25 +04:00
|
|
|
public:
|
2010-10-27 08:56:31 +04:00
|
|
|
already_AddRefed<gfxASurface> AsSurface();
|
|
|
|
|
2013-06-04 16:23:29 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2010-10-27 08:56:31 +04:00
|
|
|
void Put(GdkWindow* aWindow, GdkRectangle* aRects, GdkRectangle* aEnd);
|
2013-06-04 16:23:29 +04:00
|
|
|
#elif (MOZ_WIDGET_GTK == 3)
|
2011-09-23 00:58:07 +04:00
|
|
|
void Put(GdkWindow* aWindow, cairo_rectangle_list_t* aRects);
|
2010-10-27 08:56:31 +04:00
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
2014-02-21 06:08:53 +04:00
|
|
|
void Put(QWindow* aWindow, QRect& aRect);
|
2010-10-27 08:56:31 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gfxIntSize Size() const { return mSize; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsShmImage()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mImage(nullptr)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mXAttached(false)
|
2010-10-27 08:56:31 +04:00
|
|
|
{ mInfo.shmid = SharedMemorySysV::NULLHandle(); }
|
|
|
|
|
|
|
|
nsRefPtr<SharedMemorySysV> mSegment;
|
|
|
|
XImage* mImage;
|
|
|
|
XShmSegmentInfo mInfo;
|
|
|
|
gfxIntSize mSize;
|
|
|
|
Format mFormat;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mXAttached;
|
2010-10-27 08:56:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOZ_HAVE_SHMIMAGE
|
|
|
|
|
|
|
|
#endif
|