如何清除 XFixes 区域
我正在为 X11 平台编写一些低级代码。为了实现最佳数据复制性能,我使用 XFixes/XDamage 扩展。
如何在一个刷新周期后清除 XFixes 区域的内容?或者在我使用 XFixesSetPictureClipRegion 后它们会自行清理吗?
我的代码是这样的:
Display xdpy;
XShamPixmap pixmap_;
XFixesRegion region_;
damage_event_callback(damage_geometry_t geometry, XDamage damage,...) {
unsigned curr_region = XFixesCreateRegion(xdpy, 0, 0);
XDamageSubtract(xdpy, damage, None, curr_region);
XFixesTranslateRegion( xdpy, curr_region, geometry.left(), geometry.top() );
XFixesUnionRegion (xdpy, region_, region_, curr_region);
}
process_damage_events(...) {
XFixesSetPictureClipRegion( xdpy, pixmap_, 0, 0, region_);
XCopyArea (xdpy, window_->id(),
pixmap_, XDefaultGC(xdpy, XDefaultScreen(xdpy)),
0,0,width(),height(),0,0);
/*Should clear region_ here
*/
...
}
目前我通过删除和重新创建来清除该区域,但我想这不是最好的方法。
I'm writing some low level code for X11 platform. To achieve best data copying performance I use XFixes/XDamage extensions.
How can I clear the contents of XFixes region after one refresh cycle? Or do they clean themselves after I use XFixesSetPictureClipRegion?
My code is something like that:
Display xdpy;
XShamPixmap pixmap_;
XFixesRegion region_;
damage_event_callback(damage_geometry_t geometry, XDamage damage,...) {
unsigned curr_region = XFixesCreateRegion(xdpy, 0, 0);
XDamageSubtract(xdpy, damage, None, curr_region);
XFixesTranslateRegion( xdpy, curr_region, geometry.left(), geometry.top() );
XFixesUnionRegion (xdpy, region_, region_, curr_region);
}
process_damage_events(...) {
XFixesSetPictureClipRegion( xdpy, pixmap_, 0, 0, region_);
XCopyArea (xdpy, window_->id(),
pixmap_, XDefaultGC(xdpy, XDefaultScreen(xdpy)),
0,0,width(),height(),0,0);
/*Should clear region_ here
*/
...
}
Currently I clear the region by deleting and recreating, but I guess it's not the best way to do that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你所说的清理该区域是什么意思;您的意思是取消图片上的剪辑,或释放该区域?
要取消设置剪辑,我的猜测是您将剪辑区域设置为 None
要释放区域 XFixesDestroyRegion()
要使区域为空,您可能可以 XFixesSetRegion(dpy, Region, NULL, 0) 但我不确定这会改变除非您再次 XFixesSetPictureClipRegion ,否则剪辑在图片上。
I'm not sure what you mean by clearing the region; you mean unsetting the clip on your picture, or freeing the region?
To unset the clip my guess is you'd set the clip region to None
To free the region XFixesDestroyRegion()
To make the region empty you can probably XFixesSetRegion(dpy, region, NULL, 0) but I'm not sure that will change the clip on the picture unless you XFixesSetPictureClipRegion again.