In JxBrowser 6.10 and higher there's an option that allows enabling accelerated lightweight rendering mode. This rendering mode has improved performance compared to default lightweight rendering mode. It allows producing ~30% more frames per second.(在JxBrowser 6.10及更高版本中,有一个选项允许启用加速的轻量级渲染模式。与默认的轻量级渲染模式相比,此渲染模式具有更高的性能。它允许每秒多产生约30%的帧。)
Important: the only disadvantage of this accelerated rendering mode is that it doesn't support WebGL, because GPU process isn't used in this case. If you don't need to display web pages with WebGL, we recommend that you enable and use accelerated lightweight rendering mode.(重要提示:这种加速渲染模式的唯一缺点是它不支持WebGL,因为在这种情况下不使用GPU进程。如果不需要使用WebGL显示网页,建议您启用并使用加速的轻量级渲染模式。)
To enable accelerated lightweight rendering mode you must specify the following Chromium switches before you create the first Browser instance in your application:(要启用加速的轻量级渲染模式,必须在创建应用程序中的第一个Browser实例之前指定以下Chromium开关:)
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.BrowserPreferences; import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.chromium.swing.BrowserView; import javax.swing.*; import java.awt.*; public class AcceleratedLightweightRenderingSample { public static void main(String[] args) { BrowserPreferences.setChromiumSwitches( "--disable-gpu", "--disable-gpu-compositing", "--enable-begin-frame-scheduling", "--software-rendering-fps=60" ); Browser browser = new Browser(BrowserType.LIGHTWEIGHT); BrowserView view = new BrowserView(browser); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(view, BorderLayout.CENTER); frame.setSize(1100, 750); frame.setLocationRelativeTo(null); frame.setVisible(true); browser.loadURL("https://www.youtube.com/watch?v=lfwjzNB--5k"); } }