| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qminimaleglbackingstore.h" |
| 5 | |
| 6 | #include <QtGui/QOpenGLContext> |
| 7 | #include <QtOpenGL/QOpenGLPaintDevice> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | QMinimalEglBackingStore::QMinimalEglBackingStore(QWindow *window) |
| 12 | : QPlatformBackingStore(window) |
| 13 | , m_context(new QOpenGLContext) |
| 14 | , m_device(nullptr) |
| 15 | { |
| 16 | m_context->setFormat(window->requestedFormat()); |
| 17 | m_context->setScreen(window->screen()); |
| 18 | m_context->create(); |
| 19 | } |
| 20 | |
| 21 | QMinimalEglBackingStore::~QMinimalEglBackingStore() |
| 22 | { |
| 23 | delete m_context; |
| 24 | } |
| 25 | |
| 26 | QPaintDevice *QMinimalEglBackingStore::paintDevice() |
| 27 | { |
| 28 | return m_device; |
| 29 | } |
| 30 | |
| 31 | void QMinimalEglBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) |
| 32 | { |
| 33 | Q_UNUSED(region); |
| 34 | Q_UNUSED(offset); |
| 35 | |
| 36 | #ifdef QEGL_EXTRA_DEBUG |
| 37 | qWarning("QEglBackingStore::flush %p", window); |
| 38 | #endif |
| 39 | |
| 40 | m_context->swapBuffers(surface: window); |
| 41 | } |
| 42 | |
| 43 | void QMinimalEglBackingStore::beginPaint(const QRegion &) |
| 44 | { |
| 45 | m_context->makeCurrent(surface: window()); |
| 46 | m_device = new QOpenGLPaintDevice(window()->size()); |
| 47 | } |
| 48 | |
| 49 | void QMinimalEglBackingStore::endPaint() |
| 50 | { |
| 51 | delete m_device; |
| 52 | } |
| 53 | |
| 54 | void QMinimalEglBackingStore::resize(const QSize &size, const QRegion &staticContents) |
| 55 | { |
| 56 | Q_UNUSED(size); |
| 57 | Q_UNUSED(staticContents); |
| 58 | } |
| 59 | |
| 60 | QT_END_NAMESPACE |
| 61 |
