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
a820f126
Commit
a820f126
authored
Jan 25, 2012
by
Mike Tinglof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added rgb image drawing, some zlib changes (huffman coding working, but lz77 not so much)
parent
c577ca23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
16 deletions
+71
-16
display.js
include/display.js
+30
-1
jsunzip.js
include/jsunzip.js
+21
-11
rfb.js
include/rfb.js
+20
-4
No files found.
include/display.js
View file @
a820f126
...
@@ -20,7 +20,7 @@ var that = {}, // Public API methods
...
@@ -20,7 +20,7 @@ var that = {}, // Public API methods
c_forceCanvas
=
false
,
c_forceCanvas
=
false
,
// Predefine function variables (jslint)
// Predefine function variables (jslint)
imageDataGet
,
bgrxImageData
,
cmapImageData
,
imageDataGet
,
rgbImageData
,
bgrxImageData
,
cmapImageData
,
setFillColor
,
rescale
,
setFillColor
,
rescale
,
// The full frame buffer (logical canvas) size
// The full frame buffer (logical canvas) size
...
@@ -497,6 +497,26 @@ that.finishTile = function() {
...
@@ -497,6 +497,26 @@ that.finishTile = function() {
// else: No-op, if not prefer_js then already done by setSubTile
// else: No-op, if not prefer_js then already done by setSubTile
};
};
rgbImageData
=
function
(
x
,
y
,
width
,
height
,
arr
,
offset
)
{
var
img
,
i
,
j
,
data
,
v
=
viewport
;
/*
if ((x - v.x >= v.w) || (y - v.y >= v.h) ||
(x - v.x + width < 0) || (y - v.y + height < 0)) {
// Skipping because outside of viewport
return;
}
*/
img
=
c_ctx
.
createImageData
(
width
,
height
);
data
=
img
.
data
;
for
(
i
=
0
,
j
=
offset
;
i
<
(
width
*
height
*
4
);
i
=
i
+
4
,
j
=
j
+
3
)
{
data
[
i
]
=
arr
[
j
];
data
[
i
+
1
]
=
arr
[
j
+
1
];
data
[
i
+
2
]
=
arr
[
j
+
2
];
data
[
i
+
3
]
=
255
;
// Set Alpha
}
c_ctx
.
putImageData
(
img
,
x
-
v
.
x
,
y
-
v
.
y
);
};
bgrxImageData
=
function
(
x
,
y
,
width
,
height
,
arr
,
offset
)
{
bgrxImageData
=
function
(
x
,
y
,
width
,
height
,
arr
,
offset
)
{
var
img
,
i
,
j
,
data
,
v
=
viewport
;
var
img
,
i
,
j
,
data
,
v
=
viewport
;
/*
/*
...
@@ -540,6 +560,15 @@ that.blitImage = function(x, y, width, height, arr, offset) {
...
@@ -540,6 +560,15 @@ that.blitImage = function(x, y, width, height, arr, offset) {
}
}
};
};
that
.
blitRgbImage
=
function
(
x
,
y
,
width
,
height
,
arr
,
offset
)
{
if
(
conf
.
true_color
)
{
rgbImageData
(
x
,
y
,
width
,
height
,
arr
,
offset
);
}
else
{
// prolly wrong...
cmapImageData
(
x
,
y
,
width
,
height
,
arr
,
offset
);
}
};
that
.
blitStringImage
=
function
(
str
,
x
,
y
)
{
that
.
blitStringImage
=
function
(
str
,
x
,
y
)
{
var
img
=
new
Image
();
var
img
=
new
Image
();
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
...
...
include/jsunzip.js
View file @
a820f126
...
@@ -197,8 +197,10 @@ function JSUnzip() {
...
@@ -197,8 +197,10 @@ function JSUnzip() {
* emoller@opera.com
* emoller@opera.com
*/
*/
"use strict"
;
function
TINF
()
{
function
TINF
()
{
this
.
OK
=
0
;
this
.
OK
=
0
;
this
.
DATA_ERROR
=
(
-
3
);
this
.
DATA_ERROR
=
(
-
3
);
this
.
WINDOW_SIZE
=
32768
;
this
.
WINDOW_SIZE
=
32768
;
...
@@ -392,7 +394,7 @@ this.decode_symbol = function(d, t)
...
@@ -392,7 +394,7 @@ this.decode_symbol = function(d, t)
this
.
decode_trees
=
function
(
d
,
lt
,
dt
)
this
.
decode_trees
=
function
(
d
,
lt
,
dt
)
{
{
var
code_tree
=
new
this
.
TREE
();
var
code_tree
=
new
this
.
TREE
();
lengths
=
new
Array
(
288
+
32
);
var
lengths
=
new
Array
(
288
+
32
);
var
hlit
,
hdist
,
hclen
;
var
hlit
,
hdist
,
hclen
;
var
i
,
num
,
length
;
var
i
,
num
,
length
;
...
@@ -518,6 +520,13 @@ this.inflate_uncompressed_block = function(d)
...
@@ -518,6 +520,13 @@ this.inflate_uncompressed_block = function(d)
var
length
,
invlength
;
var
length
,
invlength
;
var
i
;
var
i
;
if
(
d
.
bitcount
>
7
)
{
var
overflow
=
Math
.
floor
(
d
.
bitcount
/
8
);
d
.
sourceIndex
-=
overflow
;
d
.
bitcount
=
0
;
d
.
tag
=
0
;
}
/* get length */
/* get length */
length
=
d
.
source
[
d
.
sourceIndex
+
1
];
length
=
d
.
source
[
d
.
sourceIndex
+
1
];
length
=
256
*
length
+
d
.
source
[
d
.
sourceIndex
];
length
=
256
*
length
+
d
.
source
[
d
.
sourceIndex
];
...
@@ -605,7 +614,11 @@ this.uncompress = function(source, offset)
...
@@ -605,7 +614,11 @@ this.uncompress = function(source, offset)
// Skip zlib header at start of stream
// Skip zlib header at start of stream
if
(
typeof
this
.
header
==
'undefined'
)
{
if
(
typeof
this
.
header
==
'undefined'
)
{
this
.
header
=
this
.
read_bits
(
d
,
16
,
0
);
this
.
header
=
this
.
read_bits
(
d
,
16
,
0
);
/* byte 0: 0x78, 7 = 32k window size, 8 = deflate */
/* byte 1: check bits for header and other flags */
}
}
var
blocks
=
0
;
do
{
do
{
...
@@ -638,21 +651,18 @@ this.uncompress = function(source, offset)
...
@@ -638,21 +651,18 @@ this.uncompress = function(source, offset)
}
}
if
(
res
!=
this
.
OK
)
return
{
'status'
:
this
.
DATA_ERROR
};
if
(
res
!=
this
.
OK
)
return
{
'status'
:
this
.
DATA_ERROR
};
blocks
++
;
}
while
(
!
bfinal
&&
d
.
sourceIndex
<
d
.
source
.
length
);
}
while
(
!
bfinal
&&
d
.
sourceIndex
<
d
.
source
.
length
-
3
);
if
(
blocks
!=
2
)
throw
(
"Unexpected number of blocks"
);
if
(
Object
.
prototype
.
toString
.
call
(
source
)
!==
'[object Array]'
)
{
if
(
Object
.
prototype
.
toString
.
call
(
source
)
!==
'[object Array]'
)
{
d
.
dest
=
d
.
dest
.
join
(
''
);
d
.
dest
=
d
.
dest
.
join
(
''
);
}
}
else
{
else
{
if
(
d
.
dest
.
length
>=
this
.
WINDOW_SIZE
)
{
d
.
history
=
d
.
dest
.
slice
(
d
.
dest
.
length
-
this
.
WINDOW_SIZE
);
}
else
{
var
overflow
=
d
.
history
.
length
+
d
.
dest
.
length
-
this
.
WINDOW_SIZE
;
if
(
overflow
>
0
)
d
.
history
=
d
.
history
.
slice
(
overflow
);
}
d
.
history
.
push
.
apply
(
d
.
history
,
d
.
dest
);
d
.
history
.
push
.
apply
(
d
.
history
,
d
.
dest
);
d
.
history
=
d
.
history
.
slice
(
-
this
.
WINDOW_SIZE
);
}
}
return
{
'status'
:
this
.
OK
,
'data'
:
d
.
dest
};
return
{
'status'
:
this
.
OK
,
'data'
:
d
.
dest
};
...
...
include/rfb.js
View file @
a820f126
...
@@ -299,7 +299,7 @@ init_vars = function() {
...
@@ -299,7 +299,7 @@ init_vars = function() {
FBU
.
lines
=
0
;
// RAW
FBU
.
lines
=
0
;
// RAW
FBU
.
tiles
=
0
;
// HEXTILE
FBU
.
tiles
=
0
;
// HEXTILE
FBU
.
imgQ
=
[];
// TIGHT_PNG image queue
FBU
.
imgQ
=
[];
// TIGHT_PNG image queue
FBU
.
streams
=
[];
// TIGHT zlib encoders
FBU
.
zlibs
=
[];
// TIGHT zlib encoders
mouse_buttonMask
=
0
;
mouse_buttonMask
=
0
;
mouse_arr
=
[];
mouse_arr
=
[];
...
@@ -1290,11 +1290,22 @@ encHandlers.TIGHT = function display_tight() {
...
@@ -1290,11 +1290,22 @@ encHandlers.TIGHT = function display_tight() {
return
[
header
,
data
];
return
[
header
,
data
];
};
};
var
checksum
=
function
(
data
)
{
var
sum
=
0
,
i
;
for
(
i
=
0
;
i
<
data
.
length
;
i
++
)
{
sum
+=
data
[
i
];
if
(
sum
>
65536
)
sum
-=
65536
;
}
return
sum
;
}
var
decompress
=
function
(
data
)
{
var
decompress
=
function
(
data
)
{
// TODO: process resetStreams here
// TODO: process resetStreams here
var
uncompressed
=
FBU
.
zlibs
[
streamId
].
uncompress
(
data
,
0
);
var
uncompressed
=
FBU
.
zlibs
[
streamId
].
uncompress
(
data
,
0
);
if
(
uncompressed
.
status
!=
0
)
if
(
uncompressed
.
status
!=
0
)
throw
(
"Invalid data in zlib stream"
);
throw
(
"Invalid data in zlib stream"
);
Util
.
Warn
(
"Decompressed "
+
data
.
length
+
" to "
+
uncompressed
.
data
.
length
+
" checksums "
+
checksum
(
data
)
+
":"
+
checksum
(
uncompressed
.
data
));
return
uncompressed
.
data
;
return
uncompressed
.
data
;
}
}
...
@@ -1319,6 +1330,8 @@ encHandlers.TIGHT = function display_tight() {
...
@@ -1319,6 +1330,8 @@ encHandlers.TIGHT = function display_tight() {
// Shift ctl, filter id, num colors, palette entries, and clength off
// Shift ctl, filter id, num colors, palette entries, and clength off
ws
.
rQshiftBytes
(
3
+
paletteSize
+
clength
[
0
]);
ws
.
rQshiftBytes
(
3
+
paletteSize
+
clength
[
0
]);
if
(
streamId
==
0
)
throw
(
"Wrong stream"
);
// Process data
// Process data
if
(
clength
[
1
]
<
12
)
if
(
clength
[
1
]
<
12
)
data
=
ws
.
rQshiftBytes
(
clength
[
1
]);
data
=
ws
.
rQshiftBytes
(
clength
[
1
]);
...
@@ -1337,6 +1350,8 @@ encHandlers.TIGHT = function display_tight() {
...
@@ -1337,6 +1350,8 @@ encHandlers.TIGHT = function display_tight() {
FBU
.
bytes
=
1
+
clength
[
0
]
+
clength
[
1
];
// ctl + clength size + zlib-data
FBU
.
bytes
=
1
+
clength
[
0
]
+
clength
[
1
];
// ctl + clength size + zlib-data
if
(
ws
.
rQwait
(
"TIGHT "
+
cmode
,
FBU
.
bytes
))
{
return
false
;
}
if
(
ws
.
rQwait
(
"TIGHT "
+
cmode
,
FBU
.
bytes
))
{
return
false
;
}
if
(
streamId
!=
0
)
throw
(
"Wrong stream"
);
ws
.
rQshiftBytes
(
1
+
clength
[
0
]);
// ctl + clength
ws
.
rQshiftBytes
(
1
+
clength
[
0
]);
// ctl + clength
if
(
clength
[
1
]
<
12
)
if
(
clength
[
1
]
<
12
)
data
=
ws
.
rQshiftBytes
(
clength
[
1
]);
data
=
ws
.
rQshiftBytes
(
clength
[
1
]);
...
@@ -1357,7 +1372,8 @@ encHandlers.TIGHT = function display_tight() {
...
@@ -1357,7 +1372,8 @@ encHandlers.TIGHT = function display_tight() {
// Keep tight reset bits
// Keep tight reset bits
resetStreams
=
ctl
&
0xF
;
resetStreams
=
ctl
&
0xF
;
if
(
resetStreams
)
throw
(
"Tight reset"
);
// Figure out filter
// Figure out filter
ctl
=
ctl
>>
4
;
ctl
=
ctl
>>
4
;
streamId
=
ctl
&
0x3
;
streamId
=
ctl
&
0x3
;
...
@@ -1540,7 +1556,7 @@ scan_tight_imgQ = function() {
...
@@ -1540,7 +1556,7 @@ scan_tight_imgQ = function() {
if
(
data
.
type
===
'fill'
)
{
if
(
data
.
type
===
'fill'
)
{
display
.
fillRect
(
data
.
x
,
data
.
y
,
data
.
width
,
data
.
height
,
data
.
color
);
display
.
fillRect
(
data
.
x
,
data
.
y
,
data
.
width
,
data
.
height
,
data
.
color
);
}
else
if
(
data
.
type
===
'rgb'
)
{
}
else
if
(
data
.
type
===
'rgb'
)
{
// TODO
display
.
blitRgbImage
(
data
.
x
,
data
.
y
,
data
.
width
,
data
.
height
,
data
.
img
.
data
,
0
);
}
else
{
}
else
{
ctx
.
drawImage
(
data
.
img
,
data
.
x
,
data
.
y
);
ctx
.
drawImage
(
data
.
img
,
data
.
x
,
data
.
y
);
}
}
...
...
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