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/qglpixelbuffer.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**
     
    4545    \since 4.1
    4646
    47     \ingroup multimedia
     47    \ingroup painting-3D
    4848
    4949    Rendering into a pbuffer is normally done using full hardware
     
    7777*/
    7878
     79#include <QtCore/qglobal.h>
     80
     81#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
     82#include <private/qpaintengineex_opengl2_p.h>
     83#endif
    7984
    8085#include <qglpixelbuffer.h>
     
    8287#include <qimage.h>
    8388
    84 #if !defined(QT_OPENGL_ES_2)
     89#ifndef QT_OPENGL_ES_2
    8590#include <private/qpaintengine_opengl_p.h>
    8691#endif
     
    95100
    96101extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
     102
     103
     104QGLContext* QGLPBufferGLPaintDevice::context() const
     105{
     106    return pbuf->d_func()->qctx;
     107}
     108
     109void QGLPBufferGLPaintDevice::endPaint() {
     110    glFlush();
     111    QGLPaintDevice::endPaint();
     112}
     113
     114void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb)
     115{
     116    pbuf = pb;
     117}
    97118
    98119void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget)
     
    106127        qctx = new QGLContext(format);
    107128        qctx->d_func()->sharing = (shareWidget != 0);
    108         if (shareWidget != 0 && shareWidget->d_func()->glcx)
     129        if (shareWidget != 0 && shareWidget->d_func()->glcx) {
    109130            qgl_share_reg()->addShare(qctx, shareWidget->d_func()->glcx);
    110 
     131            shareWidget->d_func()->glcx->d_func()->sharing = true;
     132        }
     133
     134        glDevice.setPBuffer(q);
    111135        qctx->d_func()->paintDevice = q;
    112136        qctx->d_func()->valid = true;
     
    123147#elif defined(QT_OPENGL_ES)
    124148        qctx->d_func()->eglContext = ctx;
     149        qctx->d_func()->eglSurface = pbuf;
    125150#endif
    126151    }
     
    187212    if (current && current != d->qctx)
    188213        current->makeCurrent();
    189     delete d_ptr;
    190214}
    191215
     
    364388}
    365389
    366 #if !defined(QT_OPENGL_ES_2)
    367 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_paintengine)
     390#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
     391Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine)
     392#endif
     393
     394#ifndef QT_OPENGL_ES_2
     395Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine)
    368396#endif
    369397
     
    371399QPaintEngine *QGLPixelBuffer::paintEngine() const
    372400{
    373 #if !defined(QT_OPENGL_ES_2)
    374     return qt_buffer_paintengine();
     401#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
     402    return qt_buffer_engine();
     403#elif defined(QT_OPENGL_ES_2)
     404    return qt_buffer_2_engine();
    375405#else
    376     return 0;
    377 #endif
    378 }
    379 
    380 extern int qt_defaultDpi();
     406    if (qt_gl_preferGL2Engine())
     407        return qt_buffer_2_engine();
     408    else
     409        return qt_buffer_engine();
     410#endif
     411}
     412
     413extern int qt_defaultDpiX();
     414extern int qt_defaultDpiY();
    381415
    382416/*! \reimp */
     
    385419    Q_D(const QGLPixelBuffer);
    386420
    387     float dpmx = qt_defaultDpi()*100./2.54;
    388     float dpmy = qt_defaultDpi()*100./2.54;
     421    float dpmx = qt_defaultDpiX()*100./2.54;
     422    float dpmy = qt_defaultDpiY()*100./2.54;
    389423    int w = d->req_size.width();
    390424    int h = d->req_size.height();
     
    409443
    410444    case PdmDpiX:
    411         return (int)(dpmx * 0.0254);
     445        return qRound(dpmx * 0.0254);
    412446
    413447    case PdmDpiY:
    414         return (int)(dpmy * 0.0254);
     448        return qRound(dpmy * 0.0254);
    415449
    416450    case PdmPhysicalDpiX:
    417         return (int)(dpmx * 0.0254);
     451        return qRound(dpmx * 0.0254);
    418452
    419453    case PdmPhysicalDpiY:
    420         return (int)(dpmy * 0.0254);
     454        return qRound(dpmy * 0.0254);
    421455
    422456    default:
     
    577611
    578612/*! \fn int QGLPixelBuffer::devType() const
    579     \reimp
     613    \internal
    580614*/
    581615
Note: See TracChangeset for help on using the changeset viewer.