Bug 677712 - Make Qt port support No X11 build; r=dougt,joe

--HG--
rename : dom/plugins/ipc/NPEventX11.h => dom/plugins/ipc/NPEventUnix.h
This commit is contained in:
Oleg Romashin 2011-08-24 17:15:58 +01:00
Родитель b74d644cd3
Коммит dae581c361
19 изменённых файлов: 120 добавлений и 98 удалений

Просмотреть файл

@ -5113,7 +5113,7 @@ then
PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
else
MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtDBus -lQtXml -lQtOpenGL"
MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
MOZ_QT_CFLAGS="-DQT_SHARED"
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
@ -5121,7 +5121,6 @@ then
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDBus"
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
HOST_MOC="$QTDIR/bin/moc"
fi

Просмотреть файл

@ -2010,7 +2010,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
switch(variable) {
#if defined(XP_UNIX) && !defined(XP_MACOSX)
case NPNVxDisplay : {
#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)
#if defined(MOZ_X11)
if (npp) {
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
PRBool windowless = PR_FALSE;

Просмотреть файл

@ -83,8 +83,10 @@ class gfxXlibSurface;
#endif
#ifdef MOZ_WIDGET_QT
#ifdef MOZ_X11
#include "gfxQtNativeRenderer.h"
#endif
#endif
#ifdef XP_OS2
#define INCL_PM

Просмотреть файл

@ -77,10 +77,12 @@ nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow()
ws_info = &mWsInfo;
type = NPWindowTypeWindow;
mWsInfo.type = 0;
#if defined(MOZ_X11)
mWsInfo.display = nsnull;
mWsInfo.visual = nsnull;
mWsInfo.colormap = 0;
mWsInfo.depth = 0;
#endif
}
nsPluginNativeWindowQt::~nsPluginNativeWindowQt()

Просмотреть файл

@ -59,7 +59,7 @@ EXPORTS_mozilla/plugins = \
ChildTimer.h \
NPEventOSX.h \
NPEventWindows.h \
NPEventX11.h \
NPEventUnix.h \
NPEventAndroid.h \
PluginIdentifierChild.h \
PluginIdentifierParent.h \

Просмотреть файл

@ -37,12 +37,14 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_plugins_NPEventX11_h
#define mozilla_dom_plugins_NPEventX11_h 1
#ifndef mozilla_dom_plugins_NPEventUnix_h
#define mozilla_dom_plugins_NPEventUnix_h 1
#include "npapi.h"
#ifdef MOZ_X11
#include "mozilla/X11Util.h"
#endif
namespace mozilla {
@ -95,7 +97,10 @@ struct ParamTraits<mozilla::plugins::NPRemoteEvent> // synonym for XEvent
}
memcpy(aResult, bytes, sizeof(paramType));
#ifdef MOZ_X11
SetXDisplay(aResult->event);
#endif
return true;
}
@ -105,6 +110,7 @@ struct ParamTraits<mozilla::plugins::NPRemoteEvent> // synonym for XEvent
aLog->append(L"(XEvent)");
}
#ifdef MOZ_X11
private:
static void SetXDisplay(XEvent& ev)
{
@ -118,6 +124,7 @@ private:
ev.xerror.display = display;
}
}
#endif
};
} // namespace IPC

Просмотреть файл

@ -1092,6 +1092,8 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
#elif defined(ANDROID)
# warning Need Android impl
#elif defined(MOZ_WIDGET_QT)
# warning Need QT-nonX impl
#else
# error Implement me for your OS
#endif
@ -2389,6 +2391,7 @@ PluginInstanceChild::CreateOptSurface(void)
(mIsTransparent && !mBackground) ? gfxASurface::ImageFormatARGB32 :
gfxASurface::ImageFormatRGB24;
#ifdef MOZ_X11
#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
// On Maemo 5, we must send the Visibility event to activate the plugin
if (mMaemoImageRendering) {
@ -2400,7 +2403,6 @@ PluginInstanceChild::CreateOptSurface(void)
mPluginIface->event(&mData, reinterpret_cast<void*>(&pluginEvent));
}
#endif
#ifdef MOZ_X11
Display* dpy = mWsInfo.display;
Screen* screen = DefaultScreenOfDisplay(dpy);
if (format == gfxASurface::ImageFormatRGB24 &&

Просмотреть файл

@ -274,6 +274,9 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle*
#elif defined(ANDROID)
#warning Need Android impl
int id;
#elif defined(MOZ_WIDGET_QT)
# warning Need Qt non X impl
int id;
#else
#warning Implement me
#endif

Просмотреть файл

@ -130,7 +130,7 @@ struct NPRemoteWindow
typedef HWND NativeWindowHandle;
#elif defined(MOZ_X11)
typedef XID NativeWindowHandle;
#elif defined(XP_MACOSX) || defined(ANDROID)
#elif defined(XP_MACOSX) || defined(ANDROID) || defined(MOZ_WIDGET_QT)
typedef intptr_t NativeWindowHandle; // never actually used, will always be 0
#else
#error Need NativeWindowHandle for this platform
@ -887,10 +887,10 @@ struct ParamTraits<NPCoordinateSpace>
# include "mozilla/plugins/NPEventWindows.h"
#elif defined(XP_OS2)
# error Sorry, OS/2 is not supported
#elif defined(XP_UNIX) && defined(MOZ_X11)
# include "mozilla/plugins/NPEventX11.h"
#elif defined(ANDROID)
# include "mozilla/plugins/NPEventAndroid.h"
#elif defined(XP_UNIX)
# include "mozilla/plugins/NPEventUnix.h"
#else
# error Unsupported platform
#endif

Просмотреть файл

@ -110,6 +110,7 @@ pluginDrawWindow(InstanceData* instanceData, void* event)
int width = window.width;
int height = window.height;
#ifdef MOZ_X11
XEvent* nsEvent = (XEvent*)event;
const XGraphicsExposeEvent& expose = nsEvent->xgraphicsexpose;
@ -126,6 +127,7 @@ pluginDrawWindow(InstanceData* instanceData, void* event)
return;
}
#endif
NPP npp = instanceData->npp;
if (!npp)
@ -135,6 +137,7 @@ pluginDrawWindow(InstanceData* instanceData, void* event)
if (text.isEmpty())
return;
#ifdef MOZ_X11
//printf("Drawing Default\n");
// drawing a solid color for reftests
QColor color;
@ -147,6 +150,7 @@ pluginDrawWindow(InstanceData* instanceData, void* event)
painter.drawRect(theRect);
painter.drawText(QRect(theRect), Qt::AlignCenter, text);
notifyDidPaint(instanceData);
#endif
return;
}

Просмотреть файл

@ -39,43 +39,40 @@
*
* ***** END LICENSE BLOCK ***** */
#if defined(MOZ_X11)
#if defined(XP_UNIX)
#ifdef MOZ_WIDGET_GTK2
#include <gdk/gdkx.h>
// we're using default display for now
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW))
#elif defined(MOZ_WIDGET_QT)
#include <QWidget>
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/QGLContext>
#define GLdouble_defined 1
// we're using default display for now
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->handle()
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
#endif
#if defined(MOZ_X11)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "mozilla/X11Util.h"
#include "gfxXlibSurface.h"
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#define EGL_LIB "/usr/lib/libEGL.so"
#define GLES2_LIB "/usr/lib/libGLESv2.so"
#elif defined(ANDROID)
#endif
#if defined(ANDROID)
/* from widget */
#include "AndroidBridge.h"
#define EGL_LIB "/system/lib/libEGL.so"
#define GLES2_LIB "/system/lib/libGLESv2.so"
#else
#define EGL_LIB "/usr/lib/libEGL.so"
#define GLES2_LIB "/usr/lib/libGLESv2.so"
#endif
typedef void *EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#define EGL_LIB "/system/lib/libEGL.so"
#define GLES2_LIB "/system/lib/libGLESv2.so"
#elif defined(XP_WIN)
#include "mozilla/Preferences.h"
@ -665,7 +662,7 @@ public:
: GLContext(aFormat, aIsOffscreen, aShareContext)
, mConfig(aConfig)
, mSurface(aSurface), mContext(aContext)
, mGLWidget(nsnull)
, mPlatformContext(nsnull)
, mThebesSurface(nsnull)
, mBound(PR_FALSE)
, mIsPBuffer(PR_FALSE)
@ -687,7 +684,7 @@ public:
// If mGLWidget is non-null, then we've been given it by the GL context provider,
// and it's managed by the widget implementation. In this case, We can't destroy
// our contexts.
if (mGLWidget)
if (mPlatformContext)
return;
#ifdef DEBUG
@ -786,23 +783,15 @@ public:
// where MakeCurrent with an already-current context is
// still expensive.
if (!mSurface || aForce || sEGLLibrary.fGetCurrentContext() != mContext) {
if (mGLWidget) {
#ifdef MOZ_WIDGET_QT
static_cast<QGLWidget*>(mGLWidget)->makeCurrent();
#else
succeeded = PR_FALSE;
#endif
} else {
#ifndef MOZ_WIDGET_QT
if (!mSurface) {
EGLConfig config = CreateConfig();
mSurface = CreateSurfaceForWindow(NULL, config);
}
#endif
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
mSurface, mSurface,
mContext);
if (!mSurface) {
EGLConfig config = CreateConfig();
mSurface = CreateSurfaceForWindow(NULL, config);
}
#endif
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
mSurface, mSurface,
mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
}
@ -883,8 +872,8 @@ public:
mThebesSurface = aSurf;
}
void SetQtGLWidget(void *widget) {
mGLWidget = widget;
void SetPlatformContext(void *context) {
mPlatformContext = context;
}
EGLContext Context() {
@ -946,7 +935,7 @@ protected:
EGLConfig mConfig;
EGLSurface mSurface;
EGLContext mContext;
void *mGLWidget;
void *mPlatformContext;
nsRefPtr<gfxASurface> mThebesSurface;
PRBool mBound;
@ -1096,7 +1085,7 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
if (xsurface->CairoStatus() != 0) {
return PR_FALSE;
}
pixmap = xsurface->XDrawable();
pixmap = (EGLNativePixmapType)xsurface->XDrawable();
if (!pixmap) {
return PR_FALSE;
}
@ -1728,15 +1717,12 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
return nsnull;
}
QWidget *viewport = static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
if (!viewport)
return nsnull;
if (viewport->paintEngine()->type() == QPaintEngine::OpenGL2) {
QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
if (context && context->device()) {
// Qt widget viewport already have GL context created by Qt
// Create dummy GLContextEGL class
nsRefPtr<GLContextEGL> glContext =
new GLContextEGL(ContextFormat(DepthToGLFormat(viewport->depth())),
new GLContextEGL(ContextFormat(DepthToGLFormat(context->device()->depth())),
NULL,
NULL, NULL,
sEGLLibrary.fGetCurrentContext(),
@ -1745,9 +1731,9 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
if (!glContext->Init())
return nsnull;
glContext->SetIsDoubleBuffered(PR_TRUE);
glContext->SetIsDoubleBuffered(context->format().doubleBuffer());
glContext->SetQtGLWidget(viewport);
glContext->SetPlatformContext(context);
return glContext.forget();
}
@ -1755,7 +1741,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
// All Qt nsIWidget's have the same X-Window surface
// And EGL not allowing to create multiple GL context for the same window
// we should be able to create GL context for QGV viewport once, and reuse it for all child widgets
NS_ERROR("Need special GLContext implementation for QT widgets structure");
NS_ERROR("Failed to get QGLContext");
// Switch to software rendering here
return nsnull;
@ -2081,11 +2067,11 @@ CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig, EGLenum a
if (aConfig && *aConfig) {
if (opaque)
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
xsurface->XDrawable(),
(EGLNativePixmapType)xsurface->XDrawable(),
pixmap_config_rgb);
else
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
xsurface->XDrawable(),
(EGLNativePixmapType)xsurface->XDrawable(),
pixmap_config_rgba);
if (surface != EGL_NO_SURFACE)
@ -2124,11 +2110,11 @@ CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig, EGLenum a
for (i = 0; i < numConfigs; ++i) {
if (opaque)
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
xsurface->XDrawable(),
(EGLNativePixmapType)xsurface->XDrawable(),
pixmap_config_rgb);
else
surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
xsurface->XDrawable(),
(EGLNativePixmapType)xsurface->XDrawable(),
pixmap_config_rgba);
if (surface != EGL_NO_SURFACE)
@ -2167,7 +2153,7 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& aSize,
return nsnull;
thebesSurface = xsurface;
pixmap = xsurface->XDrawable();
pixmap = (EGLNativePixmapType)xsurface->XDrawable();
#endif
if (!pixmap) {

Просмотреть файл

@ -290,7 +290,9 @@ endif
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += gfxQtPlatform.cpp gfxQPainterSurface.cpp
ifdef MOZ_X11
CPPSRCS += gfxXlibSurface.cpp gfxQtNativeRenderer.cpp
endif
ifdef MOZ_PANGO
CPPSRCS += gfxPangoFonts.cpp
else

Просмотреть файл

@ -82,7 +82,7 @@ using namespace mozilla;
#define DEFAULT_RENDER_MODE RENDER_DIRECT
static QPaintEngine::Type sDefaultQtPaintEngineType = QPaintEngine::X11;
static QPaintEngine::Type sDefaultQtPaintEngineType = QPaintEngine::Raster;
gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nsnull;
static cairo_user_data_key_t cairo_qt_pixmap_key;
static void do_qt_pixmap_unref (void *data)
@ -149,7 +149,10 @@ gfxQtPlatform::gfxQtPlatform()
// Qt doesn't provide a public API to detect the graphicssystem type. We hack
// around this by checking what type of graphicssystem a test QPixmap uses.
QPixmap pixmap(1, 1);
sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
#if (QT_VERSION < QT_VERSION_CHECK(4,8,0))
if (pixmap.paintEngine())
sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
#endif
}
gfxQtPlatform::~gfxQtPlatform()
@ -583,7 +586,7 @@ gfxQtPlatform::GetDPI()
gfxImageFormat
gfxQtPlatform::GetOffscreenFormat()
{
if (QX11Info::appDepth() == 16) {
if (qApp->desktop()->depth() == 16) {
return gfxASurface::ImageFormatRGB16_565;
}

Просмотреть файл

@ -124,5 +124,5 @@ LOCAL_INCLUDES += \
$(NULL)
ifdef MOZ_X11
INCLUDES += -I$(srcdir)/../shared/x11
INCLUDES += -I$(srcdir)/../shared
endif
INCLUDES += -I$(srcdir)/../shared

Просмотреть файл

@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
#include <QX11Info>
#endif
@ -46,7 +46,7 @@
#include "nsDebug.h"
#include "prlink.h"
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
typedef PRBool (*_XScreenSaverQueryExtension_fn)(Display* dpy, int* event_base,
int* error_base);
@ -65,7 +65,7 @@ static PRBool sInitialized = PR_FALSE;
NS_IMPL_ISUPPORTS2(nsIdleServiceQt, nsIIdleService, nsIdleService)
nsIdleServiceQt::nsIdleServiceQt()
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
: mXssInfo(nsnull)
#endif
{
@ -75,7 +75,7 @@ static void Initialize()
{
sInitialized = PR_TRUE;
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
// This will leak - See comments in ~nsIdleServiceQt().
PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1");
if (!xsslib) {
@ -93,7 +93,7 @@ static void Initialize()
nsIdleServiceQt::~nsIdleServiceQt()
{
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
if (mXssInfo)
XFree(mXssInfo);
@ -112,7 +112,7 @@ nsIdleServiceQt::~nsIdleServiceQt()
bool
nsIdleServiceQt::PollIdleTime(PRUint32 *aIdleTime)
{
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
// Ask xscreensaver about idle time:
*aIdleTime = 0;
@ -148,7 +148,7 @@ nsIdleServiceQt::PollIdleTime(PRUint32 *aIdleTime)
bool
nsIdleServiceQt::UsePollMode()
{
#ifdef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
return false;
#endif
return true;

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsIdleService.h"
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -66,7 +66,7 @@ public:
private:
~nsIdleServiceQt();
#ifndef MOZ_PLATFORM_MAEMO
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
XScreenSaverInfo* mXssInfo;
#endif

Просмотреть файл

@ -135,5 +135,9 @@ Qt::HANDLE
nsToolkit::GetSharedGC(void)
{
// FIXME Not sure
#ifdef MOZ_X11
return mSharedGC->handle();
#else
return 0;
#endif
}

Просмотреть файл

@ -112,7 +112,9 @@ using namespace QtMobility;
#include "nsAutoPtr.h"
#include "gfxQtPlatform.h"
#ifdef MOZ_X11
#include "gfxXlibSurface.h"
#endif
#include "gfxQPainterSurface.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
@ -130,6 +132,7 @@ using namespace QtMobility;
#endif //MOZ_X11
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/QGLContext>
#define GLdouble_defined 1
#include "Layers.h"
#include "LayerManagerOGL.h"
@ -793,8 +796,12 @@ nsWindow::GetNativeData(PRUint32 aDataType)
case NS_NATIVE_DISPLAY:
{
#ifdef MOZ_X11
QWidget *widget = GetViewWidget();
return widget ? widget->x11Info().display() : nsnull;
#else
return nsnull;
#endif
}
break;
@ -1135,6 +1142,7 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
// Handle buffered painting mode
if (renderMode == gfxQtPlatform::RENDER_BUFFERED) {
#ifdef MOZ_X11
if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
// Paint offscreen pixmap to QPainter
static QPixmap gBufferPixmap;
@ -1145,7 +1153,9 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
aPainter->drawPixmap(QPoint(rect.x, rect.y), gBufferPixmap,
QRect(0, 0, rect.width, rect.height));
} else if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
} else
#endif
if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
// in raster mode we can just wrap gBufferImage as QImage and paint directly
gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
QImage img(imgs->Data(),
@ -1158,6 +1168,7 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
}
} else if (renderMode == gfxQtPlatform::RENDER_DIRECT) {
QRect trans = aPainter->transform().mapRect(r).toRect();
#ifdef MOZ_X11
if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
nsRefPtr<gfxASurface> widgetSurface = GetSurfaceForQWidget(aWidget);
nsRefPtr<gfxContext> ctx = new gfxContext(widgetSurface);
@ -1165,19 +1176,23 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, Q
ctx->Rectangle(gfxRect(trans.x(), trans.y(), trans.width(), trans.height()), PR_TRUE);
ctx->Clip();
ctx->Fill();
} else if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
} else
#endif
if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
#ifdef MOZ_HAVE_SHMIMAGE
if (gShmImage) {
gShmImage->Put(aWidget, trans);
} else
#endif
if (gBufferSurface) {
nsRefPtr<gfxASurface> widgetSurface = GetSurfaceForQWidget(aWidget);
nsRefPtr<gfxContext> ctx = new gfxContext(widgetSurface);
ctx->SetSource(gBufferSurface);
ctx->Rectangle(gfxRect(trans.x(), trans.y(), trans.width(), trans.height()), PR_TRUE);
ctx->Clip();
ctx->Fill();
{
// Qt should take care about optimized rendering on QImage into painter device (gl/fb/image et.c.)
gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
QImage img(imgs->Data(),
imgs->Width(),
imgs->Height(),
imgs->Stride(),
_gfximage_to_qformat(imgs->Format()));
aPainter->drawImage(trans, img, trans);
}
}
}
@ -1663,7 +1678,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
return DispatchContentCommandEvent(NS_CONTENT_COMMAND_UNDO);
}
#ifdef MOZ_X11
// Qt::Key_Redo and Qt::Key_Undo are not available yet.
if (aEvent->nativeVirtualKey() == 0xff66) {
return DispatchContentCommandEvent(NS_CONTENT_COMMAND_REDO);
@ -1671,7 +1685,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
if (aEvent->nativeVirtualKey() == 0xff65) {
return DispatchContentCommandEvent(NS_CONTENT_COMMAND_UNDO);
}
#endif // MOZ_X11
nsKeyEvent event(PR_TRUE, NS_KEY_PRESS, this);
InitKeyEvent(event, aEvent);
@ -1867,7 +1880,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
// send the key press event
return DispatchEvent(&event);
}
#endif
}
@ -2302,6 +2314,7 @@ nsWindow::SetWindowClass(const nsAString &xulWinType)
nsXPIDLString brandName;
GetBrandName(brandName);
#ifdef MOZ_X11
XClassHint *class_hint = XAllocClassHint();
if (!class_hint)
return NS_ERROR_OUT_OF_MEMORY;
@ -2343,6 +2356,7 @@ nsWindow::SetWindowClass(const nsAString &xulWinType)
nsMemory::Free(class_hint->res_class);
nsMemory::Free(class_hint->res_name);
XFree(class_hint);
#endif
return NS_OK;
}
@ -2525,7 +2539,9 @@ nsWindow::HideWindowChrome(PRBool aShouldHide)
// and GetWindowPos is called)
QWidget *widget = GetViewWidget();
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
#ifdef MOZ_X11
XSync(widget->x11Info().display(), False);
#endif
return NS_OK;
}
@ -2664,13 +2680,17 @@ nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData)
newView->setWindowModality(Qt::WindowModal);
}
if (!IsAcceleratedQView(newView) && GetShouldAccelerate()) {
#ifdef MOZ_PLATFORM_MAEMO
if (GetShouldAccelerate()) {
newView->setViewport(new QGLWidget());
}
#endif
if (gfxQtPlatform::GetPlatform()->GetRenderMode() == gfxQtPlatform::RENDER_DIRECT) {
// Disable double buffer and system background rendering
#ifdef MOZ_X11
newView->viewport()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
newView->viewport()->setAttribute(Qt::WA_NoSystemBackground, true);
}
// Enable gestures:
@ -2712,16 +2732,6 @@ nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData)
return widget;
}
PRBool
nsWindow::IsAcceleratedQView(QGraphicsView *view)
{
if (view && view->viewport()) {
QPaintEngine::Type type = view->viewport()->paintEngine()->type();
return (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2);
}
return PR_FALSE;
}
// return the gfxASurface for rendering to this widget
gfxASurface*
nsWindow::GetThebesSurface()

Просмотреть файл

@ -349,8 +349,6 @@ private:
nsEventStatus DispatchContentCommandEvent(PRInt32 aMsg);
MozQWidget* createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData);
PRBool IsAcceleratedQView(QGraphicsView* aView);
MozQWidget* mWidget;
PRUint32 mIsVisible : 1,