如何在JavaScript中为Canvas启用加速硬件 [英] How to enable accelerated hardware in JavaScript for Canvas

查看:175
本文介绍了如何在JavaScript中为Canvas启用加速硬件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JavaScript中为HTML5画布启用硬件加速?或者是不可能在JavaScript?我记得,我读某处使用CSS或Webgl的东西,但我不记得....
如果这是一个坏问题,请不要-rep我,只是告诉我,我会删除它。 / p>

解决方案

你可能还记得的是CSS的技巧,触发加速显示,即使你不真正做3d自己: / p>

一种常见的方式是使用:

  transform:translateZ ; 

(如果需要,添加浏览器前缀版本)



请注意,这不是一个官方支持的硬件加速切换方式,它只是一个在一些浏览器中的副作用。


How do I enable hardware acceleration for HTML5 canvas in JavaScript? Or is it not possible in JavaScript? I remember that I read somewhere about doing that using something CSS or Webgl but I dont remember.... If this is a bad question please do not -rep me, just tell me and I'll remove it.

解决方案

What you probably remember is the CSS 'trick' that triggers accelerated display even if you don't really do 3d yourself:

A common way is using:

transform: translateZ(0);

in your css. (add the browser-prefixed versions if needed)

Please note that this is by no means an officially supported way of switching on hardware acceleration, it's just an (undocumented?) side-effect in some browsers.

这篇关于如何在JavaScript中为Canvas启用加速硬件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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