| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/eglconvenience/qeglpbuffer.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include <QtGui/QOffscreenSurface> | - | ||||||||||||
| 35 | #include "qeglpbuffer_p.h" | - | ||||||||||||
| 36 | #include "qeglconvenience_p.h" | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | /*! | - | ||||||||||||
| 41 | \class QEGLPbuffer | - | ||||||||||||
| 42 | \brief A pbuffer-based implementation of QPlatformOffscreenSurface for EGL. | - | ||||||||||||
| 43 | \since 5.2 | - | ||||||||||||
| 44 | \internal | - | ||||||||||||
| 45 | \ingroup qpa | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | To use this implementation in the platform plugin simply | - | ||||||||||||
| 48 | reimplement QPlatformIntegration::createPlatformOffscreenSurface() | - | ||||||||||||
| 49 | and return a new instance of this class. | - | ||||||||||||
| 50 | */ | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, | - | ||||||||||||
| 53 | QEGLPlatformContext::Flags flags) | - | ||||||||||||
| 54 | : QPlatformOffscreenSurface(offscreenSurface) | - | ||||||||||||
| 55 | , m_format(format) | - | ||||||||||||
| 56 | , m_display(display) | - | ||||||||||||
| 57 | , m_pbuffer(EGL_NO_SURFACE) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | bool hasSurfaceless = !flags.testFlag(QEGLPlatformContext::NoSurfaceless)
| 0 | ||||||||||||
| 60 | && q_hasEglExtension(display, "EGL_KHR_surfaceless_context");
| 0 | ||||||||||||
| 61 | - | |||||||||||||
| 62 | // Disable surfaceless contexts on Mesa for now. As of 10.6.0 and Intel at least, some | - | ||||||||||||
| 63 | // operations (glReadPixels) are unable to work without a surface since they at some | - | ||||||||||||
| 64 | // point temporarily unbind the current FBO and then later blow up in some seemingly | - | ||||||||||||
| 65 | // safe operations, like setting the viewport, that apparently need access to the | - | ||||||||||||
| 66 | // read/draw surface in the Intel backend. | - | ||||||||||||
| 67 | const char *vendor = eglQueryString(display, EGL_VENDOR); // hard to check for GL_ strings here, so blacklist all Mesa | - | ||||||||||||
| 68 | if (vendor && strstr(vendor, "Mesa"))
| 0 | ||||||||||||
| 69 | hasSurfaceless = false; never executed: hasSurfaceless = false; | 0 | ||||||||||||
| 70 | - | |||||||||||||
| 71 | if (hasSurfaceless)
| 0 | ||||||||||||
| 72 | return; never executed: return; | 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT); | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | if (config) {
| 0 | ||||||||||||
| 77 | const EGLint attributes[] = { | - | ||||||||||||
| 78 | EGL_WIDTH, offscreenSurface->size().width(), | - | ||||||||||||
| 79 | EGL_HEIGHT, offscreenSurface->size().height(), | - | ||||||||||||
| 80 | EGL_LARGEST_PBUFFER, EGL_FALSE, | - | ||||||||||||
| 81 | EGL_NONE | - | ||||||||||||
| 82 | }; | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | m_pbuffer = eglCreatePbufferSurface(m_display, config, attributes); | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | if (m_pbuffer != EGL_NO_SURFACE)
| 0 | ||||||||||||
| 87 | m_format = q_glFormatFromConfig(m_display, config); never executed: m_format = q_glFormatFromConfig(m_display, config); | 0 | ||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||
| 90 | - | |||||||||||||
| 91 | QEGLPbuffer::~QEGLPbuffer() | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | if (m_pbuffer != EGL_NO_SURFACE)
| 0 | ||||||||||||
| 94 | eglDestroySurface(m_display, m_pbuffer); never executed: eglDestroySurface(m_display, m_pbuffer); | 0 | ||||||||||||
| 95 | } never executed: end of block | 0 | ||||||||||||
| 96 | - | |||||||||||||
| 97 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |