Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ludmány Balázs
/
thin-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b53b0657
authored
Jul 27, 2016
by
Ludmány Balázs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse buffers
parent
3aeb58bf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
79 additions
and
87 deletions
+79
-87
ThinClient.pro
+1
-1
ThinClient.pro.user
+1
-1
copy_shader.fsh
+1
-2
copy_shader.vsh
+1
-1
dispatcher.cpp
+7
-8
draw_shader.fsh
+1
-2
draw_shader.vsh
+1
-1
jpegdecoder.cpp
+16
-11
main.cpp
+1
-2
main.qml
+3
-2
qvnc.cpp
+2
-2
qvnc.h
+1
-1
uploader.cpp
+38
-48
uploader.h
+3
-3
vncrenderer.cpp
+2
-2
No files found.
ThinClient.pro
View file @
b53b0657
TEMPLATE
=
app
QT
+=
qml
quick
CONFIG
+=
c
++
1
4
CONFIG
+=
c
++
1
1
ofast
SOURCES
+=
main
.
cpp
\
jpegdecoder
.
cpp
\
...
...
ThinClient.pro.user
View file @
b53b0657
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2016-07-2
6T16:47:48
. -->
<!-- Written by QtCreator 3.5.1, 2016-07-2
7T15:57:27
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
copy_shader.fsh
View file @
b53b0657
...
...
@@ -3,6 +3,5 @@ varying mediump vec2 vartexcoord;
void main(void)
{
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb, 1.0);
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragColor = texture2D(texture, vartexcoord);
}
copy_shader.vsh
View file @
b53b0657
...
...
@@ -7,5 +7,5 @@ varying mediump vec2 vartexcoord;
void main(void)
{
gl_Position = vec4((position.x - 1024.0) / 1024.0, (position.y - 1024.0) / 1024.0, 0.0, 1.0);
vartexcoord = vec2(
0.0, 1.0) - vec2(
texcoord.x / 1280.0, texcoord.y / 720.0);
vartexcoord = vec2(texcoord.x / 1280.0, texcoord.y / 720.0);
}
dispatcher.cpp
View file @
b53b0657
...
...
@@ -31,8 +31,7 @@ void Dispatcher::GotBitmap(rfbClient *client, const uint8_t *buffer, int x, int
{
Dispatcher
*
dispatcher
=
(
Dispatcher
*
)
rfbClientGetClientData
(
client
,
0
);
// We have to make a deep copy because libvnc might free the buffer as soon as this function returns
QImage
image
(
buffer
,
w
,
h
,
QImage
::
Format_RGBX8888
);
dispatcher
->
uploader
()
->
gotBitmap
(
image
.
convertToFormat
(
QImage
::
Format_RGB888
),
x
,
y
,
w
,
h
);
dispatcher
->
uploader
()
->
gotBitmap
(
buffer
,
x
,
y
,
w
,
h
);
}
rfbBool
Dispatcher
::
GotJpeg
(
rfbClient
*
client
,
const
uint8_t
*
buffer
,
int
length
,
int
x
,
int
y
,
int
w
,
int
h
)
...
...
@@ -152,21 +151,21 @@ void Dispatcher::refresh()
int
message
=
0
;
// Wait until we get something
while
(
message
==
0
)
{
message
=
WaitForMessage
(
m_client
,
1000
);
if
(
message
<
0
)
{
if
(
!
HandleRFBServerMessage
(
m_client
))
{
terminate
();
emit
error
();
return
;
}
}
if
(
!
HandleRFBServerMessage
(
m_client
))
{
// Wait until we get something
while
(
message
==
0
)
{
message
=
WaitForMessage
(
m_client
,
1000
);
if
(
message
<
0
)
{
terminate
();
emit
error
();
return
;
}
}
}
void
Dispatcher
::
terminate
()
...
...
draw_shader.fsh
View file @
b53b0657
...
...
@@ -4,6 +4,5 @@ varying lowp vec4 varcolor;
void main(void)
{
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb, 1.0) + varcolor;
// gl_FragColor = vec4(vartexcoord, 0.0, 1.0);
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb + varcolor.rgb, 1.0);
}
draw_shader.vsh
View file @
b53b0657
...
...
@@ -10,6 +10,6 @@ varying mediump vec2 vartexcoord;
void main(void)
{
gl_Position = ortho * vec4(position, 0.0, 1.0);
varcolor = color
.gggg
;
varcolor = color;
vartexcoord = vec2(texcoord.x / 2048.0, texcoord.y / 2048.0);
}
jpegdecoder.cpp
View file @
b53b0657
...
...
@@ -9,10 +9,6 @@ JpegDecoder::JpegDecoder(ConcurrentQueue<Jpeg *, 256u> *queue, QObject *parent)
void
JpegDecoder
::
operate
()
{
Jpeg
*
jpeg
;
forever
{
jpeg
=
m_queue
->
dequeue
();
struct
jpeg_decompress_struct
cinfo
;
struct
error_mgr
jerr
;
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
mgr
);
...
...
@@ -21,15 +17,24 @@ void JpegDecoder::operate()
jpeg_destroy_decompress
(
&
cinfo
);
}
jpeg_create_decompress
(
&
cinfo
);
cinfo
.
do_fancy_upsampling
=
TRUE
;
cinfo
.
dct_method
=
JDCT_FLOAT
;
Jpeg
*
jpeg
;
JSAMPLE
*
samples
;
JSAMPROW
*
rows
;
forever
{
jpeg
=
m_queue
->
dequeue
();
jpeg_mem_src
(
&
cinfo
,
jpeg
->
data
,
jpeg
->
length
);
(
void
)
jpeg_read_header
(
&
cinfo
,
TRUE
);
cinfo
.
dct_method
=
JDCT_FASTEST
;
cinfo
.
do_fancy_upsampling
=
FALSE
;
cinfo
.
two_pass_quantize
=
FALSE
;
cinfo
.
dither_mode
=
JDITHER_ORDERED
;
//cinfo.scale_num = 1;
//cinfo.scale_denom = 8;
cinfo
.
out_color_space
=
JCS_EXT_RGBX
;
(
void
)
jpeg_start_decompress
(
&
cinfo
);
JSAMPLE
*
samples
=
new
JSAMPLE
[
cinfo
.
output_width
*
cinfo
.
output_height
*
cinfo
.
output_components
];
JSAMPROW
*
rows
=
new
JSAMPROW
[
cinfo
.
output_height
*
cinfo
.
output_components
];
samples
=
new
JSAMPLE
[
cinfo
.
output_width
*
cinfo
.
output_height
*
cinfo
.
output_components
];
rows
=
new
JSAMPROW
[
cinfo
.
output_height
*
cinfo
.
output_components
];
for
(
size_t
i
=
0
;
i
<
cinfo
.
output_height
;
i
++
)
{
rows
[
i
]
=
samples
+
(
i
*
cinfo
.
output_width
*
cinfo
.
output_components
);
}
...
...
@@ -41,7 +46,7 @@ void JpegDecoder::operate()
emit
finished
(
samples
,
jpeg
->
x
,
jpeg
->
y
,
jpeg
->
width
,
jpeg
->
height
);
delete
[]
jpeg
->
data
;
delete
jpeg
;
delete
rows
;
jpeg_destroy_decompress
(
&
cinfo
);
delete
[]
rows
;
}
jpeg_destroy_decompress
(
&
cinfo
);
}
main.cpp
View file @
b53b0657
...
...
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
format
.
setMajorVersion
(
2
);
format
.
setMinorVersion
(
0
);
format
.
setRenderableType
(
QSurfaceFormat
::
OpenGLES
);
format
.
setSwapBehavior
(
QSurfaceFormat
::
Doub
leBuffer
);
format
.
setSwapBehavior
(
QSurfaceFormat
::
Sing
leBuffer
);
format
.
setSwapInterval
(
0
);
QSurfaceFormat
::
setDefaultFormat
(
format
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_UseOpenGLES
,
true
);
...
...
@@ -28,4 +28,3 @@ int main(int argc, char *argv[])
return
app
.
exec
();
}
main.qml
View file @
b53b0657
...
...
@@ -4,8 +4,8 @@ import thinclient 1.3
ApplicationWindow
{
visible
:
true
width
:
vnc
.
width
height
:
tab
.
height
+
vnc
.
height
width
:
800
height
:
600
id
:
window
header
:
TabBar
{
...
...
@@ -30,5 +30,6 @@ ApplicationWindow {
port
:
10495
width
:
1280
height
:
720
transform
:
Scale
{
xScale
:
window
.
width
/
vnc
.
width
;
yScale
:
(
window
.
height
-
tab
.
height
)
/
vnc
.
height
}
}
}
qvnc.cpp
View file @
b53b0657
...
...
@@ -164,7 +164,7 @@ void QVnc::wheelEvent(QWheelEvent *event)
void
QVnc
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
// Filter mouse move events, we don't need 100+ of them in a second
if
((
event
->
timestamp
()
-
m_lastMouseEvent
)
>
33
)
{
//
if((event->timestamp() - m_lastMouseEvent) > 33) {
Qt
::
MouseButtons
buttons
=
event
->
buttons
();
m_lastMouseEvent
=
event
->
timestamp
();
if
(
m_dispatcher
->
mouseEvent
(
event
->
x
(),
...
...
@@ -177,7 +177,7 @@ void QVnc::mouseMoveEvent(QMouseEvent *event)
event
->
accept
();
else
event
->
ignore
();
}
//
}
}
void
QVnc
::
hoverMoveEvent
(
QHoverEvent
*
event
)
...
...
qvnc.h
View file @
b53b0657
#ifndef VNC_H
#define VNC_H
#define DECODER_COUNT
8
#define DECODER_COUNT
256
#include <QQuickWindow>
#include <QObject>
...
...
uploader.cpp
View file @
b53b0657
This diff is collapsed.
Click to expand it.
uploader.h
View file @
b53b0657
...
...
@@ -40,7 +40,7 @@ struct Indices
{
// 4 corner/rectangle and the first and last one duplicated except for the first and last rectangle
unsigned
short
i
[(
VERTEX_BUFFER
/
4
)
*
6
-
2
];
constexpr
Indices
()
:
i
()
Indices
()
:
i
()
{
i
[
0
]
=
0
;
auto
index
=
1
;
...
...
@@ -51,7 +51,7 @@ struct Indices
}
}
};
const
expr
Indices
ind
;
const
struct
Indices
ind
;
struct
Vertex
{
...
...
@@ -97,7 +97,7 @@ public:
void
gotCopy
(
const
GLushort
src_x
,
const
GLushort
src_y
,
const
GLushort
width
,
const
GLushort
height
,
const
GLushort
dest_x
,
const
GLushort
dest_y
);
void
gotBitmap
(
const
QImage
&
image
,
void
gotBitmap
(
const
unsigned
char
*
image
,
const
GLushort
x
,
const
GLushort
y
,
const
GLushort
width
,
const
GLushort
height
);
void
gotJpeg
();
...
...
vncrenderer.cpp
View file @
b53b0657
...
...
@@ -25,9 +25,9 @@ VncRenderer::VncRenderer(QQuickWindow *window,
void
VncRenderer
::
render
()
{
/*
static QTime frameTime;
static
QTime
frameTime
;
qDebug
()
<<
qRound
(
1000.0
/
frameTime
.
elapsed
())
<<
*
m_drawCount
;
frameTime.restart();
*/
frameTime
.
restart
();
if
(
*
m_drawCount
>
0
)
{
m_program
.
bind
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment