Bug 867104 - Add a crashtest. r=ehsan
[gecko.git] / widget / qt / mozqglwidgetwrapper.cpp
blob0ff74836d68b84636c93c902bea4b8bc7aa7983c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=4 et sw=4 tw=80: */
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 #include "mozqglwidgetwrapper.h"
8 #include <QGraphicsView>
9 #include <QtOpenGL/QGLWidget>
10 #include <QtOpenGL/QGLContext>
12 MozQGLWidgetWrapper::MozQGLWidgetWrapper()
13 : mWidget(new QGLWidget())
17 MozQGLWidgetWrapper::~MozQGLWidgetWrapper()
19 delete mWidget;
22 void MozQGLWidgetWrapper::makeCurrent()
24 mWidget->makeCurrent();
27 void MozQGLWidgetWrapper::setViewport(QGraphicsView* aView)
29 aView->setViewport(mWidget);
32 bool MozQGLWidgetWrapper::hasGLContext(QGraphicsView* aView)
34 return aView && qobject_cast<QGLWidget*>(aView->viewport());
37 bool MozQGLWidgetWrapper::isRGBAContext()
39 QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
40 return context && context->format().alpha();