XPutImage出现问题 [英] Having issues with XPutImage

查看:229
本文介绍了XPutImage出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这些函数调用:

OSPImgBlit(&img->_obj, &win1->_obj, 0, 0, 0, 0, 640, 480);
OSPRun(&win1->_obj, OSPWND_SWAP);

对于这些实现:

void OSPwnd_swap(OSPobj *obj, va_list arg) {
    OSPwindow *wnd = (OSPwindow *) obj;
    XdbeSwapInfo swpifo;

    swpifo.swap_window = wnd->_wnd;
    swpifo.swap_action = XdbeUndefined;

    // XdbeSwapBuffers returns true on success, we return 0 on success.
    if(XdbeSwapBuffers(wnd->_dpy->_dpy, &swpifo, 1)) {
        OSPrint(1, "OSPwnd_swap : Window %d swapped "
                    "on connection %d",
                    wnd->_wnd, XConnectionNumber(wnd->_dpy->_dpy));
/*      XFlush(wnd->_dpy->_dpy); */
    }
    else {
        OSPrint(1, "OSPwnd_swap : Unable to swap window %d "
                    "on connection %d",
                    wnd->_wnd, XConnectionNumber(wnd->_dpy->_dpy));
    }
}

void OSPImgBlit(OSPobj *orig, OSPobj *dest, int x_orig, int y_orig,
            int x_dest, int y_dest, unsigned int width, unsigned int height) {
    OSPimage *orig_as_image = (OSPimage *) orig;
    OSPwindow *orig_as_window = (OSPwindow *) orig;
    OSPimage *dest_as_image = (OSPimage *) dest;
    OSPwindow *dest_as_window = (OSPwindow *) dest;

    enum {
        image_to_image = 0,
        image_to_window = 1,
        window_to_image = 2,
        window_to_window = 3
    } mode = image_to_window;

    switch(mode) {
        case image_to_window:
            XPutImage(dest_as_window->_dpy->_dpy, dest_as_window->_bbf,
                        dest_as_window->_gc, orig_as_image->_img,
                        x_orig, y_orig, x_dest, y_dest, width, height);
        default:;
    }
}

整个代码在这里: https://github.com/DJTECKING/OSPOOC.git

我的应用程序正确启动,但是当我尝试关闭创建的窗口时,它随机发生以下行为之一: -segfault -X_PutImage上的BadDrawable -什么都没有(关闭窗口上的关闭按钮无效) -正确关闭窗口和应用程序

My application starts correctly but when I attempt to close the window I created, it happen one of these behavior randomly : - segfault - BadDrawable on X_PutImage - nothing (not working close button on closing window) - Correctly closed window and application

我猜好像我正在使用一个已经关闭的窗口或已释放的图像, 但是在整个代码中,我不明白这怎么发生,有什么想法吗?

I guess something like I'm using a already closed window or freed image, but in the entire code I don't understand how can this happen, any idea?

XPutImage也只能遮盖一个正方形 当我尝试复制整个窗口时.

Also XPutImage only blits a square while I was attempting to copy the whole window.

另一个可能与此主题分开的问题, 即使使用Xdouble缓冲区扩展,我仍然会遇到难看的撕裂效果, 该扩展程序不是应该避免这种情况吗?

Yet another question that might be separated of this topic, I continue to face ugly tearing effects, even with Xdouble buffer extension, was not this extension supposed to avoid this?

我没有10个声誉,因此这里是直接的图片链接: http://i.stack.imgur.com/AnlMo.png

I haven't 10 reputation so here is direct image link: http://i.stack.imgur.com/AnlMo.png

推荐答案

撕裂效果可能归因于Xdbe mate的实现 在Waylang下对fedora22没有撕裂效果.

Tearing effects might due to Xdbe mate implementation No tearing effects under waylang on fedora22.

Segfault和BadDrawable是由于OSPwnd:OSPDpyHdl中的事件处理循环所致. 直到事件队列为空,直到关闭窗口上的事件到达之前,其他事件(例如鼠标指针进入窗口)才停止. 然后OSPDpyHdl在使用对象检索下一个事件之前先删除它们. 从OSPDpyHdl返回之前,也没有对这些事件进行彻底的处理.

Segfault and BadDrawable is due to the event processing loop in OSPwnd:OSPDpyHdl. It wasn't stopping till the event queue was empty, events on closing window arrived before other one like mouse pointer entering window. Then OSPDpyHdl was deleting objects before using them to retrieve next events. These events were also not treated corectly before returning from OSPDpyHdl.

部分XPutImage是由于以下事实: 用户无法按[x] [y]顺序访问图像的数据表 由于图像在内存中是连续的. 因此win-> _ data [y]访问每一行,win-> _ data [y] [x]每个像素.

Partial XPutImage was due to the fact that user can't access data table of an image by the [x][y] order since image is line contigous in memory. So win->_data[y] accesses to each line and win->_data[y][x] each pixel.

问题在于,所有图像每秒发送60次,这阻碍了X连接并禁用了服务器的响应性.

The problem is that all image is sent 60 times per second encumbering the X connection and disabling server reactivity.

这篇关于XPutImage出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆