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
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
84 additions
and
92 deletions
+84
-92
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
+21
-16
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
TEMPLATE
=
app
QT
+=
qml
quick
QT
+=
qml
quick
CONFIG
+=
c
++
1
4
CONFIG
+=
c
++
1
1
ofast
SOURCES
+=
main
.
cpp
\
SOURCES
+=
main
.
cpp
\
jpegdecoder
.
cpp
\
jpegdecoder
.
cpp
\
...
...
ThinClient.pro.user
View file @
b53b0657
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!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>
<qtcreator>
<data>
<data>
<variable>
EnvironmentId
</variable>
<variable>
EnvironmentId
</variable>
...
...
copy_shader.fsh
View file @
b53b0657
...
@@ -3,6 +3,5 @@ varying mediump vec2 vartexcoord;
...
@@ -3,6 +3,5 @@ varying mediump vec2 vartexcoord;
void main(void)
void main(void)
{
{
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb, 1.0);
gl_FragColor = texture2D(texture, vartexcoord);
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
}
copy_shader.vsh
View file @
b53b0657
...
@@ -7,5 +7,5 @@ varying mediump vec2 vartexcoord;
...
@@ -7,5 +7,5 @@ varying mediump vec2 vartexcoord;
void main(void)
void main(void)
{
{
gl_Position = vec4((position.x - 1024.0) / 1024.0, (position.y - 1024.0) / 1024.0, 0.0, 1.0);
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
...
@@ -31,8 +31,7 @@ void Dispatcher::GotBitmap(rfbClient *client, const uint8_t *buffer, int x, int
{
{
Dispatcher
*
dispatcher
=
(
Dispatcher
*
)
rfbClientGetClientData
(
client
,
0
);
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
// 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
(
buffer
,
x
,
y
,
w
,
h
);
dispatcher
->
uploader
()
->
gotBitmap
(
image
.
convertToFormat
(
QImage
::
Format_RGB888
),
x
,
y
,
w
,
h
);
}
}
rfbBool
Dispatcher
::
GotJpeg
(
rfbClient
*
client
,
const
uint8_t
*
buffer
,
int
length
,
int
x
,
int
y
,
int
w
,
int
h
)
rfbBool
Dispatcher
::
GotJpeg
(
rfbClient
*
client
,
const
uint8_t
*
buffer
,
int
length
,
int
x
,
int
y
,
int
w
,
int
h
)
...
@@ -152,6 +151,12 @@ void Dispatcher::refresh()
...
@@ -152,6 +151,12 @@ void Dispatcher::refresh()
int
message
=
0
;
int
message
=
0
;
if
(
!
HandleRFBServerMessage
(
m_client
))
{
terminate
();
emit
error
();
return
;
}
// Wait until we get something
// Wait until we get something
while
(
message
==
0
)
{
while
(
message
==
0
)
{
message
=
WaitForMessage
(
m_client
,
1000
);
message
=
WaitForMessage
(
m_client
,
1000
);
...
@@ -161,12 +166,6 @@ void Dispatcher::refresh()
...
@@ -161,12 +166,6 @@ void Dispatcher::refresh()
return
;
return
;
}
}
}
}
if
(
!
HandleRFBServerMessage
(
m_client
))
{
terminate
();
emit
error
();
return
;
}
}
}
void
Dispatcher
::
terminate
()
void
Dispatcher
::
terminate
()
...
...
draw_shader.fsh
View file @
b53b0657
...
@@ -4,6 +4,5 @@ varying lowp vec4 varcolor;
...
@@ -4,6 +4,5 @@ varying lowp vec4 varcolor;
void main(void)
void main(void)
{
{
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb, 1.0) + varcolor;
gl_FragColor = vec4(texture2D(texture, vartexcoord).rgb + varcolor.rgb, 1.0);
// gl_FragColor = vec4(vartexcoord, 0.0, 1.0);
}
}
draw_shader.vsh
View file @
b53b0657
...
@@ -10,6 +10,6 @@ varying mediump vec2 vartexcoord;
...
@@ -10,6 +10,6 @@ varying mediump vec2 vartexcoord;
void main(void)
void main(void)
{
{
gl_Position = ortho * vec4(position, 0.0, 1.0);
gl_Position = ortho * vec4(position, 0.0, 1.0);
varcolor = color
.gggg
;
varcolor = color;
vartexcoord = vec2(texcoord.x / 2048.0, texcoord.y / 2048.0);
vartexcoord = vec2(texcoord.x / 2048.0, texcoord.y / 2048.0);
}
}
jpegdecoder.cpp
View file @
b53b0657
...
@@ -9,27 +9,32 @@ JpegDecoder::JpegDecoder(ConcurrentQueue<Jpeg *, 256u> *queue, QObject *parent)
...
@@ -9,27 +9,32 @@ JpegDecoder::JpegDecoder(ConcurrentQueue<Jpeg *, 256u> *queue, QObject *parent)
void
JpegDecoder
::
operate
()
void
JpegDecoder
::
operate
()
{
{
struct
jpeg_decompress_struct
cinfo
;
struct
error_mgr
jerr
;
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
mgr
);
jerr
.
mgr
.
error_exit
=
error_exit
;
if
(
setjmp
(
jerr
.
setjmp_buffer
))
{
jpeg_destroy_decompress
(
&
cinfo
);
}
jpeg_create_decompress
(
&
cinfo
);
Jpeg
*
jpeg
;
Jpeg
*
jpeg
;
JSAMPLE
*
samples
;
JSAMPROW
*
rows
;
forever
{
forever
{
jpeg
=
m_queue
->
dequeue
();
jpeg
=
m_queue
->
dequeue
();
struct
jpeg_decompress_struct
cinfo
;
struct
error_mgr
jerr
;
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
mgr
);
jerr
.
mgr
.
error_exit
=
error_exit
;
if
(
setjmp
(
jerr
.
setjmp_buffer
))
{
jpeg_destroy_decompress
(
&
cinfo
);
}
jpeg_create_decompress
(
&
cinfo
);
cinfo
.
do_fancy_upsampling
=
TRUE
;
cinfo
.
dct_method
=
JDCT_FLOAT
;
jpeg_mem_src
(
&
cinfo
,
jpeg
->
data
,
jpeg
->
length
);
jpeg_mem_src
(
&
cinfo
,
jpeg
->
data
,
jpeg
->
length
);
(
void
)
jpeg_read_header
(
&
cinfo
,
TRUE
);
(
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
);
(
void
)
jpeg_start_decompress
(
&
cinfo
);
JSAMPLE
*
samples
=
new
JSAMPLE
[
cinfo
.
output_width
*
cinfo
.
output_height
*
cinfo
.
output_components
];
samples
=
new
JSAMPLE
[
cinfo
.
output_width
*
cinfo
.
output_height
*
cinfo
.
output_components
];
JSAMPROW
*
rows
=
new
JSAMPROW
[
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
++
)
{
for
(
size_t
i
=
0
;
i
<
cinfo
.
output_height
;
i
++
)
{
rows
[
i
]
=
samples
+
(
i
*
cinfo
.
output_width
*
cinfo
.
output_components
);
rows
[
i
]
=
samples
+
(
i
*
cinfo
.
output_width
*
cinfo
.
output_components
);
}
}
...
@@ -41,7 +46,7 @@ void JpegDecoder::operate()
...
@@ -41,7 +46,7 @@ void JpegDecoder::operate()
emit
finished
(
samples
,
jpeg
->
x
,
jpeg
->
y
,
jpeg
->
width
,
jpeg
->
height
);
emit
finished
(
samples
,
jpeg
->
x
,
jpeg
->
y
,
jpeg
->
width
,
jpeg
->
height
);
delete
[]
jpeg
->
data
;
delete
[]
jpeg
->
data
;
delete
jpeg
;
delete
jpeg
;
delete
rows
;
delete
[]
rows
;
jpeg_destroy_decompress
(
&
cinfo
);
}
}
jpeg_destroy_decompress
(
&
cinfo
);
}
}
main.cpp
View file @
b53b0657
...
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
...
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
format
.
setMajorVersion
(
2
);
format
.
setMajorVersion
(
2
);
format
.
setMinorVersion
(
0
);
format
.
setMinorVersion
(
0
);
format
.
setRenderableType
(
QSurfaceFormat
::
OpenGLES
);
format
.
setRenderableType
(
QSurfaceFormat
::
OpenGLES
);
format
.
setSwapBehavior
(
QSurfaceFormat
::
Doub
leBuffer
);
format
.
setSwapBehavior
(
QSurfaceFormat
::
Sing
leBuffer
);
format
.
setSwapInterval
(
0
);
format
.
setSwapInterval
(
0
);
QSurfaceFormat
::
setDefaultFormat
(
format
);
QSurfaceFormat
::
setDefaultFormat
(
format
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_UseOpenGLES
,
true
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_UseOpenGLES
,
true
);
...
@@ -28,4 +28,3 @@ int main(int argc, char *argv[])
...
@@ -28,4 +28,3 @@ int main(int argc, char *argv[])
return
app
.
exec
();
return
app
.
exec
();
}
}
main.qml
View file @
b53b0657
...
@@ -4,8 +4,8 @@ import thinclient 1.3
...
@@ -4,8 +4,8 @@ import thinclient 1.3
ApplicationWindow
{
ApplicationWindow
{
visible
:
true
visible
:
true
width
:
vnc
.
width
width
:
800
height
:
tab
.
height
+
vnc
.
height
height
:
600
id
:
window
id
:
window
header
:
TabBar
{
header
:
TabBar
{
...
@@ -30,5 +30,6 @@ ApplicationWindow {
...
@@ -30,5 +30,6 @@ ApplicationWindow {
port
:
10495
port
:
10495
width
:
1280
width
:
1280
height
:
720
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)
...
@@ -164,7 +164,7 @@ void QVnc::wheelEvent(QWheelEvent *event)
void
QVnc
::
mouseMoveEvent
(
QMouseEvent
*
event
)
void
QVnc
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
{
// Filter mouse move events, we don't need 100+ of them in a second
// 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
();
Qt
::
MouseButtons
buttons
=
event
->
buttons
();
m_lastMouseEvent
=
event
->
timestamp
();
m_lastMouseEvent
=
event
->
timestamp
();
if
(
m_dispatcher
->
mouseEvent
(
event
->
x
(),
if
(
m_dispatcher
->
mouseEvent
(
event
->
x
(),
...
@@ -177,7 +177,7 @@ void QVnc::mouseMoveEvent(QMouseEvent *event)
...
@@ -177,7 +177,7 @@ void QVnc::mouseMoveEvent(QMouseEvent *event)
event
->
accept
();
event
->
accept
();
else
else
event
->
ignore
();
event
->
ignore
();
}
//
}
}
}
void
QVnc
::
hoverMoveEvent
(
QHoverEvent
*
event
)
void
QVnc
::
hoverMoveEvent
(
QHoverEvent
*
event
)
...
...
qvnc.h
View file @
b53b0657
#ifndef VNC_H
#ifndef VNC_H
#define VNC_H
#define VNC_H
#define DECODER_COUNT
8
#define DECODER_COUNT
256
#include <QQuickWindow>
#include <QQuickWindow>
#include <QObject>
#include <QObject>
...
...
uploader.cpp
View file @
b53b0657
...
@@ -5,7 +5,7 @@ Uploader::Uploader(QObject *parent) :
...
@@ -5,7 +5,7 @@ Uploader::Uploader(QObject *parent) :
QObject
(
parent
),
m_context
(
this
),
m_indices
(
QOpenGLBuffer
::
IndexBuffer
),
QObject
(
parent
),
m_context
(
this
),
m_indices
(
QOpenGLBuffer
::
IndexBuffer
),
m_uploadVertices
(
new
QOpenGLBuffer
*
),
m_renderVertices
(
new
QOpenGLBuffer
*
),
m_uploadVertices
(
new
QOpenGLBuffer
*
),
m_renderVertices
(
new
QOpenGLBuffer
*
),
m_uploadTexture
(
new
GLuint
*
),
m_renderTexture
(
new
GLuint
*
),
m_program
(
this
),
m_jpegs
(
0
),
m_uploadTexture
(
new
GLuint
*
),
m_renderTexture
(
new
GLuint
*
),
m_program
(
this
),
m_jpegs
(
0
),
m_atlasX
(
0
),
m_atlasY
(
0
),
m_atlasRowHeight
(
0
),
m_atlasLastWidth
(
0
),
m_copyIndex
(
0
)
m_atlasX
(
1
),
m_atlasY
(
1
),
m_atlasRowHeight
(
0
),
m_atlasLastWidth
(
0
),
m_copyIndex
(
0
)
{
{
// "applications must ensure that create() is only called on the main (GUI) thread"
// "applications must ensure that create() is only called on the main (GUI) thread"
m_surface
.
create
();
m_surface
.
create
();
...
@@ -29,24 +29,9 @@ void Uploader::createContext(QOpenGLContext *context)
...
@@ -29,24 +29,9 @@ void Uploader::createContext(QOpenGLContext *context)
m_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Vertex
,
"copy_shader.vsh"
);
m_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Vertex
,
"copy_shader.vsh"
);
m_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Fragment
,
"copy_shader.fsh"
);
m_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Fragment
,
"copy_shader.fsh"
);
m_program
.
bind
();
m_program
.
bind
();
m_program
.
setUniformValue
(
"texture"
,
0
);
m_program
.
setUniformValue
(
"texture"
,
1
);
QMatrix4x4
ortho
;
ortho
.
ortho
(
0
,
TEXTURE_WIDTH
,
0
,
TEXTURE_HEIGHT
,
-
1
,
1
);
// m_program.setUniformValue("ortho", ortho);
m_program
.
enableAttributeArray
(
"position"
);
m_program
.
enableAttributeArray
(
"position"
);
m_program
.
enableAttributeArray
(
"texcoord"
);
m_program
.
enableAttributeArray
(
"texcoord"
);
m_functions
->
glVertexAttribPointer
(
m_program
.
attributeLocation
(
"position"
),
2
,
GL_UNSIGNED_SHORT
,
GL_FALSE
,
sizeof
(
Copy
),
(
void
*
)
0
);
m_functions
->
glVertexAttribPointer
(
m_program
.
attributeLocation
(
"texcoord"
),
2
,
GL_UNSIGNED_SHORT
,
GL_FALSE
,
sizeof
(
Copy
),
(
void
*
)
(
2
*
sizeof
(
GLushort
)));
m_indices
.
create
();
m_indices
.
create
();
m_indices
.
bind
();
m_indices
.
bind
();
...
@@ -75,21 +60,21 @@ void Uploader::createContext(QOpenGLContext *context)
...
@@ -75,21 +60,21 @@ void Uploader::createContext(QOpenGLContext *context)
m_functions
->
glEnable
(
GL_TEXTURE_2D
);
m_functions
->
glEnable
(
GL_TEXTURE_2D
);
m_functions
->
glActiveTexture
(
GL_TEXTURE0
);
m_functions
->
glActiveTexture
(
GL_TEXTURE0
);
m_functions
->
glGenTextures
(
2
,
m_texId
);
m_functions
->
glGenTextures
(
2
,
m_texId
);
unsigned
char
black
[]
=
{
0
,
0
,
0
,
0
};
for
(
size_t
i
=
0
;
i
<
2
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
2
;
i
++
)
{
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
m_texId
[
i
]);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
m_texId
[
i
]);
m_functions
->
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGB
,
TEXTURE_WIDTH
,
TEXTURE_HEIGHT
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
NULL
);
m_functions
->
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
TEXTURE_WIDTH
,
TEXTURE_HEIGHT
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
NULL
);
m_functions
->
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
1
,
1
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
black
);
}
}
*
m_uploadTexture
=
m_texId
;
*
m_uploadTexture
=
m_texId
;
*
m_renderTexture
=
m_texId
+
1
;
*
m_renderTexture
=
m_texId
+
1
;
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
**
m_uploadTexture
);
m_functions
->
glGenFramebuffers
(
1
,
&
m_FBOId
);
m_functions
->
glGenFramebuffers
(
1
,
&
m_FBOId
);
m_functions
->
glBindFramebuffer
(
GL_FRAMEBUFFER
,
m_FBOId
);
m_functions
->
glBindFramebuffer
(
GL_FRAMEBUFFER
,
m_FBOId
);
m_functions
->
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
**
m_uploadTexture
,
0
);
m_functions
->
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
**
m_uploadTexture
,
0
);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
**
m_uploadTexture
);
m_functions
->
glViewport
(
0
,
0
,
TEXTURE_WIDTH
,
TEXTURE_HEIGHT
);
m_functions
->
glViewport
(
0
,
0
,
TEXTURE_WIDTH
,
TEXTURE_HEIGHT
);
m_functions
->
glPixelStorei
(
GL_UNPACK_ALIGNMENT
,
1
);
m_functions
->
glPixelStorei
(
GL_UNPACK_ALIGNMENT
,
1
);
}
}
...
@@ -120,10 +105,10 @@ void Uploader::gotCopy(const GLushort src_x, const GLushort src_y,
...
@@ -120,10 +105,10 @@ void Uploader::gotCopy(const GLushort src_x, const GLushort src_y,
// copy from source
// copy from source
if
(
m_copyIndex
+
4
<
COPY_BUFFER
)
{
if
(
m_copyIndex
+
4
<
COPY_BUFFER
)
{
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({
m_atlasX
,
m_atlasY
,
src_x
,
(
GLushort
)
(
src_y
+
height
)});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({
m_atlasX
,
(
GLushort
)
(
m_atlasY
+
height
)
,
src_x
,
(
GLushort
)
(
src_y
+
height
)});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({
m_atlasX
,
(
GLushort
)
(
m_atlasY
+
height
)
,
src_x
,
src_y
});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({
m_atlasX
,
m_atlasY
,
src_x
,
src_y
});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({(
GLushort
)
(
m_atlasX
+
width
),
m_atlasY
,
(
GLushort
)
(
src_x
+
width
),
(
GLushort
)
(
src_y
+
height
)});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({(
GLushort
)
(
m_atlasX
+
width
),
(
GLushort
)
(
m_atlasY
+
height
)
,
(
GLushort
)
(
src_x
+
width
),
(
GLushort
)
(
src_y
+
height
)});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({(
GLushort
)
(
m_atlasX
+
width
),
(
GLushort
)
(
m_atlasY
+
height
)
,
(
GLushort
)
(
src_x
+
width
),
src_y
});
m_copyPointer
[
m_copyIndex
++
]
=
Copy
({(
GLushort
)
(
m_atlasX
+
width
),
m_atlasY
,
(
GLushort
)
(
src_x
+
width
),
src_y
});
}
else
{
}
else
{
qDebug
()
<<
"Out of memory"
;
qDebug
()
<<
"Out of memory"
;
}
}
...
@@ -131,26 +116,26 @@ void Uploader::gotCopy(const GLushort src_x, const GLushort src_y,
...
@@ -131,26 +116,26 @@ void Uploader::gotCopy(const GLushort src_x, const GLushort src_y,
// copy to destination
// copy to destination
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
// bottom left
// bottom left
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({
dest_x
,
(
GLushort
)
(
dest_y
+
height
),
0
,
0
,
0
,
0
,
m_atlasX
,
m_atlasY
});
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({
dest_x
,
(
GLushort
)
(
dest_y
+
height
),
0
,
0
,
0
,
0
,
m_atlasX
,
(
GLushort
)
(
m_atlasY
+
height
)
});
// top left
// top left
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({
dest_x
,
dest_y
,
0
,
0
,
0
,
0
,
m_atlasX
,
(
GLushort
)
(
m_atlasY
+
height
)
});
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({
dest_x
,
dest_y
,
0
,
0
,
0
,
0
,
m_atlasX
,
m_atlasY
});
// bottom right
// bottom right
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({(
GLushort
)
(
dest_x
+
width
),
(
GLushort
)
(
dest_y
+
height
),
0
,
0
,
0
,
0
,
(
GLushort
)
(
m_atlasX
+
width
),
m_atlasY
});
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({(
GLushort
)
(
dest_x
+
width
),
(
GLushort
)
(
dest_y
+
height
),
0
,
0
,
0
,
0
,
(
GLushort
)
(
m_atlasX
+
width
),
(
GLushort
)
(
m_atlasY
+
height
)
});
// top right
// top right
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({(
GLushort
)
(
dest_x
+
width
),
dest_y
,
0
,
0
,
0
,
0
,
(
GLushort
)
(
m_atlasX
+
width
),
(
GLushort
)
(
m_atlasY
+
height
)
});
m_vertexPointer
[
m_vertexIndex
++
]
=
Vertex
({(
GLushort
)
(
dest_x
+
width
),
dest_y
,
0
,
0
,
0
,
0
,
(
GLushort
)
(
m_atlasX
+
width
),
m_atlasY
});
}
else
{
}
else
{
qDebug
()
<<
"Out of memory"
;
qDebug
()
<<
"Out of memory"
;
}
}
}
}
void
Uploader
::
gotBitmap
(
const
QImage
&
image
,
void
Uploader
::
gotBitmap
(
const
unsigned
char
*
image
,
const
GLushort
x
,
const
GLushort
y
,
const
GLushort
x
,
const
GLushort
y
,
const
GLushort
width
,
const
GLushort
height
)
const
GLushort
width
,
const
GLushort
height
)
{
{
if
(
!
refreshAtlas
(
width
,
height
))
if
(
!
refreshAtlas
(
width
,
height
))
return
;
return
;
m_functions
->
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
m_atlasX
,
m_atlasY
,
width
,
height
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
image
.
constBits
()
);
m_functions
->
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
m_atlasX
,
m_atlasY
,
width
,
height
,
GL_RGB
A
,
GL_UNSIGNED_BYTE
,
image
);
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
// bottom left
// bottom left
...
@@ -180,7 +165,7 @@ void Uploader::finishedJpeg(const unsigned char *image,
...
@@ -180,7 +165,7 @@ void Uploader::finishedJpeg(const unsigned char *image,
m_jpegs
--
;
m_jpegs
--
;
m_functions
->
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
m_atlasX
,
m_atlasY
,
width
,
height
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
image
);
m_functions
->
glTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
m_atlasX
,
m_atlasY
,
width
,
height
,
GL_RGB
A
,
GL_UNSIGNED_BYTE
,
image
);
delete
[]
image
;
delete
[]
image
;
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
if
(
m_vertexIndex
+
4
<
VERTEX_BUFFER
)
{
...
@@ -265,40 +250,44 @@ void Uploader::startRendering()
...
@@ -265,40 +250,44 @@ void Uploader::startRendering()
std
::
swap
(
*
m_uploadTexture
,
*
m_renderTexture
);
std
::
swap
(
*
m_uploadTexture
,
*
m_renderTexture
);
m_atlasX
=
0
;
m_atlasX
=
1
;
m_atlasY
=
0
;
m_atlasY
=
1
;
m_atlasRowHeight
=
0
;
m_atlasRowHeight
=
0
;
m_atlasLastWidth
=
0
;
m_atlasLastWidth
=
0
;
m_swapped
=
false
;
m_swapped
=
false
;
m_finished
=
false
;
m_finished
=
false
;
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
**
m_uploadTexture
);
m_functions
->
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
**
m_uploadTexture
,
0
);
m_functions
->
glFramebufferTexture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
**
m_uploadTexture
,
0
);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
**
m_uploadTexture
);
emit
uploadFinished
();
emit
uploadFinished
();
}
}
void
Uploader
::
copyRectangles
()
void
Uploader
::
copyRectangles
()
{
{
if
(
m_copyIndex
>
0
)
{
if
(
m_copyIndex
>
0
)
{
// m_functions->glActiveTexture(GL_TEXTURE1);
m_functions
->
glActiveTexture
(
GL_TEXTURE1
);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
m_FBOTexture
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
m_copyBuffer
.
bind
();
m_copyBuffer
.
bind
();
m_copyBuffer
.
unmap
();
m_copyBuffer
.
unmap
();
m_functions
->
glVertexAttribPointer
(
m_program
.
attributeLocation
(
"position"
),
2
,
GL_UNSIGNED_SHORT
,
GL_FALSE
,
sizeof
(
Copy
),
(
void
*
)
0
);
m_functions
->
glVertexAttribPointer
(
m_program
.
attributeLocation
(
"texcoord"
),
2
,
GL_UNSIGNED_SHORT
,
GL_FALSE
,
sizeof
(
Copy
),
(
void
*
)
(
2
*
sizeof
(
GLushort
)));
m_indices
.
bind
();
m_indices
.
bind
();
m_functions
->
glDrawElements
(
GL_TRIANGLE_STRIP
,
(
m_copyIndex
/
4
)
*
6
-
2
,
GL_UNSIGNED_SHORT
,
(
GLvoid
*
)
0
);
m_functions
->
glDrawElements
(
GL_TRIANGLE_STRIP
,
(
m_copyIndex
/
4
)
*
6
-
2
,
GL_UNSIGNED_SHORT
,
(
GLvoid
*
)
0
);
m_functions
->
glFinish
();
m_copyPointer
=
(
Copy
*
)
m_copyBuffer
.
map
(
QOpenGLBuffer
::
WriteOnly
);
m_copyPointer
=
(
Copy
*
)
m_copyBuffer
.
map
(
QOpenGLBuffer
::
WriteOnly
);
(
*
m_uploadVertices
)
->
bind
();
(
*
m_uploadVertices
)
->
bind
();
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
**
m_uploadTexture
);
m_functions
->
glActiveTexture
(
GL_TEXTURE0
);
// m_functions->glActiveTexture(GL_TEXTURE0);
m_copyIndex
=
0
;
m_copyIndex
=
0
;
}
}
}
}
...
@@ -325,14 +314,15 @@ unsigned int *Uploader::drawCount() const
...
@@ -325,14 +314,15 @@ unsigned int *Uploader::drawCount() const
void
Uploader
::
changeFBOTexture
(
const
unsigned
int
FBOTexture
,
const
QMatrix4x4
&
ortho
)
void
Uploader
::
changeFBOTexture
(
const
unsigned
int
FBOTexture
,
const
QMatrix4x4
&
ortho
)
{
{
/*m_functions->glActiveTexture(GL_TEXTURE1);
m_FBOTexture
=
FBOTexture
;
m_functions
->
glActiveTexture
(
GL_TEXTURE1
);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
m_FBOTexture
);
m_functions
->
glBindTexture
(
GL_TEXTURE_2D
,
m_FBOTexture
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
m_functions
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
m_functions->glActiveTexture(GL_TEXTURE0);
*/
m_functions
->
glActiveTexture
(
GL_TEXTURE0
);
m_FBOTexture
=
FBOTexture
;
m_program
.
setUniformValue
(
"texortho"
,
ortho
);
m_program
.
setUniformValue
(
"texortho"
,
ortho
);
}
}
uploader.h
View file @
b53b0657
...
@@ -40,7 +40,7 @@ struct Indices
...
@@ -40,7 +40,7 @@ struct Indices
{
{
// 4 corner/rectangle and the first and last one duplicated except for the first and last rectangle
// 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
];
unsigned
short
i
[(
VERTEX_BUFFER
/
4
)
*
6
-
2
];
constexpr
Indices
()
:
i
()
Indices
()
:
i
()
{
{
i
[
0
]
=
0
;
i
[
0
]
=
0
;
auto
index
=
1
;
auto
index
=
1
;
...
@@ -51,7 +51,7 @@ struct Indices
...
@@ -51,7 +51,7 @@ struct Indices
}
}
}
}
};
};
const
expr
Indices
ind
;
const
struct
Indices
ind
;
struct
Vertex
struct
Vertex
{
{
...
@@ -97,7 +97,7 @@ public:
...
@@ -97,7 +97,7 @@ public:
void
gotCopy
(
const
GLushort
src_x
,
const
GLushort
src_y
,
void
gotCopy
(
const
GLushort
src_x
,
const
GLushort
src_y
,
const
GLushort
width
,
const
GLushort
height
,
const
GLushort
width
,
const
GLushort
height
,
const
GLushort
dest_x
,
const
GLushort
dest_y
);
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
x
,
const
GLushort
y
,
const
GLushort
width
,
const
GLushort
height
);
const
GLushort
width
,
const
GLushort
height
);
void
gotJpeg
();
void
gotJpeg
();
...
...
vncrenderer.cpp
View file @
b53b0657
...
@@ -25,9 +25,9 @@ VncRenderer::VncRenderer(QQuickWindow *window,
...
@@ -25,9 +25,9 @@ VncRenderer::VncRenderer(QQuickWindow *window,
void
VncRenderer
::
render
()
void
VncRenderer
::
render
()
{
{
/*
static QTime frameTime;
static
QTime
frameTime
;
qDebug
()
<<
qRound
(
1000.0
/
frameTime
.
elapsed
())
<<
*
m_drawCount
;
qDebug
()
<<
qRound
(
1000.0
/
frameTime
.
elapsed
())
<<
*
m_drawCount
;
frameTime.restart();
*/
frameTime
.
restart
();
if
(
*
m_drawCount
>
0
)
{
if
(
*
m_drawCount
>
0
)
{
m_program
.
bind
();
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