From b0514ccdd318e2e508edab57bfd7ed064a550308 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 9 Mar 2010 14:45:54 +0100 Subject: Minimal fix to get the svgalib example to compile Confirmed to work in 16 and 32 bit modes. Patch made by David Boddie. Testing and README by me. Task-number: QTBUG-7403 Reviewed-by: David Boddie --- doc/src/examples/svgalib.qdoc | 3 -- examples/qws/svgalib/README | 12 +++++--- examples/qws/svgalib/svgalibpaintdevice.cpp | 2 +- examples/qws/svgalib/svgalibpaintengine.cpp | 45 ++++++++++++++--------------- examples/qws/svgalib/svgalibpaintengine.h | 6 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/src/examples/svgalib.qdoc b/doc/src/examples/svgalib.qdoc index cf6512c..9142112 100644 --- a/doc/src/examples/svgalib.qdoc +++ b/doc/src/examples/svgalib.qdoc @@ -43,9 +43,6 @@ \example qws/svgalib \title Accelerated Graphics Driver Example - \warning This example was designed to work with Qt 4.4 and will not work - with current versions of Qt. It will be removed from Qt 4.7. - The Accelerated Graphics Driver example shows how you can write your own accelerated graphics driver and \l {add your graphics driver to Qt for Embedded Linux}. In \l{Qt for Embedded Linux}, diff --git a/examples/qws/svgalib/README b/examples/qws/svgalib/README index 0b2831f..227c066 100644 --- a/examples/qws/svgalib/README +++ b/examples/qws/svgalib/README @@ -1,5 +1,9 @@ -This is the SVGA screen driver plugin example from Qt 4.4. The code does -not compile with Qt 4.5, because the internal graphics engine has changed. +This is the SVGA screen driver plugin example for QWS. -This is unsupported code, provided for convenience in case there is -interest in porting it to Qt 4.5. +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/svgalibpaintdevice.cpp b/examples/qws/svgalib/svgalibpaintdevice.cpp index 090311f..86613d2 100644 --- a/examples/qws/svgalib/svgalibpaintdevice.cpp +++ b/examples/qws/svgalib/svgalibpaintdevice.cpp @@ -48,7 +48,7 @@ SvgalibPaintDevice::SvgalibPaintDevice(QWidget *w) : QCustomRasterPaintDevice(w) { - pengine = new SvgalibPaintEngine; + pengine = new SvgalibPaintEngine(this); } SvgalibPaintDevice::~SvgalibPaintDevice() diff --git a/examples/qws/svgalib/svgalibpaintengine.cpp b/examples/qws/svgalib/svgalibpaintengine.cpp index 8713863..59740da 100644 --- a/examples/qws/svgalib/svgalibpaintengine.cpp +++ b/examples/qws/svgalib/svgalibpaintengine.cpp @@ -45,7 +45,8 @@ #include #include -SvgalibPaintEngine::SvgalibPaintEngine() +SvgalibPaintEngine::SvgalibPaintEngine(QPaintDevice *device) + : QRasterPaintEngine(device) { } @@ -61,7 +62,7 @@ bool SvgalibPaintEngine::begin(QPaintDevice *dev) simplePen = true; brush = Qt::NoBrush; simpleBrush = true; - matrix = QMatrix(); + matrix = QTransform(); simpleMatrix = true; setClip(QRect(0, 0, device->width(), device->height())); opaque = true; @@ -81,54 +82,52 @@ bool SvgalibPaintEngine::end() //! [1] //! [2] -void SvgalibPaintEngine::updateState(const QPaintEngineState &state) +void SvgalibPaintEngine::updateState() { - QPaintEngine::DirtyFlags flags = state.state(); + QRasterPaintEngineState *s = state(); - if (flags & DirtyTransform) { - matrix = state.matrix(); + if (s->dirty & DirtyTransform) { + matrix = s->matrix; simpleMatrix = (matrix.m12() == 0 && matrix.m21() == 0); } - if (flags & DirtyPen) { - pen = state.pen(); + 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 (flags & DirtyBrush) { - brush = state.brush(); + if (s->dirty & DirtyBrush) { + brush = s->brush; simpleBrush = (brush.style() == Qt::SolidPattern || brush.style() == Qt::NoBrush) && (brush.color().alpha() == 255); } - if (flags & DirtyClipRegion) - setClip(state.clipRegion()); + if (s->dirty & DirtyClipRegion) + setClip(s->clipRegion); - if (flags & DirtyClipEnabled) { - clipEnabled = state.isClipEnabled(); + if (s->dirty & DirtyClipEnabled) { + clipEnabled = s->isClipEnabled(); updateClip(); } - if (flags & DirtyClipPath) { + if (s->dirty & DirtyClipPath) { setClip(QRegion()); simpleClip = false; } - if (flags & DirtyCompositionMode) { - const QPainter::CompositionMode m = state.compositionMode(); + if (s->dirty & DirtyCompositionMode) { + const QPainter::CompositionMode m = s->composition_mode; sourceOver = (m == QPainter::CompositionMode_SourceOver); } - if (flags & DirtyOpacity) - opaque = (state.opacity() == 256); + if (s->dirty & DirtyOpacity) + opaque = (s->opacity == 256); - if (flags & DirtyHints) - aliased = !(state.renderHints() & QPainter::Antialiasing); - - QRasterPaintEngine::updateState(state); + if (s->dirty & DirtyHints) + aliased = !(s->flags.antialiased); } //! [2] diff --git a/examples/qws/svgalib/svgalibpaintengine.h b/examples/qws/svgalib/svgalibpaintengine.h index f43d201..27b77ee 100644 --- a/examples/qws/svgalib/svgalibpaintengine.h +++ b/examples/qws/svgalib/svgalibpaintengine.h @@ -48,12 +48,12 @@ class SvgalibPaintEngine : public QRasterPaintEngine { public: - SvgalibPaintEngine(); + SvgalibPaintEngine(QPaintDevice *device); ~SvgalibPaintEngine(); bool begin(QPaintDevice *device); bool end(); - void updateState(const QPaintEngineState &state); + void updateState(); void drawRects(const QRect *rects, int rectCount); private: @@ -64,7 +64,7 @@ private: bool simplePen; QBrush brush; bool simpleBrush; - QMatrix matrix; + QTransform matrix; bool simpleMatrix; QRegion clip; bool clipEnabled; -- cgit v0.12