Opened 19 years ago

Closed 19 years ago

#17 closed enhancement (fixed)

Add the canvas module (QCanvas class)

Reported by: dmik Owned by: dmik
Priority: normal Milestone: qt-os2-3.3.1-rc07
Component: [general] Version:
Severity: normal Keywords: canvas module
Cc:

Description

Everyting is ready to add the canvas module to the OS/2 version of Qt.

Change History (4)

comment:1 by dmik, 19 years ago

Status: newassigned

comment:2 by dmik, 19 years ago

The canvas module has been added.

On OS/2, we use regions to scan polygons (in QCanvasPolygonalItem implementation) to determine what canvas chunks they intersect with. This is because QPolygonScanner (used on other platforms) is not actually capable to correctly scan polygons in all-inclusive mode (i.e. when points on all four edges of the polygon are part of it), while in OS/2 polygons (and regions created from them) are always all-inclusive. I guess that this method of scanning is at least as fast as QPolygonScanner (based on Xserver sources). Until I did it, moving polygonal items caused drawing artefacts to appear in the canvas view.

Note that setting up a transofmation matrix on a canvas view (the QCanvasView}} class) can decrease the performance (when moving items, redrawing, etc.) proportionally to the scale factor defined by the matrix, if pixmaps with alpha channel ({{{QCanvasPixmap items) intersect with the item being moved or redrawn. This performance decrease also happens in Qt on my Linux platform add is due to the hardware alpha channel acceleration support missing in OS/2 and Linux video drivers.

comment:3 by dmik, 19 years ago

Also note, that setting a non-identity transformation matrix on a canvas view will cause various artefacts (try to scroll the canvas view quickly when the canvas is zoomed in or move another window on top of it) or distortions (try to move canvas items when the canvas is zoomed out). This behavior can be seen on all platforms (Win32, Linux) with any Qt 3.3.x version upto 3.3.3.

As I found, the reason for the former problem is rounding errors (hey, how could they keep this bug for so long?) happening when the inverted transformation matrix is applied to the rectangle defining the area of the canvas view to repaint/update. As a result, wrong chunks are invalidated on item's edges. The latter problem can be caused by the same issue.

comment:4 by dmik, 19 years ago

Resolution: fixed
Status: assignedclosed

All my fixes to QCanvas are enclosed with the #if !defined(QT_NO_CANVAS_ROUNDING_FIX) construct, so if one wants to disable them he should define the QT_NO_CANVAS_ROUNDING_FIX macro. So far, these fixes is tested on OS/2 only, so it QT_NO_CANVAS_ROUNDING_FIX is defined (i.e. no fixes) for all other platforms.

Playing more with QCanvas, I came to a conclusion that there is a general problem in the QCanvas design: it operates on integers (instead of doubles) when doing series of direct and inverse transformations in a row, that results in a big inaccuracy (more than one pixel in some cases). My hacks give much much better results when the canvas is scaled, sheared or rotated in the canvas view; however they are just quick patches and not that perfect -- some artefacts are still theoretically possible (in rare cases, though).

Note: See TracTickets for help on using tickets.