发现Firefox没有Chrome快?使用 Mactype+关闭硬件加速 可能会拖慢Firefox的渲染速度

平常使用火狐发现速度仍是比不上Chrome。按理说,火狐换上了量子引擎,又通过那么屡次优化,速度应该有明显的提高才对。前端

偶然之下,才发现罪魁祸首是我关闭了硬件加速。segmentfault

为了解决 Window 糟糕的字体渲染,我使用了Mactype,同时也对firefox进行了一些调整:浏览器

将默认的
gfx.content.azure.backends;direct2d1.1,skia,cairo
改成:
gfx.content.azure.backends;direct2d1.1,cairo,skia
将 gfx.direct2d.disabled 改成 true

后来,偶然在 about:support 里的“决策日志”这一项发现了一些有趣的信息:wordpress

DIRECT2D   disabled by user: Disabled via gfx.direct2d.disabled
WEBRENDER  opt-in by default: WebRender is an opt-in feature  blocked by runtime: Qualified enable blocked
WEBRENDER_QUALIFIED blocked by env: Not Nvidia
OMTP broken by runtime: OMTP is not supported when using cairo

信息里关键词有:DIRECT2D,WEBRENDER,OMTP:字体

因此在通过上面对 gfx.content.azure.backends 的修改后,浏览器优先使用了cairo去进行绘制,可是cairo刚好又不支持OMTP,并且硬件加速也被咱们关闭了,浏览器的渲染速度天然慢下来了3d

彷佛 良好的字体渲染效果浏览器的渲染速度 必须取舍一个。其实,firefox自带字体渲染的配置,经过调整彻底能够作到与mactype媲美的字体渲染。(我全都要...)日志

首先是恢复 gfx.content.azure.backends 和 gfx.direct2d.disabled 的默认设置,让浏览器使用硬件加速和OMTP。

其次,停掉Mactype对firefox的渲染。

火狐浏览器 DIRECTWRITE 字体调节参数

来源:all.js - DXR

参数 取值范围 描述
gfx.font_rendering.cleartype_params.gamma [1000,2200] 伽马值
gfx.font_rendering.cleartype_params.enhanced_contrast [0,1000] 对比度
gfx.font_rendering.cleartype_params.cleartype_level [0,100] Cleartype等级
gfx.font_rendering.cleartype_params.pixel_structure 0 = flat; 1 = RGB; 2 = BGR; 像素结构
gfx.font_rendering.cleartype_params.rendering_mode [0,5] 渲染模式

rendering_mode的取值解释

  • 0 = 使用字体默认值
  • 1 = 抗锯齿
  • 2 = GDI 经典;
  • 3 = GDI 天然宽度;
  • 4 = 天然
  • 5 = 天然对称

个人参数

gfx.font_rendering.cleartype_params.cleartype_level;100
gfx.font_rendering.cleartype_params.enhanced_contrast;200
gfx.font_rendering.cleartype_params.gamma;2000
gfx.font_rendering.cleartype_params.pixel_structure;1
gfx.font_rendering.cleartype_params.rendering_mode;5

附 未调整的firefox、Mactype渲染的firefox、调整后的firefox 对比:

未调整:

未调整

Mactype:

mactype

调整后:

调整后

若是你刚好在使用Mactype+Firefox,那么你可能并无体验到新版本Firefox带来的速度提高

建议你关掉Mactype(或者停用Mactype对Firefox的调整),按照上面的方法打开硬件加速,调整字体配置,从新打开Firefox,感觉先后的渲染速度变化。

相关文章
相关标签/搜索