Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qgl_egl.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtOpenGL module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4141
    4242#include <QtOpenGL/qgl.h>
     43#include "qgl_p.h"
    4344#include "qgl_egl_p.h"
    4445
     
    5859    // if the system hasn't already chosen a fixed format to
    5960    // match the pixmap, widget, etc.
    60     if (props.value(EGL_RED_SIZE) == EGL_DONT_CARE || f.redBufferSize() != -1)
     61    if (props.value(EGL_RED_SIZE) == 0 || f.redBufferSize() != -1)
    6162        props.setValue(EGL_RED_SIZE, f.redBufferSize() == -1 ? 1 : f.redBufferSize());
    62     if (props.value(EGL_GREEN_SIZE) == EGL_DONT_CARE || f.greenBufferSize() != -1)
     63    if (props.value(EGL_GREEN_SIZE) == 0 || f.greenBufferSize() != -1)
    6364        props.setValue(EGL_GREEN_SIZE, f.greenBufferSize() == -1 ? 1 : f.greenBufferSize());
    64     if (props.value(EGL_BLUE_SIZE) == EGL_DONT_CARE || f.blueBufferSize() != -1)
     65    if (props.value(EGL_BLUE_SIZE) == 0 || f.blueBufferSize() != -1)
    6566        props.setValue(EGL_BLUE_SIZE, f.blueBufferSize() == -1 ? 1 : f.blueBufferSize());
    6667    if (f.alpha()) {
    67         if (props.value(EGL_ALPHA_SIZE) == EGL_DONT_CARE || f.alphaBufferSize() != -1)
     68        if (props.value(EGL_ALPHA_SIZE) == 0 || f.alphaBufferSize() != -1)
    6869            props.setValue(EGL_ALPHA_SIZE, f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize());
    6970    }
     
    7576    if (f.sampleBuffers()) {
    7677        props.setValue(EGL_SAMPLE_BUFFERS, 1);
    77         props.setValue(EGL_SAMPLES, f.samples());
     78        props.setValue(EGL_SAMPLES, f.samples() == -1 ? 1 : f.samples());
    7879    } else {
    7980        props.setValue(EGL_SAMPLE_BUFFERS, 0);
     
    129130}
    130131
     132bool QGLFormat::hasOpenGL()
     133{
     134    return true;
     135}
     136
     137void QGLContext::reset()
     138{
     139    Q_D(QGLContext);
     140    if (!d->valid)
     141        return;
     142    d->cleanup();
     143    doneCurrent();
     144    if (d->eglContext) {
     145        d->destroyEglSurfaceForDevice();
     146        delete d->eglContext;
     147    }
     148    d->eglContext = 0;
     149    d->eglSurface = EGL_NO_SURFACE;
     150    d->crWin = false;
     151    d->sharing = false;
     152    d->valid = false;
     153    d->transpColor = QColor();
     154    d->initDone = false;
     155    qgl_share_reg()->removeShare(this);
     156}
     157
     158void QGLContext::makeCurrent()
     159{
     160    Q_D(QGLContext);
     161    if (!d->valid || !d->eglContext || d->eglSurface == EGL_NO_SURFACE) {
     162        qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
     163        return;
     164    }
     165
     166    if (d->eglContext->makeCurrent(d->eglSurface))
     167        QGLContextPrivate::setCurrentContext(this);
     168}
     169
     170void QGLContext::doneCurrent()
     171{
     172    Q_D(QGLContext);
     173    if (d->eglContext)
     174        d->eglContext->doneCurrent();
     175
     176    QGLContextPrivate::setCurrentContext(0);
     177}
     178
     179
     180void QGLContext::swapBuffers() const
     181{
     182    Q_D(const QGLContext);
     183    if (!d->valid || !d->eglContext)
     184        return;
     185
     186    d->eglContext->swapBuffers(d->eglSurface);
     187}
     188
     189void QGLContextPrivate::destroyEglSurfaceForDevice()
     190{
     191    if (eglSurface != EGL_NO_SURFACE) {
     192#ifdef Q_WS_X11
     193        // Make sure we don't call eglDestroySurface on a surface which
     194        // was created for a different winId:
     195        if (paintDevice->devType() == QInternal::Widget) {
     196            QGLWidget* w = static_cast<QGLWidget*>(paintDevice);
     197
     198            if (w->d_func()->eglSurfaceWindowId == w->winId())
     199                eglDestroySurface(eglContext->display(), eglSurface);
     200            else
     201                qWarning("WARNING: Potential EGL surface leak!");
     202        } else
     203#endif
     204            eglDestroySurface(eglContext->display(), eglSurface);
     205        eglSurface = EGL_NO_SURFACE;
     206    }
     207}
     208
     209void QGLWidget::setMouseTracking(bool enable)
     210{
     211    QWidget::setMouseTracking(enable);
     212}
     213
     214QColor QGLContext::overlayTransparentColor() const
     215{
     216    return d_func()->transpColor;
     217}
     218
     219uint QGLContext::colorIndex(const QColor &c) const
     220{
     221    Q_UNUSED(c);
     222    return 0;
     223}
     224
     225void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase)
     226{
     227    Q_UNUSED(fnt);
     228    Q_UNUSED(listBase);
     229}
     230
     231void *QGLContext::getProcAddress(const QString &proc) const
     232{
     233    return (void*)eglGetProcAddress(reinterpret_cast<const char *>(proc.toLatin1().data()));
     234}
     235
     236bool QGLWidgetPrivate::renderCxPm(QPixmap*)
     237{
     238    return false;
     239}
     240
    131241QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.