summaryrefslogtreecommitdiffstats
path: root/examples/qws/svgalib
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qws/svgalib')
-rw-r--r--examples/qws/svgalib/README9
-rw-r--r--examples/qws/svgalib/svgalib.desktop11
-rw-r--r--examples/qws/svgalib/svgalib.pro22
-rw-r--r--examples/qws/svgalib/svgalibpaintdevice.cpp66
-rw-r--r--examples/qws/svgalib/svgalibpaintdevice.h65
-rw-r--r--examples/qws/svgalib/svgalibpaintengine.cpp190
-rw-r--r--examples/qws/svgalib/svgalibpaintengine.h78
-rw-r--r--examples/qws/svgalib/svgalibplugin.cpp74
-rw-r--r--examples/qws/svgalib/svgalibscreen.cpp353
-rw-r--r--examples/qws/svgalib/svgalibscreen.h83
-rw-r--r--examples/qws/svgalib/svgalibsurface.cpp86
-rw-r--r--examples/qws/svgalib/svgalibsurface.h75
12 files changed, 0 insertions, 1112 deletions
diff --git a/examples/qws/svgalib/README b/examples/qws/svgalib/README
deleted file mode 100644
index 227c066f01..0000000000
--- a/examples/qws/svgalib/README
+++ /dev/null
@@ -1,9 +0,0 @@
-This is the SVGA screen driver plugin example for QWS.
-
-You may need to set the SVGALIB_DEFAULT_MODE environment
-variable. These values have been confirmed to work on one specific
-machine using svgalib 1.4.3: 18, 24, 34, 35, 36
-
-There is a bug in the example causing missing updates in 8-bit mode
-(e.g. modes 10 and 12). Fixing this bug is left as an exercise for the
-reader.
diff --git a/examples/qws/svgalib/svgalib.desktop b/examples/qws/svgalib/svgalib.desktop
deleted file mode 100644
index 94ea92fd52..0000000000
--- a/examples/qws/svgalib/svgalib.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Accelerated Graphics Driver
-Exec=/opt/usr/bin/svgalib
-Icon=svgalib
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/qws/svgalib/svgalib.pro b/examples/qws/svgalib/svgalib.pro
deleted file mode 100644
index 7058750bb3..0000000000
--- a/examples/qws/svgalib/svgalib.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-
-LIBS += -lvgagl -lvga
-
-TARGET = svgalibscreen
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-HEADERS = svgalibscreen.h \
- svgalibpaintengine.h \
- svgalibsurface.h \
- svgalibpaintdevice.h
-SOURCES = svgalibscreen.cpp \
- svgalibpaintengine.cpp \
- svgalibsurface.cpp \
- svgalibpaintdevice.cpp \
- svgalibplugin.cpp
-
-QT += widgets
-
-simulator: warning(This example does not work on Simulator platform)
diff --git a/examples/qws/svgalib/svgalibpaintdevice.cpp b/examples/qws/svgalib/svgalibpaintdevice.cpp
deleted file mode 100644
index 6a6063d35a..0000000000
--- a/examples/qws/svgalib/svgalibpaintdevice.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 "svgalibpaintdevice.h"
-#include "svgalibpaintengine.h"
-
-#include <QApplication>
-#include <QDesktopWidget>
-
-SvgalibPaintDevice::SvgalibPaintDevice(QWidget *w)
- : QCustomRasterPaintDevice(w)
-{
- pengine = new SvgalibPaintEngine(this);
-}
-
-SvgalibPaintDevice::~SvgalibPaintDevice()
-{
- delete pengine;
-}
-
-int SvgalibPaintDevice::metric(PaintDeviceMetric m) const
-{
- if (m == PdmWidth)
- return QApplication::desktop()->screenGeometry().width();
- else if (m == PdmHeight)
- return QApplication::desktop()->screenGeometry().height();
- return QCustomRasterPaintDevice::metric(m);
-}
-
diff --git a/examples/qws/svgalib/svgalibpaintdevice.h b/examples/qws/svgalib/svgalibpaintdevice.h
deleted file mode 100644
index 736a003cfd..0000000000
--- a/examples/qws/svgalib/svgalibpaintdevice.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 SVGALIBPAINTDEVICE_H
-#define SVGALIBPAINTDEVICE_H
-
-#include "svgalibpaintengine.h"
-#include <private/qpaintengine_raster_p.h>
-#include <qscreen_qws.h>
-
-//! [0]
-class SvgalibPaintDevice : public QCustomRasterPaintDevice
-{
-public:
- SvgalibPaintDevice(QWidget *w);
- ~SvgalibPaintDevice();
-
- void* memory() const { return QScreen::instance()->base(); }
-
- QPaintEngine *paintEngine() const { return pengine; }
- int metric(PaintDeviceMetric m) const;
-
-private:
- SvgalibPaintEngine *pengine;
-};
-//! [0]
-
-#endif // SVGALIBPAINTDEVICE_H
diff --git a/examples/qws/svgalib/svgalibpaintengine.cpp b/examples/qws/svgalib/svgalibpaintengine.cpp
deleted file mode 100644
index 1f109f585c..0000000000
--- a/examples/qws/svgalib/svgalibpaintengine.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 "svgalibpaintengine.h"
-
-#include <QColor>
-#include <vga.h>
-#include <vgagl.h>
-
-SvgalibPaintEngine::SvgalibPaintEngine(QPaintDevice *device)
- : QRasterPaintEngine(device)
-{
-}
-
-SvgalibPaintEngine::~SvgalibPaintEngine()
-{
-}
-
-//! [0]
-bool SvgalibPaintEngine::begin(QPaintDevice *dev)
-{
- device = dev;
- pen = Qt::NoPen;
- simplePen = true;
- brush = Qt::NoBrush;
- simpleBrush = true;
- matrix = QTransform();
- simpleMatrix = true;
- setClip(QRect(0, 0, device->width(), device->height()));
- opaque = true;
- aliased = true;
- sourceOver = true;
-
- return QRasterPaintEngine::begin(dev);
-}
-//! [0]
-
-//! [1]
-bool SvgalibPaintEngine::end()
-{
- gl_setclippingwindow(0, 0, device->width() - 1, device->height() - 1);
- return QRasterPaintEngine::end();
-}
-//! [1]
-
-//! [2]
-void SvgalibPaintEngine::updateState()
-{
- QRasterPaintEngineState *s = state();
-
- if (s->dirty & DirtyTransform) {
- matrix = s->matrix;
- simpleMatrix = (matrix.m12() == 0 && matrix.m21() == 0);
- }
-
- if (s->dirty & DirtyPen) {
- pen = s->pen;
- simplePen = (pen.width() == 0 || pen.widthF() <= 1)
- && (pen.style() == Qt::NoPen || pen.style() == Qt::SolidLine)
- && (pen.color().alpha() == 255);
- }
-
- if (s->dirty & DirtyBrush) {
- brush = s->brush;
- simpleBrush = (brush.style() == Qt::SolidPattern
- || brush.style() == Qt::NoBrush)
- && (brush.color().alpha() == 255);
- }
-
- if (s->dirty & DirtyClipRegion)
- setClip(s->clipRegion);
-
- if (s->dirty & DirtyClipEnabled) {
- clipEnabled = s->isClipEnabled();
- updateClip();
- }
-
- if (s->dirty & DirtyClipPath) {
- setClip(QRegion());
- simpleClip = false;
- }
-
- if (s->dirty & DirtyCompositionMode) {
- const QPainter::CompositionMode m = s->composition_mode;
- sourceOver = (m == QPainter::CompositionMode_SourceOver);
- }
-
- if (s->dirty & DirtyOpacity)
- opaque = (s->opacity == 256);
-
- if (s->dirty & DirtyHints)
- aliased = !(s->flags.antialiased);
-}
-//! [2]
-
-//! [3]
-void SvgalibPaintEngine::setClip(const QRegion &region)
-{
- if (region.isEmpty())
- clip = QRect(0, 0, device->width(), device->height());
- else
- clip = matrix.map(region) & QRect(0, 0, device->width(), device->height());
- clipEnabled = true;
- updateClip();
-}
-//! [3]
-
-//! [4]
-void SvgalibPaintEngine::updateClip()
-{
- QRegion clipRegion = QRect(0, 0, device->width(), device->height());
-
- if (!systemClip().isEmpty())
- clipRegion &= systemClip();
- if (clipEnabled)
- clipRegion &= clip;
-
- simpleClip = (clipRegion.rects().size() <= 1);
-
- const QRect r = clipRegion.boundingRect();
- gl_setclippingwindow(r.left(), r.top(),
- r.x() + r.width(),
- r.y() + r.height());
-}
-//! [4]
-
-//! [5]
-void SvgalibPaintEngine::drawRects(const QRect *rects, int rectCount)
-{
- const bool canAccelerate = simplePen && simpleBrush && simpleMatrix
- && simpleClip && opaque && aliased
- && sourceOver;
- if (!canAccelerate) {
- QRasterPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- for (int i = 0; i < rectCount; ++i) {
- const QRect r = matrix.mapRect(rects[i]);
- if (brush != Qt::NoBrush) {
- gl_fillbox(r.left(), r.top(), r.width(), r.height(),
- brush.color().rgba());
- }
- if (pen != Qt::NoPen) {
- const int c = pen.color().rgba();
- gl_hline(r.left(), r.top(), r.right(), c);
- gl_hline(r.left(), r.bottom(), r.right(), c);
- gl_line(r.left(), r.top(), r.left(), r.bottom(), c);
- gl_line(r.right(), r.top(), r.right(), r.bottom(), c);
- }
- }
-}
-//! [5]
diff --git a/examples/qws/svgalib/svgalibpaintengine.h b/examples/qws/svgalib/svgalibpaintengine.h
deleted file mode 100644
index 2bbbb0c942..0000000000
--- a/examples/qws/svgalib/svgalibpaintengine.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 SVGALIBPAINTENGINE_H
-#define SVGALIBPAINTENGINE_H
-
-//! [0]
-#include <private/qpaintengine_raster_p.h>
-
-class SvgalibPaintEngine : public QRasterPaintEngine
-{
-public:
- SvgalibPaintEngine(QPaintDevice *device);
- ~SvgalibPaintEngine();
-
- bool begin(QPaintDevice *device);
- bool end();
- void updateState();
- void drawRects(const QRect *rects, int rectCount);
-
-private:
- void setClip(const QRegion &region);
- void updateClip();
-
- QPen pen;
- bool simplePen;
- QBrush brush;
- bool simpleBrush;
- QTransform matrix;
- bool simpleMatrix;
- QRegion clip;
- bool clipEnabled;
- bool simpleClip;
- bool opaque;
- bool aliased;
- bool sourceOver;
- QPaintDevice *device;
-};
-//! [0]
-
-#endif // SVGALIBPAINTENGINE_H
diff --git a/examples/qws/svgalib/svgalibplugin.cpp b/examples/qws/svgalib/svgalibplugin.cpp
deleted file mode 100644
index 993e0ed0a1..0000000000
--- a/examples/qws/svgalib/svgalibplugin.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 "svgalibscreen.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class SvgalibPlugin : public QScreenDriverPlugin
-{
-public:
- SvgalibPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-SvgalibPlugin::SvgalibPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList SvgalibPlugin::keys() const
-{
- return (QStringList() << "svgalib");
-}
-
-QScreen* SvgalibPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() != "svgalib")
- return 0;
-
- return new SvgalibScreen(displayId);
-}
-
-Q_EXPORT_STATIC_PLUGIN(Svgalib)
-Q_EXPORT_PLUGIN2(svgalibscreendriver, SvgalibPlugin)
diff --git a/examples/qws/svgalib/svgalibscreen.cpp b/examples/qws/svgalib/svgalibscreen.cpp
deleted file mode 100644
index 689568d045..0000000000
--- a/examples/qws/svgalib/svgalibscreen.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 "svgalibscreen.h"
-#include "svgalibsurface.h"
-
-#include <QVector>
-#include <QApplication>
-#include <QColor>
-#include <QWidget>
-
-#include <math.h>
-
-static int getModeDepth(vga_modeinfo *mode)
-{
- const int bits = int(log2(mode->colors));
- if (bits == 24 && mode->bytesperpixel == 4)
- return 32;
- return bits;
-}
-
-//! [0]
-bool SvgalibScreen::connect(const QString &displaySpec)
-{
- int mode = vga_getdefaultmode();
- if (mode <= 0) {
- qCritical("SvgalibScreen::connect(): invalid vga mode");
- return false;
- }
-
- vga_modeinfo *modeinfo = vga_getmodeinfo(mode);
-
- QScreen::lstep = modeinfo->linewidth;
- QScreen::dw = QScreen::w = modeinfo->width;
- QScreen::dh = QScreen::h = modeinfo->height;
- QScreen::d = getModeDepth(modeinfo);
- QScreen::size = QScreen::lstep * dh;
- QScreen::data = 0;
-
- switch (depth()) {
- case 32:
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- case 24:
- setPixelFormat(QImage::Format_RGB888);
- break;
- case 16:
- setPixelFormat(QImage::Format_RGB16);
- break;
- case 15:
- setPixelFormat(QImage::Format_RGB555);
- break;
- default:
- break;
- }
-
- const int dpi = 72;
- QScreen::physWidth = qRound(QScreen::dw * 25.4 / dpi);
- QScreen::physHeight = qRound(QScreen::dh * 25.4 / dpi);
-
- const QStringList args = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
- grayscale = args.contains(QLatin1String("grayscale"), Qt::CaseInsensitive);
-
- return true;
-}
-//! [0]
-
-void SvgalibScreen::initColorMap()
-{
- const int numColors = vga_getcolors();
- if (numColors == 2 || numColors > 256) {
- screencols = 0;
- return; // not a palette based mode
- }
-
- if (numColors == 16) {
- if (grayscale) {
- for (int i = 0; i < 256; ++i) {
- const int c = i * 16 / 256;
- vga_setpalette(i, c, c, c);
- }
- screencols = 256; // XXX: takes advantage of optimization in alloc()
- } else { // read in EGA palette
- int r, g, b;
- for (int i = 0; i < 16; ++i) {
- vga_getpalette(i, &r, &g, &b);
- screenclut[i] = qRgb(r, g, b);
- }
- screencols = 16;
- }
-
- return;
- }
-
- Q_ASSERT(numColors == 256);
-
- if (grayscale) {
- for (int i = 0; i < 256; ++i) {
- const int c = i * 64 / 256;
- vga_setpalette(i, c, c, c);
- }
- } else {
- int i = 0;
-
-#if 0
- // read in EGA palette
- while (i < 16) {
- int r, g, b;
- vga_getpalette(i, &r, &g, &b);
- screenclut[i] = qRgb(r, g, b);
- ++i;
- }
- screencols = 16;
-#endif
-
- // 6 * 6 * 6 color cube
- for (int r = 0; r < 6; ++r) {
- for (int g = 0; g < 6; ++g) {
- for (int b = 0; b < 6; ++b) {
- vga_setpalette(i, r * 64/6, g * 64/6, b * 64/6);
- screenclut[i] = qRgb(r * 256/6, g * 256/6, b * 256/6);
- ++i;
- }
- }
- }
- screencols = i;
-
- while (i < 256) {
- screenclut[i] = qRgb(0, 0, 0);
- ++i;
- }
- }
-}
-
-//! [1]
-bool SvgalibScreen::initDevice()
-{
- if (vga_init() != 0) {
- qCritical("SvgalibScreen::initDevice(): unable to initialize svgalib");
- return false;
- }
-
- int mode = vga_getdefaultmode();
- if (vga_setmode(mode) == -1) {
- qCritical("SvgalibScreen::initialize(): unable to set graphics mode");
- return false;
- }
-
- if (gl_setcontextvga(mode) != 0) {
- qCritical("SvgalibScreen::initDevice(): unable to set vga context");
- return false;
- }
- context = gl_allocatecontext();
- gl_getcontext(context);
-
- vga_modeinfo *modeinfo = vga_getmodeinfo(mode);
- if (modeinfo->flags & IS_LINEAR)
- QScreen::data = vga_getgraphmem();
-
- initColorMap();
-
- QScreenCursor::initSoftwareCursor();
- return true;
-}
-//! [1]
-
-//! [2]
-void SvgalibScreen::shutdownDevice()
-{
- gl_freecontext(context);
- vga_setmode(TEXT);
-}
-//! [2]
-
-//! [3]
-void SvgalibScreen::disconnect()
-{
-}
-//! [3]
-
-//! [4]
-void SvgalibScreen::solidFill(const QColor &color, const QRegion &reg)
-{
- int c;
- if (depth() == 4 || depth() == 8)
- c = alloc(color.red(), color.green(), color.blue());
- else
- c = gl_rgbcolor(color.red(), color.green(), color.blue());
-
- const QVector<QRect> rects = (reg & region()).rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- gl_fillbox(r.left(), r.top(), r.width(), r.height(), c);
- }
-}
-//! [4]
-
-void SvgalibScreen::blit16To8(const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- const int imageStride = image.bytesPerLine() / 2;
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i).translated(-topLeft);
- int y = r.y();
- const quint16 *s = reinterpret_cast<const quint16*>(image.scanLine(y));
-
- while (y <= r.bottom()) {
- int x1 = r.x();
- while (x1 <= r.right()) {
- const quint16 c = s[x1];
- int x2 = x1;
- // find span length
- while ((x2+1 < r.right()) && (s[x2+1] == c))
- ++x2;
- gl_hline(x1 + topLeft.x(), y + topLeft.y(), x2 + topLeft.x(),
- qt_colorConvert<quint8, quint16>(c, 0));
- x1 = x2 + 1;
- }
- s += imageStride;
- ++y;
- }
- }
-}
-
-void SvgalibScreen::blit32To8(const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- const int imageStride = image.bytesPerLine() / 4;
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i).translated(-topLeft);
- int y = r.y();
- const quint32 *s = reinterpret_cast<const quint32*>(image.scanLine(y));
-
- while (y <= r.bottom()) {
- int x1 = r.x();
- while (x1 <= r.right()) {
- const quint32 c = s[x1];
- int x2 = x1;
- // find span length
- while ((x2+1 < r.right()) && (s[x2+1] == c))
- ++x2;
- gl_hline(x1 + topLeft.x(), y + topLeft.y(), x2 + topLeft.x(),
- qt_colorConvert<quint8, quint32>(c, 0));
- x1 = x2 + 1;
- }
- s += imageStride;
- ++y;
- }
- }
-}
-
-//! [5]
-void SvgalibScreen::blit(const QImage &img, const QPoint &topLeft,
- const QRegion &reg)
-{
- if (depth() == 8) {
- switch (img.format()) {
- case QImage::Format_RGB16:
- blit16To8(img, topLeft, reg);
- return;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit32To8(img, topLeft, reg);
- return;
- default:
- break;
- }
- }
-
- if (img.format() != pixelFormat()) {
- if (base())
- QScreen::blit(img, topLeft, reg);
- return;
- }
-
- const QVector<QRect> rects = (reg & region()).rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- gl_putboxpart(r.x(), r.y(), r.width(), r.height(),
- img.width(), img.height(),
- static_cast<void*>(const_cast<uchar*>(img.bits())),
- r.x() - topLeft.x(), r.y() - topLeft.y());
- }
-}
-//! [5]
-
-//! [7]
-QWSWindowSurface* SvgalibScreen::createSurface(QWidget *widget) const
-{
- if (base()) {
- static int onScreenPaint = -1;
- if (onScreenPaint == -1)
- onScreenPaint = qgetenv("QT_ONSCREEN_PAINT").toInt();
-
- if (onScreenPaint > 0 || widget->testAttribute(Qt::WA_PaintOnScreen))
- return new SvgalibSurface(widget);
- }
- return QScreen::createSurface(widget);
-}
-//! [7]
-
-//! [8]
-QWSWindowSurface* SvgalibScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("svgalib"))
- return new SvgalibSurface;
- return QScreen::createSurface(key);
-}
-//! [8]
diff --git a/examples/qws/svgalib/svgalibscreen.h b/examples/qws/svgalib/svgalibscreen.h
deleted file mode 100644
index 244375ed18..0000000000
--- a/examples/qws/svgalib/svgalibscreen.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 SVGALIBSCREEN_H
-#define SVGALIBSCREEN_H
-
-#include <QScreen>
-
-#include <vga.h>
-#include <vgagl.h>
-
-//! [0]
-class SvgalibScreen : public QScreen
-{
-public:
- SvgalibScreen(int displayId) : QScreen(displayId) {}
- ~SvgalibScreen() {}
-
- bool connect(const QString &displaySpec);
- bool initDevice();
- void shutdownDevice();
- void disconnect();
-
- void setMode(int, int, int) {}
- void blank(bool) {}
-
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
-//! [0]
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
-//! [1]
-private:
- void initColorMap();
- void blit16To8(const QImage &image,
- const QPoint &topLeft, const QRegion &region);
- void blit32To8(const QImage &image,
- const QPoint &topLeft, const QRegion &region);
-
- GraphicsContext *context;
-};
-//! [1]
-
-#endif // SVGALIBSCREEN_H
diff --git a/examples/qws/svgalib/svgalibsurface.cpp b/examples/qws/svgalib/svgalibsurface.cpp
deleted file mode 100644
index 35f80cbb61..0000000000
--- a/examples/qws/svgalib/svgalibsurface.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 "svgalibsurface.h"
-#include "svgalibpaintdevice.h"
-
-#include <vgagl.h>
-
-SvgalibSurface::SvgalibSurface() : QWSWindowSurface(), pdevice(0)
-{
- setSurfaceFlags(Opaque);
-}
-
-SvgalibSurface::SvgalibSurface(QWidget *w)
- : QWSWindowSurface(w)
-{
- setSurfaceFlags(Opaque);
- pdevice = new SvgalibPaintDevice(w);
-}
-
-SvgalibSurface::~SvgalibSurface()
-{
- delete pdevice;
-}
-
-void SvgalibSurface::setGeometry(const QRect &rect)
-{
- QWSWindowSurface::setGeometry(rect);
-}
-
-QPoint SvgalibSurface::painterOffset() const
-{
- return geometry().topLeft() + QWSWindowSurface::painterOffset();
-}
-
-//! [0]
-bool SvgalibSurface::scroll(const QRegion &region, int dx, int dy)
-{
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- gl_copybox(r.left(), r.top(), r.width(), r.height(),
- r.left() + dx, r.top() + dy);
- }
-
- return true;
-}
-//! [0]
-
diff --git a/examples/qws/svgalib/svgalibsurface.h b/examples/qws/svgalib/svgalibsurface.h
deleted file mode 100644
index fd4fd8e26e..0000000000
--- a/examples/qws/svgalib/svgalibsurface.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 Nokia Corporation 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 SVGALIBSURFACE_H
-#define SVGALIBSURFACE_H
-
-#include "svgalibpaintengine.h"
-#include "svgalibpaintdevice.h"
-#include <private/qwindowsurface_qws_p.h>
-
-class SvgalibPaintDevice;
-
-//! [0]
-class SvgalibSurface : public QWSWindowSurface
-{
-public:
- SvgalibSurface();
- SvgalibSurface(QWidget *w);
- ~SvgalibSurface();
-
- void setGeometry(const QRect &rect);
- bool isValid() const { return true; }
- bool scroll(const QRegion &region, int dx, int dy);
- QString key() const { return QLatin1String("svgalib"); }
-
- bool attach(const QByteArray &) { return true; }
- void detach() {}
-
- QImage image() const { return QImage(); }
- QPaintDevice *paintDevice() { return pdevice; }
- QPoint painterOffset() const;
-
-private:
- SvgalibPaintDevice *pdevice;
-};
-//! [0]
-
-#endif // SVGALIBSURFACE_H