Torsten Hüter wrote:
Hi Marco,
Yes, you're right, the additional cost is another library to maintain. However the bonus is, that it helps to accelerate the drawing speed - exactly because it was optimized for speed. AFAIK even antialiasing should work. It's well supported for Linux / Windows (mingw) / Mac OS X.
I could imagine that for KiCad is a abstract graphics layer is created and different rendering engines are used as plugins (like for instance some emulators use).
I'll play with it at the weekend.
Torsten,
You will need more than a weekend to play with the Kicad drawing code.
I am speaking from experience here. The problem with using any new
device context to do the drawing will not be the device context itself
but the current design of the Kicad drawing code. This has been
discussed before. I do not believe the problem lies completely with
wxDC but rather that Kicad maintains it's own coordinate transformation
(scale, offset, polarity) code outside of wxDC. These transformations
get performed by wxDC irregardless of whether you use them or not. By
default wxDC sets the scale factor and the polarity to 1 and the offset
to 0. If you look at source code for wxDC::DoDrawXXXX() methods, they
all call the LogicalToDevice() method to perform the coordinate
transforms before calling the platform specific low level drawing
functions. So Kicad effectively calculates all drawing coordinates
twice for each draw method call. The other problem is that the
coordinate scaling, offseting, polarity, and transformation code in
Kicad exists in different classes and functions all over the place. I
would like to see a more measured approach to solving the current
problem. Now that there is a KicadGraphicContext class, I propose the
following:
1) Move all of the drawing code in gr_basic.cpp into KicadGraphicContext
and eliminate the global variable ActiveScreen.
2) Perform all of the scaling, Y axis polarity inversion, and transforms
in KicadGraphicContext.
3) Move all of the coordinate offset code calculations into
KicadGraphicContext.
4) Add the clipping rectangle to KicadGraphicContext and remove it form
the parameter list of all the drawing object draw methods.
5) Use the same wxDC method names for setting, getting, and transforming
coordinates between device (screen in Kicad) and logical (drawing in Kicad).