检查硬件加速可用性? (可以测试) [英] Checking hardware acceleration availability? (Testing available)

查看:124
本文介绍了检查硬件加速可用性? (可以测试)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了使用-webkit-transform,-webkit-perspective和其他类似方法的CSS.我的设计在可以使用硬件加速但实际上无法使用的机器上看起来有些屈膝.如何检查硬件加速可用性并提供后备CSS?

I've written CSS that uses -webkit-transform, -webkit-perspective and several similar. My design looks the bees knees on machines where hardware acceleration is available but is practically unusable when not. How can I check hardware acceleration availability and provide fallback CSS?

旁注:运行chrome://gpu-internals/手动检查可用性.

Side note: Run chrome://gpu-internals/ to manually check for availability.

推荐答案

可悲的是,答案似乎是你还不能(还)".

Sadly, the answer seems to be 'you can't (yet)'.

Modernizr项目在其无法检测到的"中列出了硬件加速: https://github.com/Modernizr/Modernizr/wiki/Undetectables .

The Modernizr project lists HW acceleration amongst its 'undetectables': https://github.com/Modernizr/Modernizr/wiki/Undetectables.

部分问题似乎在于,在页面上呈现任何内容时,会根据具体情况使用硬件加速.因此,即使理论上浏览器可能支持硬件加速,也无法预先知道是否将其用于任何给定的操作(翻译,过渡,重画等).

Part of the problem seems to be that HW acceleration is used on a case-by-case basis when rendering anything on the page. So, even though a browser may theoretically support HW acceleration, whether or not it will be used for any given operation (translation, transition, repaint, etc) won't be known in advance.

您可以想象一种检测方案,该方案使用性能分析来检测有无HW加速的性能变化-但是使用HW加速的事情发生在页面视图之外的一层中.例如,即使您可以可靠地启用/禁用硬件加速,也无法检测到过渡的帧速率.

You could imagine a detection scheme that used profiling to detect the change in performance with/without HW acceleration - but the things that use HW acceleration happen in a layer out of the page's view. You can't, for instance detect the frame-rate of a transition, even if you could reliably enable/disable HW acceleration.

webkit呈现API看起来像是可以提供此信息的地方,但看起来似乎无法通过页面级Javascript访问(即使DOM中的节点都已附加RenderObjects):

The webkit rendering API looks like the place this information might be available, but it doesn't look to be accessible via page-level Javascript (even though nodes in the DOM have RenderObjects attached to them): https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/

唯一可行的选择似乎是用户代理嗅探已知的加速浏览器列表(糟糕).

Looks like the only viable option is user-agent sniffing against a list of known accelerated browsers (yuck).

这篇关于检查硬件加速可用性? (可以测试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆