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__
2016-02-18 18:56:15 +03:00
# if defined(MOZ_X11)
2010-10-27 08:56:31 +04:00
# define MOZ_HAVE_SHMIMAGE
# endif
# ifdef MOZ_HAVE_SHMIMAGE
2015-09-15 23:46:39 +03:00
# include "mozilla/gfx/2D.h"
2010-10-27 08:56:31 +04:00
# include "nsIWidget.h"
2013-09-25 00:45:13 +04:00
# include "nsAutoPtr.h"
2016-02-28 07:16:57 +03:00
# include "Units.h"
2010-10-27 08:56:31 +04:00
# include <X11/Xlib.h>
# include <X11/extensions/XShm.h>
class nsShmImage {
2016-02-25 22:38:05 +03:00
// 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
NS_INLINE_DECL_THREADSAFE_REFCOUNTING ( nsShmImage )
2010-10-27 08:56:31 +04:00
public :
2016-02-25 22:38:05 +03:00
static bool UseShm ( ) ;
already_AddRefed < mozilla : : gfx : : DrawTarget >
CreateDrawTarget ( const mozilla : : LayoutDeviceIntRegion & aRegion ) ;
void Put ( const mozilla : : LayoutDeviceIntRegion & aRegion ) ;
nsShmImage ( Display * aDisplay ,
Drawable aWindow ,
Visual * aVisual ,
2016-02-28 07:16:57 +03:00
unsigned int aDepth ) ;
2010-10-27 08:56:31 +04:00
private :
2016-02-28 07:16:57 +03:00
~ nsShmImage ( ) ;
bool InitExtension ( ) ;
2016-02-25 22:38:05 +03:00
bool CreateShmSegment ( ) ;
void DestroyShmSegment ( ) ;
bool CreateImage ( const mozilla : : gfx : : IntSize & aSize ) ;
void DestroyImage ( ) ;
2016-02-28 07:16:57 +03:00
static Bool FindEvent ( Display * aDisplay , XEvent * aEvent , XPointer aArg ) ;
bool RequestWasProcessed ( ) ;
2016-02-28 07:16:57 +03:00
void WaitForRequest ( ) ;
2016-02-28 07:16:57 +03:00
void SendEvent ( ) ;
2016-02-28 07:16:57 +03:00
2016-02-25 22:38:05 +03:00
XImage * mImage ;
Display * mDisplay ;
2016-02-28 07:16:57 +03:00
Window mWindow ;
2016-02-25 22:38:05 +03:00
Visual * mVisual ;
unsigned int mDepth ;
XShmSegmentInfo mInfo ;
mozilla : : gfx : : SurfaceFormat mFormat ;
2016-02-28 07:16:57 +03:00
Pixmap mPixmap ;
GC mGC ;
2016-02-28 07:16:57 +03:00
unsigned long mRequest ;
2016-02-28 07:16:57 +03:00
unsigned long mPreviousRequestProcessed ;
2010-10-27 08:56:31 +04:00
} ;
# endif // MOZ_HAVE_SHMIMAGE
# endif