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
48eed1ac
Commit
48eed1ac
authored
Jun 24, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor canvas imageData test slightly.
parent
486cd527
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
canvas.js
include/canvas.js
+16
-12
No files found.
include/canvas.js
View file @
48eed1ac
...
@@ -13,12 +13,14 @@
...
@@ -13,12 +13,14 @@
var
Canvas
,
Canvas_native
;
var
Canvas
,
Canvas_native
;
(
function
()
{
(
function
()
{
var
pre
,
extra
=
""
,
start
,
end
;
var
pre
,
start
=
"<script src='"
,
end
=
"'><
\
/script>"
;
if
(
document
.
createElement
(
'canvas'
).
getContext
)
{
if
(
document
.
createElement
(
'canvas'
).
getContext
)
{
Canvas_native
=
true
;
Canvas_native
=
true
;
}
else
{
}
else
{
pre
=
(
typeof
VNC_uri_prefix
!==
"undefined"
)
?
VNC_uri_prefix
:
"include/"
;
document
.
write
(
start
+
pre
+
"excanvas.js"
+
end
);
Canvas_native
=
false
;
Canvas_native
=
false
;
document
.
write
(
"<script src='excanvas'><
\
/script>"
);
}
}
}());
}());
...
@@ -146,6 +148,7 @@ init: function (id) {
...
@@ -146,6 +148,7 @@ init: function (id) {
// Use default Canvas functions
// Use default Canvas functions
}
else
{
}
else
{
console
.
warn
(
"Using excanvas canvas emulation"
);
console
.
warn
(
"Using excanvas canvas emulation"
);
//G_vmlCanvasManager.init(c);
G_vmlCanvasManager
.
initElement
(
c
);
G_vmlCanvasManager
.
initElement
(
c
);
}
}
...
@@ -154,21 +157,25 @@ init: function (id) {
...
@@ -154,21 +157,25 @@ init: function (id) {
Canvas
.
clear
();
Canvas
.
clear
();
/*
/*
* Determine browser
feature support and most optimal rendering
* Determine browser
Canvas feature support
* methods
*
and select fastest rendering
methods
*/
*/
tval
=
0
;
tval
=
0
;
Canvas
.
has_imageData
=
false
;
try
{
try
{
imgTest
=
Canvas
.
ctx
.
getImageData
(
0
,
0
,
1
,
1
);
imgTest
=
Canvas
.
ctx
.
getImageData
(
0
,
0
,
1
,
1
);
imgTest
.
data
[
0
]
=
123
;
imgTest
.
data
[
0
]
=
123
;
imgTest
.
data
[
3
]
=
255
;
imgTest
.
data
[
3
]
=
255
;
Canvas
.
ctx
.
putImageData
(
imgTest
,
0
,
0
);
Canvas
.
ctx
.
putImageData
(
imgTest
,
0
,
0
);
tval
=
Canvas
.
ctx
.
getImageData
(
0
,
0
,
1
,
1
).
data
[
0
];
tval
=
Canvas
.
ctx
.
getImageData
(
0
,
0
,
1
,
1
).
data
[
0
];
}
catch
(
exc
)
{
}
if
(
tval
===
123
)
{
if
(
tval
===
123
)
{
Canvas
.
has_imageData
=
true
;
}
}
catch
(
exc
)
{}
if
(
Canvas
.
has_imageData
)
{
console
.
log
(
"Canvas supports imageData"
);
Canvas
.
_rgbxImage
=
Canvas
.
_rgbxImageData
;
Canvas
.
_rgbxImage
=
Canvas
.
_rgbxImageData
;
Canvas
.
_cmapImage
=
Canvas
.
_cmapImageData
;
Canvas
.
_cmapImage
=
Canvas
.
_cmapImageData
;
if
(
Canvas
.
ctx
.
createImageData
)
{
if
(
Canvas
.
ctx
.
createImageData
)
{
...
@@ -178,9 +185,6 @@ init: function (id) {
...
@@ -178,9 +185,6 @@ init: function (id) {
}
else
if
(
Canvas
.
ctx
.
getImageData
)
{
}
else
if
(
Canvas
.
ctx
.
getImageData
)
{
console
.
log
(
"Using Canvas getImageData"
);
console
.
log
(
"Using Canvas getImageData"
);
Canvas
.
_imageData
=
Canvas
.
_imageDataGet
;
Canvas
.
_imageData
=
Canvas
.
_imageDataGet
;
}
else
{
console
.
log
(
"No imageData support"
);
return
false
;
}
}
if
(
Util
.
Engine
.
webkit
)
{
if
(
Util
.
Engine
.
webkit
)
{
console
.
log
(
"Prefering javascript operations"
);
console
.
log
(
"Prefering javascript operations"
);
...
@@ -190,7 +194,7 @@ init: function (id) {
...
@@ -190,7 +194,7 @@ init: function (id) {
Canvas
.
prefer_js
=
false
;
Canvas
.
prefer_js
=
false
;
}
}
}
else
{
}
else
{
console
.
log
(
"
No
imageData, using fillRect (slow)"
);
console
.
log
(
"
Canvas lacks
imageData, using fillRect (slow)"
);
Canvas
.
_rgbxImage
=
Canvas
.
_rgbxImageFill
;
Canvas
.
_rgbxImage
=
Canvas
.
_rgbxImageFill
;
Canvas
.
_cmapImage
=
Canvas
.
_cmapImageFill
;
Canvas
.
_cmapImage
=
Canvas
.
_cmapImageFill
;
Canvas
.
prefer_js
=
false
;
Canvas
.
prefer_js
=
false
;
...
...
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