diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-03-20 16:04:19 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-21 11:08:17 +0100 |
commit | d8ce5886971107d219dc1e597f979c97ace6d64f (patch) | |
tree | ea02f7b3925bccae8b0908d846052546c62d6650 | |
parent | 96275509fcec8abc8e580aa6c3c53d893885b7a7 (diff) | |
download | qtwayland-d8ce5886971107d219dc1e597f979c97ace6d64f.tar.gz |
Remove the QWidget compositor example
The QWidget API isn't well fit for a Wayland compositor, and does
not have any advantage over a QWindow, which can also draw using
QPainter. Besides the current implementation doesn't work properly,
and no one seems to be interested in fixing it.
Change-Id: Id1c337506af48e1d1fdd8d14f0ed637d299702f3
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
-rw-r--r-- | examples/examples.pro | 4 | ||||
-rw-r--r-- | examples/qwidget-compositor/main.cpp | 394 | ||||
-rw-r--r-- | examples/qwidget-compositor/qwidget-compositor.pro | 23 | ||||
-rw-r--r-- | examples/qwidget-compositor/qwidget-compositor.qrc | 5 | ||||
-rw-r--r-- | examples/qwidget-compositor/textureblitter.cpp | 158 | ||||
-rw-r--r-- | examples/qwidget-compositor/textureblitter.h | 68 |
6 files changed, 0 insertions, 652 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 2d4cd1bb..d633fb92 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -5,10 +5,6 @@ TEMPLATE=subdirs contains(CONFIG, wayland-compositor) { SUBDIRS += qwindow-compositor - qtHaveModule(widgets) { - SUBDIRS += qwidget-compositor - } - qtHaveModule(quick) { SUBDIRS += qml-compositor } diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp deleted file mode 100644 index 7a268fbd..00000000 --- a/examples/qwidget-compositor/main.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandcompositor.h" - -#include "qwaylandsurface.h" -#include <QtCompositor/qwaylandinput.h> - -#include <QApplication> -#include <QWidget> -#include <QTimer> -#include <QPainter> -#include <QMouseEvent> -#include <QtCore/QLinkedList> - -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include <QOpenGLContext> -#include <QGLWidget> -#include <QtGui/private/qopengltexturecache_p.h> -#include "textureblitter.h" -#include <QOpenGLFunctions> -#endif - -#include <QDebug> - -#ifdef QT_COMPOSITOR_WAYLAND_GL -class QWidgetCompositor : public QGLWidget, public QWaylandCompositor -#else -class QWidgetCompositor : public QWidget, public WaylandCompositor -#endif -{ - Q_OBJECT -public: - QWidgetCompositor() - : QWaylandCompositor(windowHandle(), 0, DefaultExtensions | SubSurfaceExtension) -#ifdef QT_COMPOSITOR_WAYLAND_GL - , m_surfaceCompositorFbo(0) - , m_textureBlitter(0) - , m_textureCache(0) -#endif - , m_moveSurface(0) - , m_dragSourceSurface(0) - , m_cursorSurface(0) - { - setMouseTracking(true); - setRetainedSelectionEnabled(true); - m_background = QImage(QLatin1String(":/background.jpg")); - //make sure we get the window id and create the glcontext - //so that clients can successfully initialize egl - winId(); - } - -private slots: - void surfaceDestroyed(QObject *object) { - QWaylandSurface *surface = static_cast<QWaylandSurface *>(object); - m_surfaces.removeAll(surface); - update(); - } - - void surfaceMapped() { - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); - QPoint pos; - if (!m_surfaces.contains(surface)) { - uint px = 1 + (qrand() % (width() - surface->size().width() - 2)); - uint py = 1 + (qrand() % (height() - surface->size().height() - 2)); - pos = QPoint(px, py); - surface->setPos(pos); - if (surface->hasShellSurface()) - m_surfaces.append(surface); - } - if (surface->hasShellSurface()) - defaultInputDevice()->setKeyboardFocus(surface); - update(); - } - - void surfaceCommitted() { - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); - surfaceCommitted(surface); - } - -protected: - void surfaceCommitted(QWaylandSurface *surface) - { - Q_UNUSED(surface); - update(); - } - - void surfaceCreated(QWaylandSurface *surface) { - connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); - connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); - connect(surface, SIGNAL(committed()), this, SLOT(surfaceCommitted())); - update(); - } - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint composeSurface(QWaylandSurface *surface) { - GLuint texture = 0; - QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); - - QSize windowSize = surface->size(); - surface->swapBuffers(); - - if (!m_surfaceCompositorFbo) - functions->glGenFramebuffers(1,&m_surfaceCompositorFbo); - - functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surfaceCompositorFbo); - - if (surface->type() == QWaylandSurface::Shm) { - texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); - } else { - texture = surface->texture(); - } - - functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, texture, 0); - paintChildren(surface,surface,windowSize); - functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, 0, 0); - - functions->glBindFramebuffer(GL_FRAMEBUFFER, 0); - return texture; - } - - void paintChildren(QWaylandSurface *surface, QWaylandSurface *window, const QSize &windowSize) { - - if (surface->subSurfaces().size() == 0) - return; - - QLinkedListIterator<QWaylandSurface *> i(surface->subSurfaces()); - while (i.hasNext()) { - QWaylandSurface *subSurface = i.next(); - QPointF p = subSurface->mapTo(window,QPoint(0,0)); - QSize size = subSurface->size(); - subSurface->swapBuffers(); - if (size.isValid()) { - GLuint texture = 0; - if (subSurface->type() == QWaylandSurface::Texture) { - texture = subSurface->texture(); - } else if (surface->type() == QWaylandSurface::Shm ) { - texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); - } - m_textureBlitter->drawTexture(texture,QRect(p.toPoint(),size),windowSize,0,window->isYInverted(),subSurface->isYInverted()); - } - paintChildren(subSurface,window,windowSize); - } - } -#else //hmmm, this is actually untested :( - QImage composeSurface(WaylandSurface *surface) - { - Q_ASSER(surface->type() == WaylandSurface::Shm); - QImage img = surface->image(); - QPainter p(&img); - paintChildren(surface,p,surface); - - return img; - } - - void paintChildren(WaylandSurface *surface, QPainter *painter, WaylandSurface *window) { - if (surface->subSurfaces().size() == 0) - return; - - QLinkedListIterator<WaylandSurface *> i(surface->subSurfaces()); - while (i.hasNext()) { - WaylandSurface *subSurface = i.next(); - QPoint p = subSurface->mapTo(window,QPoint(0,0)); - QRect geo = subSurface->geometry(); - geo.moveTo(p); - if (geo.isValid()) { - painter->drawImage(p,subSurface->image()); - } - paintChildren(subSurface,painter,window); - } - } -#endif //QT_COMPOSITOR_WAYLAND_GL - - - - void paintEvent(QPaintEvent *) { - QPainter p(this); - - frameStarted(); - if (!m_background.isNull()) - p.drawPixmap(rect(), m_backgroundScaled); - -#ifdef QT_COMPOSITOR_WAYLAND_GL - cleanupGraphicsResources(); - if (!m_textureCache) { - m_textureCache = new QOpenGLTextureCache(context()->contextHandle()); - } - if (!m_textureBlitter) { - m_textureBlitter = new TextureBlitter(); - } - m_textureBlitter->bind(); -#endif - for (int i = 0; i < m_surfaces.size(); ++i) { -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint texture = composeSurface(m_surfaces.at(i)); - QWaylandSurface *surface = m_surfaces.at(i); - QRect geo(surface->pos().toPoint(),surface->size()); - m_textureBlitter->drawTexture(texture,geo,size(),0,false,m_surfaces.at(i)->isYInverted()); -#else - QImage img = composeSurface(m_surfaces.at(i)); - p.drawImage(m_surfaces.at(i)->geometry().topLeft(),img); -#endif //QT_COMPOSITOR_WAYLAND_GL - } - - sendFrameCallbacks(surfaces()); - -#ifdef QT_COMPOSITOR_WAYLAND_GL - //jl:FIX FIX FIX:) -// update(); - m_textureBlitter->release(); -#endif - } - - void resizeEvent(QResizeEvent *) - { - if (!m_background.isNull()) { - m_backgroundScaled = QPixmap::fromImage(m_background.scaled(size(), - Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } - } - - void raise(QWaylandSurface *surface) { - defaultInputDevice()->setKeyboardFocus(surface); - update(); - m_surfaces.removeOne(surface); - m_surfaces.append(surface); - } - - void mousePressEvent(QMouseEvent *e) { - m_cursorPos = e->pos(); - QPointF local; - if (QWaylandSurface *surface = surfaceAt(e->pos(), &local)) { - raise(surface); - if (e->modifiers() & Qt::ControlModifier) { - m_moveSurface = surface; - m_moveOffset = local; - } else { - defaultInputDevice()->sendMousePressEvent(e->button(), local.toPoint(),e->pos()); - } - } - } - - void mouseMoveEvent(QMouseEvent *e) { - m_cursorPos = e->pos(); - if (isDragging()) { - QPoint global = e->pos(); // "global" here means the window of the compositor - QPointF local; - QWaylandSurface *surface = surfaceAt(e->pos(), &local); - if (surface) { - if (!m_dragSourceSurface) - m_dragSourceSurface = surface; - if (m_dragSourceSurface == surface) - m_lastDragSourcePos = local; - raise(surface); - } - //this should go away when draggin is reimplemented - sendDragMoveEvent(global, local.toPoint(), surface); - return; - } - if (m_moveSurface) { - m_moveSurface->setPos(e->localPos() - m_moveOffset); - update(); - return; - } - QPointF local; - if (surfaceAt(e->pos(), &local)) - defaultInputDevice()->sendMouseMoveEvent(local.toPoint(),pos()); - } - - void mouseReleaseEvent(QMouseEvent *e) { - if (isDragging()) { - sendDragEndEvent(); - if (m_dragSourceSurface) { - // Must send a release event to the source too, no matter where the cursor is now. - // This is a hack and should go away when we reimplement draging - defaultInputDevice()->sendMouseReleaseEvent(e->button(), m_lastDragSourcePos.toPoint(), e->pos()); - m_dragSourceSurface = 0; - } - } - if (m_moveSurface) { - m_moveSurface = 0; - return; - } - QPointF local; - if (surfaceAt(e->pos(), &local)) - defaultInputDevice()->sendMouseReleaseEvent(e->button(), local.toPoint(), e->pos()); - } - - void keyPressEvent(QKeyEvent *event) - { - defaultInputDevice()->sendKeyPressEvent(event->nativeScanCode()); - } - - void keyReleaseEvent(QKeyEvent *event) - { - defaultInputDevice()->sendKeyReleaseEvent(event->nativeScanCode()); - } - - QWaylandSurface *surfaceAt(const QPointF &point, QPointF *local = 0) { - for (int i = m_surfaces.size() - 1; i >= 0; --i) { - QWaylandSurface *surface = m_surfaces.at(i); - QRect geo(surface->pos().toPoint(),surface->size()); - if (geo.contains(point.toPoint())) { - if (local) - *local = point - surface->pos(); - return surface; - } - } - return 0; - } - - void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) { - m_cursorSurface = surface; - m_cursorHotspot = QPoint(hotspotX, hotspotY); - update(); - } - -private: - QImage m_background; - QPixmap m_backgroundScaled; - - QList<QWaylandSurface *> m_surfaces; - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint m_surfaceCompositorFbo; - TextureBlitter *m_textureBlitter; - QOpenGLTextureCache *m_textureCache; -#endif - - QWaylandSurface *m_moveSurface; - QPointF m_moveOffset; - QWaylandSurface *m_dragSourceSurface; - QPointF m_lastDragSourcePos; - - QWaylandSurface* m_cursorSurface; - QPoint m_cursorPos; - QPoint m_cursorHotspot; - - friend class TouchObserver; -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QWidgetCompositor compositor; - compositor.resize(800, 600); - compositor.show(); - -// QTouchScreenHandlerThread t(QString(), new TouchObserver(&compositor)); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/qwidget-compositor/qwidget-compositor.pro b/examples/qwidget-compositor/qwidget-compositor.pro deleted file mode 100644 index 688175b9..00000000 --- a/examples/qwidget-compositor/qwidget-compositor.pro +++ /dev/null @@ -1,23 +0,0 @@ -# if you want to compile QtCompositor as part of the application -# instead of linking to it, remove the QT += compositor and uncomment -# the following line -#include (../../src/qt-compositor/qt-compositor.pri) - -# to make QtCompositor/... style includes working without installing -INCLUDEPATH += $$PWD/../../include - -HEADERS += \ - textureblitter.h - -SOURCES += \ - main.cpp \ - textureblitter.cpp - -QT += core-private gui-private widgets widgets-private opengl opengl-private compositor - -RESOURCES += qwidget-compositor.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qwidget-compositor.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor -INSTALLS += target sources diff --git a/examples/qwidget-compositor/qwidget-compositor.qrc b/examples/qwidget-compositor/qwidget-compositor.qrc deleted file mode 100644 index 20dd10a5..00000000 --- a/examples/qwidget-compositor/qwidget-compositor.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file alias="background.jpg">../qml-compositor/background.jpg</file> - </qresource> -</RCC> diff --git a/examples/qwidget-compositor/textureblitter.cpp b/examples/qwidget-compositor/textureblitter.cpp deleted file mode 100644 index 5607274b..00000000 --- a/examples/qwidget-compositor/textureblitter.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textureblitter.h" - -#include <QtGui/QOpenGLShaderProgram> -#include <QtGui/QOpenGLContext> -#include <QtGui/QOpenGLFunctions> - -TextureBlitter::TextureBlitter() - : m_shaderProgram(new QOpenGLShaderProgram()) -{ - static const char *textureVertexProgram = - "uniform highp mat4 matrix;\n" - "attribute highp vec3 vertexCoordEntry;\n" - "attribute highp vec2 textureCoordEntry;\n" - "varying highp vec2 textureCoord;\n" - "void main() {\n" - " textureCoord = textureCoordEntry;\n" - " gl_Position = matrix * vec4(vertexCoordEntry, 1);\n" - "}\n"; - - static const char *textureFragmentProgram = - "uniform sampler2D texture;\n" - "varying highp vec2 textureCoord;\n" - "void main() {\n" - " gl_FragColor = texture2D(texture, textureCoord);\n" - "}\n"; - - //Enable transparent windows - glEnable(GL_BLEND); - glBlendFunc (GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - - m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram); - m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram); - m_shaderProgram->link(); -} - - -void TextureBlitter::bind() -{ - - m_shaderProgram->bind(); - - m_vertexCoordEntry = m_shaderProgram->attributeLocation("vertexCoordEntry"); - m_textureCoordEntry = m_shaderProgram->attributeLocation("textureCoordEntry"); - m_matrixLocation = m_shaderProgram->uniformLocation("matrix"); -} - -void TextureBlitter::release() -{ - m_shaderProgram->release(); -} - -void TextureBlitter::drawTexture(int textureId, const QRectF &targetRect, const QSize &targetSize, int depth, bool targethasInvertedY, bool sourceHasInvertedY) -{ - - glViewport(0,0,targetSize.width(),targetSize.height()); - GLfloat zValue = depth / 1000.0f; - //Set Texture and Vertex coordinates - const GLfloat textureCoordinates[] = { - 0, 0, - 1, 0, - 1, 1, - 0, 1 - }; - - GLfloat x1 = targetRect.left(); - GLfloat x2 = targetRect.right(); - GLfloat y1, y2; - if (targethasInvertedY) { - if (sourceHasInvertedY) { - y1 = targetRect.top(); - y2 = targetRect.bottom(); - } else { - y1 = targetRect.bottom(); - y2 = targetRect.top(); - } - } else { - if (sourceHasInvertedY) { - y1 = targetSize.height() - targetRect.top(); - y2 = targetSize.height() - targetRect.bottom(); - } else { - y1 = targetSize.height() - targetRect.bottom(); - y2 = targetSize.height() - targetRect.top(); - } - } - - const GLfloat vertexCoordinates[] = { - GLfloat(x1), GLfloat(y1), zValue, - GLfloat(x2), GLfloat(y1), zValue, - GLfloat(x2), GLfloat(y2), zValue, - GLfloat(x1), GLfloat(y2), zValue - }; - - //Set matrix to transfrom geometry values into gl coordinate space. - m_transformMatrix.setToIdentity(); - m_transformMatrix.scale( 2.0f / targetSize.width(), 2.0f / targetSize.height() ); - m_transformMatrix.translate(-targetSize.width() / 2.0f, -targetSize.height() / 2.0f); - - //attach the data! - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - currentContext->functions()->glEnableVertexAttribArray(m_vertexCoordEntry); - currentContext->functions()->glEnableVertexAttribArray(m_textureCoordEntry); - - currentContext->functions()->glVertexAttribPointer(m_vertexCoordEntry, 3, GL_FLOAT, GL_FALSE, 0, vertexCoordinates); - currentContext->functions()->glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates); - m_shaderProgram->setUniformValue(m_matrixLocation, m_transformMatrix); - - glBindTexture(GL_TEXTURE_2D, textureId); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - glBindTexture(GL_TEXTURE_2D, 0); - - currentContext->functions()->glDisableVertexAttribArray(m_vertexCoordEntry); - currentContext->functions()->glDisableVertexAttribArray(m_textureCoordEntry); -} diff --git a/examples/qwidget-compositor/textureblitter.h b/examples/qwidget-compositor/textureblitter.h deleted file mode 100644 index 9a6ce59e..00000000 --- a/examples/qwidget-compositor/textureblitter.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTUREBLITTER_H -#define TEXTUREBLITTER_H - -#include <QtGui/QMatrix4x4> - -#include <QtGui/qopengl.h> - -class QOpenGLShaderProgram; -class TextureBlitter -{ -public: - TextureBlitter(); - void bind(); - void release(); - void drawTexture(int textureId, const QRectF &sourceGeometry, - const QSize &targetRect, int depth, - bool targethasInvertedY, bool sourceHasInvertedY); - -private: - QOpenGLShaderProgram *m_shaderProgram; - QMatrix4x4 m_transformMatrix; - - int m_matrixLocation; - int m_vertexCoordEntry; - int m_textureCoordEntry; -}; - -#endif // TEXTUREBLITTER_H |