Is there a way to programmatically test for browser GPU acceleration?

筅森魡賤 提交于 2019-12-21 07:03:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!