问题
I want to include a few "bells and whistles" features on a site I'm currently developing, but I don't want to bog down the entire machine for my users. Is there a way I can test to see if the current browser is GPU accelerated?
I could just check against UserAgents, but I've always heard it's not accurate enough to trust.
I guess I could build a canvas element, make quite a few drawing calls, and time them? Anything under a certain threshold I could consider good enough for my superfluous extras? Would this be good enough?
回答1:
Why does it matter if its GPU accelerated? The only thing that should matter is performance.
So timing the canvas element is the better choice even if you could find out if there is GPU acceleration or not.
回答2:
The best way that won't be fooled by browser UserAgent hacks is checking support for latest features included in the browser versions that support the GPU acceleration. You'd need to do some digging to find what was added in the same versions as the GPU acceleration to do that.
Just keep in mind that GPU support for canvas at the moment works only on Windows - so you'd have to take all the OSX running machines out of equation and only in ie9, chrome 11 and firefox 4 - all of them either RC, betas, or dev builds.
for IE9 for example: only IE have scrollabar color CSS properties and only IE9 form all the IEs supports css opacity
function isIE9() {
var bodyStyle = document.body.style;
return (bodyStyle.scrollbar3dLightColor != undefined && bodyStyle.opacity != undefined)
}
来源:https://stackoverflow.com/questions/4972074/is-there-a-way-to-programmatically-test-for-browser-gpu-acceleration