added: make bitx11 use CDebugWindow
This commit is contained in:
parent
fefbff6979
commit
e14a8da618
2 changed files with 7 additions and 58 deletions
|
@ -102,7 +102,6 @@ CBitX11::CBitX11(int argc, char *argv[])
|
||||||
m_pictattr.repeat = RepeatNone;
|
m_pictattr.repeat = RepeatNone;
|
||||||
|
|
||||||
memset(&m_transform, 0, sizeof(m_transform));
|
memset(&m_transform, 0, sizeof(m_transform));
|
||||||
memset(&m_debugtransform, 0, sizeof(m_debugtransform));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBitX11::~CBitX11()
|
CBitX11::~CBitX11()
|
||||||
|
@ -138,20 +137,7 @@ void CBitX11::Setup()
|
||||||
XShmAttach(m_dpy, &m_shmseginfo);
|
XShmAttach(m_dpy, &m_shmseginfo);
|
||||||
|
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
{
|
m_debugwindow.Enable(m_destwidth, m_destheight, m_debugscale);
|
||||||
m_debugwindow = XCreateSimpleWindow(m_dpy, RootWindow(m_dpy, DefaultScreen(m_dpy)),
|
|
||||||
0, 0, m_destwidth * m_debugscale, m_destheight * m_debugscale, 0, 0, 0);
|
|
||||||
XMapWindow(m_dpy, m_debugwindow);
|
|
||||||
XFlush(m_dpy);
|
|
||||||
|
|
||||||
m_debuggc = XCreateGC(m_dpy, m_debugwindow, 0, NULL);
|
|
||||||
m_debugpixmap = XCreatePixmap(m_dpy, m_rootwin, m_destwidth, m_destheight, m_rootattr.depth);
|
|
||||||
m_debugsrcformat = XRenderFindVisualFormat(m_dpy, m_rootattr.visual);
|
|
||||||
m_debugdstformat = XRenderFindVisualFormat(m_dpy, m_rootattr.visual);
|
|
||||||
m_debugsrcpicture = XRenderCreatePicture(m_dpy, m_debugpixmap, m_debugsrcformat, CPRepeat, &m_pictattr);
|
|
||||||
m_debugdstpicture = XRenderCreatePicture(m_dpy, m_debugwindow, m_debugdstformat, CPRepeat, &m_pictattr);
|
|
||||||
XRenderSetPictureFilter(m_dpy, m_debugsrcpicture, "nearest", NULL, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBitX11::Process()
|
void CBitX11::Process()
|
||||||
|
@ -282,39 +268,7 @@ void CBitX11::Process()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_debug)
|
m_debugwindow.DisplayFrame(data);
|
||||||
{
|
|
||||||
//write the quantized and dithered planes back into the Ximage
|
|
||||||
for (int y = 0; y < m_destheight; y++)
|
|
||||||
{
|
|
||||||
uint8_t* ximline = (uint8_t*)m_xim->data + y * m_xim->bytes_per_line;
|
|
||||||
uint8_t* ximend = ximline + m_xim->bytes_per_line;
|
|
||||||
int* planeliner = planes[0] + y * planewidth + 1;
|
|
||||||
int* planelineg = planes[1] + y * planewidth + 1;
|
|
||||||
|
|
||||||
while (ximline != ximend)
|
|
||||||
{
|
|
||||||
*(ximline++) = 0;
|
|
||||||
*(ximline++) = Clamp(*(planelineg++), 0, 255);
|
|
||||||
*(ximline++) = Clamp(*(planeliner++), 0, 255);
|
|
||||||
ximline++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//write the Ximage back into the pixmap
|
|
||||||
XShmPutImage(m_dpy, m_debugpixmap, m_debuggc, m_xim, 0, 0, 0, 0, m_destwidth, m_destheight, False);
|
|
||||||
|
|
||||||
m_debugtransform.matrix[0][0] = m_destwidth;
|
|
||||||
m_debugtransform.matrix[1][1] = m_destwidth;
|
|
||||||
m_debugtransform.matrix[2][2] = m_destwidth * m_debugscale;
|
|
||||||
|
|
||||||
//render the pixmap on the debug window, scaled by m_debugscale
|
|
||||||
XRenderSetPictureTransform (m_dpy, m_debugsrcpicture, &m_debugtransform);
|
|
||||||
XRenderComposite(m_dpy, PictOpSrc, m_debugsrcpicture, None, m_debugdstpicture,
|
|
||||||
0, 0, 0, 0, 0, 0, m_destwidth * m_debugscale, m_destheight * m_debugscale);
|
|
||||||
|
|
||||||
XFlush(m_dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
looptime += Round64(1000000.0f / m_fps);
|
looptime += Round64(1000000.0f / m_fps);
|
||||||
USleep(looptime - GetTimeUs());
|
USleep(looptime - GetTimeUs());
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define BITX11_H
|
#define BITX11_H
|
||||||
|
|
||||||
#include "util/tcpsocket.h"
|
#include "util/tcpsocket.h"
|
||||||
|
#include "util/debugwindow.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/extensions/Xrender.h>
|
#include <X11/extensions/Xrender.h>
|
||||||
|
@ -44,6 +45,10 @@ class CBitX11
|
||||||
float m_fps;
|
float m_fps;
|
||||||
bool m_dither;
|
bool m_dither;
|
||||||
|
|
||||||
|
bool m_debug;
|
||||||
|
int m_debugscale;
|
||||||
|
CDebugWindow m_debugwindow;
|
||||||
|
|
||||||
CTcpClientSocket m_socket;
|
CTcpClientSocket m_socket;
|
||||||
|
|
||||||
Display* m_dpy;
|
Display* m_dpy;
|
||||||
|
@ -63,16 +68,6 @@ class CBitX11
|
||||||
XShmSegmentInfo m_shmseginfo;
|
XShmSegmentInfo m_shmseginfo;
|
||||||
XImage* m_xim;
|
XImage* m_xim;
|
||||||
|
|
||||||
bool m_debug;
|
|
||||||
int m_debugscale;
|
|
||||||
Window m_debugwindow;
|
|
||||||
GC m_debuggc;
|
|
||||||
Pixmap m_debugpixmap;
|
|
||||||
XRenderPictFormat* m_debugsrcformat;
|
|
||||||
XRenderPictFormat* m_debugdstformat;
|
|
||||||
Picture m_debugsrcpicture;
|
|
||||||
Picture m_debugdstpicture;
|
|
||||||
XTransform m_debugtransform;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BITX11_H
|
#endif //BITX11_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue