2014-04-24 14:40:22 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-04-24 14:40:22 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2014-04-24 14:40:22 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-04-24 14:40:22 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-04-24 14:40:22 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QOPENGLCONTEXTWINDOW_H
|
|
|
|
#define QOPENGLCONTEXTWINDOW_H
|
|
|
|
|
|
|
|
#include <QtGui/QWindow>
|
|
|
|
#include <QtGui/QOpenGLContext>
|
Introduce platform API abstraction for QOpenGLContext
The API is available by including qopenglcontext.h as usual,
but scoped in the QPlatformInterface namespace. The namespace
exposes platform specific type-safe interfaces that provide:
a) Factory functions for adopting native contexts, e.g.
QCocoaGLContext::fromNative(nsContext, shareContext);
b) Access to underlying native handles, e.g.
openGLContext->platformInterface<QCocoaGLContext>->nativeContext()
c) Platform specific functionality, e.g.
static QWGLContext::openGLModuleHandle()
openGLContext->platformInterface<QEGLContext>->doSomething();
The platform interfaces live close to the classes they extend,
removing the need for complex indirection and plumbing, and
avoids kitchen-sink modules and APIs such as the extras modules,
QPlatformFunctions, or QPlatformNativeInterface.
In the case of QOpenGLContext these platform APIs are backed
by the platform plugin, so dynamic_cast is used to ensure the
platform plugin supports the requested interface, but this is
and implementation detail. The interface APIs are agnostic
to where the implementation lives, while still being available
to the user as part of the APIs they extend/augment.
The documentation will be restored when the dust settles.
Task-number: QTBUG-80233
Change-Id: Iac612403383991c4b24064332542a6e4bcbb3293
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-08 18:00:36 +00:00
|
|
|
#include <QtOpenGL/QOpenGLTextureBlitter>
|
2014-04-24 14:40:22 +00:00
|
|
|
#include <QtGui/QImage>
|
|
|
|
#include <QtCore/QVariant>
|
|
|
|
|
|
|
|
class QOpenGLContextWindow : public QWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
QOpenGLContextWindow();
|
|
|
|
~QOpenGLContextWindow();
|
|
|
|
|
|
|
|
void render();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void exposeEvent(QExposeEvent *event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
qreal dWidth() const { return width() * devicePixelRatio(); }
|
|
|
|
qreal dHeight() const { return height() * devicePixelRatio(); }
|
|
|
|
void createForeignContext();
|
|
|
|
|
|
|
|
QOpenGLContext *m_context;
|
|
|
|
QImage m_image;
|
|
|
|
QVariant m_nativeHandle;
|
|
|
|
uint m_textureId;
|
|
|
|
QOpenGLTextureBlitter *m_blitter;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|