Bug 779726 - Move QGL includes into isolated wrapper class, and fix qgl.h and GLDefs.h conflicts. r=dougt

--HG--
extra : rebase_source : 02dee7a407a23efb7ce5a2caef0c61fbfb00a7c2
This commit is contained in:
Oleg Romashin 2012-08-16 11:31:47 -04:00
Родитель d3ca4efc0f
Коммит 2656deaadb
6 изменённых файлов: 93 добавлений и 20 удалений

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

@ -54,6 +54,7 @@ CPPSRCS += \
nsPrintSettingsQt.cpp \
nsPrintDialogQt.cpp \
nsDeviceContextSpecQt.cpp \
mozqglwidgetwrapper.cpp \
$(NULL)
EXPORTS = \

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

@ -21,10 +21,20 @@ EXTRA_DSO_LDOPTS = \
$(MOZ_QT_LIBS) \
$(NULL)
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
LOCAL_INCLUDES += \
-I$(topsrcdir)/xpcom/build \
-I$(topsrcdir)/widget/qt \
$(NULL)
GARBAGE += moziqwidget.h nsQAppInstance.h nsQAppInstance.cpp
export:: $(topsrcdir)/widget/qt/moziqwidget.h $(topsrcdir)/toolkit/xre/nsQAppInstance.h $(topsrcdir)/toolkit/xre/nsQAppInstance.cpp
EXPORT_SOURCES = \
$(topsrcdir)/widget/qt/moziqwidget.h \
$(topsrcdir)/toolkit/xre/nsQAppInstance.h \
$(topsrcdir)/toolkit/xre/nsQAppInstance.cpp \
$(topsrcdir)/widget/qt/mozqglwidgetwrapper.h \
$(topsrcdir)/widget/qt/mozqglwidgetwrapper.cpp
GARBAGE += $(EXPORT_SOURCES)
export:: $(EXPORT_SOURCES)
$(INSTALL) $^ .
MOCSRCS = \

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

@ -10,7 +10,7 @@
#include <QApplication>
#include <QGraphicsWidget>
#include <QGraphicsView>
#include <QtOpenGL/QGLWidget>
#include "mozqglwidgetwrapper.h"
#include "nsCOMPtr.h"
@ -134,8 +134,8 @@ public:
void setGLWidgetEnabled(bool aEnabled)
{
if (aEnabled) {
mGLWidget = new QGLWidget();
setViewport(mGLWidget);
mGLWidget = new MozQGLWidgetWrapper();
mGLWidget->setViewport(this);
} else {
delete mGLWidget;
mGLWidget = 0;
@ -174,7 +174,7 @@ protected:
private:
MozQGraphicsViewEvents mEventHandler;
IMozQWidget* mTopLevelWidget;
QGLWidget* mGLWidget;
MozQGLWidgetWrapper* mGLWidget;
};
#ifdef MOZ_ENABLE_MEEGOTOUCH

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

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* 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/. */
#include "mozqglwidgetwrapper.h"
#include <QGraphicsView>
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/QGLContext>
MozQGLWidgetWrapper::MozQGLWidgetWrapper()
: mWidget(new QGLWidget())
{
}
MozQGLWidgetWrapper::~MozQGLWidgetWrapper()
{
delete mWidget;
}
void MozQGLWidgetWrapper::makeCurrent()
{
mWidget->makeCurrent();
}
void MozQGLWidgetWrapper::setViewport(QGraphicsView* aView)
{
aView->setViewport(mWidget);
}
bool MozQGLWidgetWrapper::hasGLContext(QGraphicsView* aView)
{
return aView && qobject_cast<QGLWidget*>(aView->viewport());
}
bool MozQGLWidgetWrapper::isRGBAContext()
{
QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
return context && context->format().alpha();
}

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

@ -0,0 +1,30 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* 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/. */
#ifndef MOZQGLWIDGETWRAPPER_H
#define MOZQGLWIDGETWRAPPER_H
/*
* qgl.h and GLDefs.h has conflicts in type defines
* QGLWidget wrapper class helps to avoid including qgl.h with mozilla gl includes
*/
class QGLWidget;
class QGraphicsView;
class MozQGLWidgetWrapper
{
public:
MozQGLWidgetWrapper();
~MozQGLWidgetWrapper();
void makeCurrent();
void setViewport(QGraphicsView*);
static bool hasGLContext(QGraphicsView*);
static bool isRGBAContext();
private:
QGLWidget* mWidget;
};
#endif

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

@ -6,12 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Util.h"
#include "BasicLayers.h"
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/QGLContext>
// Solve conflict of qgl.h and GLDefs.h
#define GLdouble_defined 1
#include <QApplication>
#include <QDesktopWidget>
#include <QtGui/QCursor>
@ -27,6 +22,7 @@
#include <QStyleOptionGraphicsItem>
#include <QPaintEngine>
#include <QMimeData>
#include "mozqglwidgetwrapper.h"
#include <QtCore/QDebug>
#include <QtCore/QEvent>
@ -106,6 +102,7 @@ static Atom sPluginIMEAtom = nullptr;
#endif //MOZ_X11
#include "Layers.h"
#include "BasicLayers.h"
#include "LayerManagerOGL.h"
#include "nsFastStartupQt.h"
@ -2581,8 +2578,7 @@ nsPopupWindow::~nsPopupWindow()
NS_IMETHODIMP_(bool)
nsWindow::HasGLContext()
{
QGraphicsView *view = qobject_cast<QGraphicsView*>(GetViewWidget());
return view && qobject_cast<QGLWidget*>(view->viewport());
return MozQGLWidgetWrapper::hasGLContext(qobject_cast<QGraphicsView*>(GetViewWidget()));
}
MozQWidget*
@ -3272,12 +3268,7 @@ nsWindow::GetGLFrameBufferFormat()
{
if (mLayerManager &&
mLayerManager->GetBackendType() == mozilla::layers::LAYERS_OPENGL) {
// On maemo the hardware fb has RGB format.
#ifdef MOZ_PLATFORM_MAEMO
return LOCAL_GL_RGB;
#else
return LOCAL_GL_RGBA;
#endif
return MozQGLWidgetWrapper::isRGBAContext() ? LOCAL_GL_RGBA : LOCAL_GL_RGB;
}
return LOCAL_GL_NONE;
}