Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
ed7e776d
Commit
ed7e776d
authored
Apr 12, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First pass at RRE encoding
parent
d628147b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
18 deletions
+60
-18
canvas.js
canvas.js
+5
-0
vnc.js
vnc.js
+55
-18
No files found.
canvas.js
View file @
ed7e776d
...
@@ -148,6 +148,11 @@ rfbImage: function(x, y, width, height, arr) {
...
@@ -148,6 +148,11 @@ rfbImage: function(x, y, width, height, arr) {
},
},
rfbRect
:
function
(
x
,
y
,
width
,
height
,
color
)
{
Canvas
.
ctx
.
fillStyle
=
"rgb("
+
color
[
2
]
+
","
+
color
[
1
]
+
","
+
color
[
0
]
+
")"
;
Canvas
.
ctx
.
fillRect
(
x
,
y
,
width
,
height
);
},
copyImage
:
function
(
old_x
,
old_y
,
new_x
,
new_y
,
width
,
height
)
{
copyImage
:
function
(
old_x
,
old_y
,
new_x
,
new_y
,
width
,
height
)
{
Canvas
.
ctx
.
drawImage
(
$
(
Canvas
.
id
),
old_x
,
old_y
,
width
,
height
,
Canvas
.
ctx
.
drawImage
(
$
(
Canvas
.
id
),
old_x
,
old_y
,
width
,
height
,
new_x
,
new_y
,
width
,
height
);
new_x
,
new_y
,
width
,
height
);
...
...
vnc.js
View file @
ed7e776d
...
@@ -43,6 +43,7 @@ Array.prototype.shiftBytes = function (len) {
...
@@ -43,6 +43,7 @@ Array.prototype.shiftBytes = function (len) {
*/
*/
var
FBU
=
{
var
FBU
=
{
rects
:
0
,
rects
:
0
,
subrects
:
0
,
bytes
:
0
,
bytes
:
0
,
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
...
@@ -201,6 +202,47 @@ init_msg: function (data) {
...
@@ -201,6 +202,47 @@ init_msg: function (data) {
debug
(
"<< init_msg ("
+
RFB
.
state
+
")"
);
debug
(
"<< init_msg ("
+
RFB
.
state
+
")"
);
},
},
/* Framebuffer update display functions */
display_raw
:
function
()
{
debug
(
">> display_raw"
);
Canvas
.
rfbImage
(
FBU
.
x
,
FBU
.
y
,
FBU
.
width
,
FBU
.
height
,
FBU
.
arr
);
FBU
.
rects
--
;
},
display_copy_rect
:
function
()
{
debug
(
">> display_copy_rect"
);
var
old_x
=
FBU
.
arr
.
shift16
();
var
old_y
=
FBU
.
arr
.
shift16
();
Canvas
.
copyImage
(
old_x
,
old_y
,
FBU
.
x
,
FBU
.
y
,
FBU
.
width
,
FBU
.
height
);
FBU
.
rects
--
;
},
display_rre
:
function
()
{
debug
(
">> display_rre"
);
if
(
FBU
.
subrects
==
0
)
{
debug
(
"Processing new RRE"
);
FBU
.
subrects
=
FBU
.
arr
.
shift32
();
var
color
=
data
.
shiftBytes
(
FBU
.
fb_Bpp
);
// Background
Canvas
.
rfbRect
(
FBU
.
x
,
FBU
.
y
,
FBU
.
width
,
FBU
.
height
,
color
);
}
else
{
/* Render one sub-rectangle */
FBU
.
subrects
--
;
var
color
=
data
.
shiftBytes
(
FBU
.
fb_Bpp
);
var
x
=
data
.
shift16
();
var
y
=
data
.
shift16
();
var
width
=
data
.
shift16
();
var
height
=
data
.
shift16
();
Canvas
.
rfbRect
(
x
,
y
,
width
,
height
,
color
);
}
if
(
FBU
.
subrects
>
0
)
{
FBU
.
bytes
=
(
8
+
FBU
.
fb_Bpp
);
}
else
{
FBU
.
rect
--
;
}
},
/* Normal RFB/VNC messages */
/* Normal RFB/VNC messages */
normal_msg
:
function
(
data
)
{
normal_msg
:
function
(
data
)
{
//debug(">> normal_msg");
//debug(">> normal_msg");
...
@@ -222,15 +264,14 @@ normal_msg: function (data) {
...
@@ -222,15 +264,14 @@ normal_msg: function (data) {
}
}
while
(
data
.
length
>
0
)
{
while
(
data
.
length
>
0
)
{
//debug("data.length: " + data.length
);
debug
(
"data.length: "
+
data
.
length
+
", FBU.bytes: "
+
FBU
.
bytes
);
if
(
FBU
.
bytes
==
0
)
{
if
(
FBU
.
bytes
==
0
)
{
FBU
.
x
=
data
.
shift16
();
FBU
.
x
=
data
.
shift16
();
FBU
.
y
=
data
.
shift16
();
FBU
.
y
=
data
.
shift16
();
FBU
.
width
=
data
.
shift16
();
FBU
.
width
=
data
.
shift16
();
FBU
.
height
=
data
.
shift16
();
FBU
.
height
=
data
.
shift16
();
FBU
.
encoding
=
parseInt
(
data
.
shift32
(),
10
);
FBU
.
encoding
=
parseInt
(
data
.
shift32
(),
10
);
//debug("encoding: " + FBU.encoding);
debug
(
"encoding: "
+
FBU
.
encoding
);
//debug('New rect: ' + FBU.x + "," + FBU.y + " -> " + (FBU.x + FBU.width) + "," + (FBU.y + FBU.height));
switch
(
FBU
.
encoding
)
{
switch
(
FBU
.
encoding
)
{
case
0
:
// Raw
case
0
:
// Raw
FBU
.
bytes
=
FBU
.
width
*
FBU
.
height
*
RFB
.
fb_Bpp
;
FBU
.
bytes
=
FBU
.
width
*
FBU
.
height
*
RFB
.
fb_Bpp
;
...
@@ -238,6 +279,10 @@ normal_msg: function (data) {
...
@@ -238,6 +279,10 @@ normal_msg: function (data) {
case
1
:
// Copy-Rect
case
1
:
// Copy-Rect
FBU
.
bytes
=
4
;
FBU
.
bytes
=
4
;
break
;
break
;
case
2
:
// RRE
debug
(
"RRE"
);
FBU
.
bytes
=
4
+
RFB
.
fb_Bpp
;
break
;
}
}
}
else
{
}
else
{
if
(
data
.
length
>=
FBU
.
bytes
)
{
if
(
data
.
length
>=
FBU
.
bytes
)
{
...
@@ -246,22 +291,13 @@ normal_msg: function (data) {
...
@@ -246,22 +291,13 @@ normal_msg: function (data) {
FBU
.
bytes
=
0
;
FBU
.
bytes
=
0
;
switch
(
FBU
.
encoding
)
{
switch
(
FBU
.
encoding
)
{
case
0
:
// Raw
case
0
:
RFB
.
display_raw
();
break
;
// Raw
//debug('Raw-Rect: (' + FBU.x + "," + FBU.y + ")X(" + (FBU.x + FBU.width) + "," + (FBU.y + FBU.height) + ")");
case
1
:
RFB
.
display_copy_rect
();
break
;
// Copy-Rect
Canvas
.
rfbImage
(
FBU
.
x
,
FBU
.
y
,
FBU
.
width
,
FBU
.
height
,
FBU
.
arr
);
case
2
:
RFB
.
display_rre
();
break
;
// RRE
break
;
case
1
:
// Copy-Rect
var
old_x
=
FBU
.
arr
.
shift16
();
var
old_y
=
FBU
.
arr
.
shift16
();
//debug('Copy-Rect: (' + old_x + "," + old_y + ")X(" + (FBU.x + FBU.width) + "," + (FBU.y + FBU.height) + ") -> (" + FBU.x + "," + FBU.y + ")");
Canvas
.
copyImage
(
old_x
,
old_y
,
FBU
.
x
,
FBU
.
y
,
FBU
.
width
,
FBU
.
height
);
break
;
}
}
FBU
.
arr
=
[];
FBU
.
arr
=
[];
FBU
.
rects
--
;
}
else
{
}
else
{
//debug('Part rect: ' + FBU.x + "," + FBU.y + " -> " + (FBU.x + FBU.width) + "," + (FBU.y + FBU.height));
FBU
.
bytes
=
FBU
.
bytes
-
data
.
length
;
FBU
.
bytes
=
FBU
.
bytes
-
data
.
length
;
FBU
.
arr
=
FBU
.
arr
.
concat
(
data
.
shiftBytes
(
data
.
length
))
FBU
.
arr
=
FBU
.
arr
.
concat
(
data
.
shiftBytes
(
data
.
length
))
}
}
...
@@ -324,7 +360,8 @@ setEncodings: function () {
...
@@ -324,7 +360,8 @@ setEncodings: function () {
debug
(
">> setEncodings"
);
debug
(
">> setEncodings"
);
var
arr
=
[
2
];
// msg-type
var
arr
=
[
2
];
// msg-type
arr
.
push8
(
0
);
// padding
arr
.
push8
(
0
);
// padding
arr
.
push16
(
2
);
// encoding count
arr
.
push16
(
3
);
// encoding count
arr
.
push32
(
2
);
// RRE encoding
arr
.
push32
(
1
);
// copy-rect encoding
arr
.
push32
(
1
);
// copy-rect encoding
arr
.
push32
(
0
);
// raw encoding
arr
.
push32
(
0
);
// raw encoding
RFB
.
send_array
(
arr
);
RFB
.
send_array
(
arr
);
...
...
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