aboutsummaryrefslogtreecommitdiffstats
path: root/unix/x0vncserver/Image.cxx
diff options
context:
space:
mode:
authorPeter Åstrand (astrand) <astrand@cendio.se>2018-01-15 15:17:39 +0100
committerPeter Åstrand (astrand) <astrand@cendio.se>2018-01-15 15:17:39 +0100
commit46fab93cbdc6f114f63279f0268ea3be94cd2922 (patch)
treec06eb16fabde422a293873c64b3c3995c4df3d4c /unix/x0vncserver/Image.cxx
parent5f4972547d43f271e03d6113aae57d1654c683e2 (diff)
downloadtigervnc-46fab93cbdc6f114f63279f0268ea3be94cd2922.tar.gz
tigervnc-46fab93cbdc6f114f63279f0268ea3be94cd2922.zip
Use XShmGetImage for large reads
XShmGetImage is much faster. On my machine, this reduces the CPU usage of a fullscreen Youtube video playback from 40% to 25%.
Diffstat (limited to 'unix/x0vncserver/Image.cxx')
-rw-r--r--unix/x0vncserver/Image.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/unix/x0vncserver/Image.cxx b/unix/x0vncserver/Image.cxx
index ca3d6429..f1a45933 100644
--- a/unix/x0vncserver/Image.cxx
+++ b/unix/x0vncserver/Image.cxx
@@ -315,8 +315,13 @@ void ShmImage::get(Window wnd, int x, int y)
void ShmImage::get(Window wnd, int x, int y, int w, int h,
int dst_x, int dst_y)
{
- // FIXME: Use SHM for this as well?
- XGetSubImage(dpy, wnd, x, y, w, h, AllPlanes, ZPixmap, xim, dst_x, dst_y);
+ // XShmGetImage is faster, but can only retrieve the entire
+ // window. Use it for large reads.
+ if (x == dst_x && y == dst_y && (long)w * h > (long)xim->width * xim->height / 4) {
+ XShmGetImage(dpy, wnd, xim, 0, 0, AllPlanes);
+ } else {
+ XGetSubImage(dpy, wnd, x, y, w, h, AllPlanes, ZPixmap, xim, dst_x, dst_y);
+ }
}
//