qte和显示设备关联的过程

本文以qte 2.3.10为例,虽然这已经是很老的版本了,但是在某些场合它仍然是非常适合的。

 

qpainter_qws.cpp

  QPainter::begin():

        gfx = ((QPaintDevice *)pdev)->graphicsContext();

 

qwidget_qws.cpp

   QWidget::graphicsContext():

        qgfx_qws=qwsDisplay()->screenGfx();

            QPaintDevice::qwsDisplay(){ return qt_fbdpy; }->screenGfx();

                               QGfx * QWSDisplay::screenGfx(){ return qt_screen->screenGfx(); }

 

从qgfx_qws.cpp开始:

   QGfx *QGfx::createGfx()调用qt_screen->createGfx()来进行关联。qt_screen是个全局变量,它在qgfxraser_qws.cpp中的QScreen *qt_get_screen( int display_id, const char *spec )被初始化。初始化语句为:

qt_screen = driverTable[i].qt_get_screen( display_id );而driverTable又是全局变量,在当qgfxraser_qws.cpp中直接在编译时被赋值:

 

struct DriverTable

{

    char *name;

    QScreen *(*qt_get_screen)(int);

    int accel;

} driverTable [] = { 

#if !defined(QT_NO_QWS_LINUXFB)

    { "LinuxFb", qt_get_screen_linuxfb, 0 },

#endif

#if !defined(QT_NO_QWS_VNC)

    { "VNC", qt_get_screen_vnc, 0 },

#endif

    { 0, 0, 0 },

};

 

而且qgfxraser_qws.cpp根据编译时的参数来包含不同的设备相关的cpp源码文件,如:

#if !defined(QT_NO_QWS_LINUXFB)

#include "qgfxlinuxfb_qws.cpp"

#endif

而且,qgfxraser_qws.cpp中用C++的模板功能实现了最底层的画图功能,如drawLine,drawPoint,但是不包含硬件加速。需要硬件加速的需要要自己另外实现。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值