Linux 上的 Java 2D 页面翻转

发布于 2024-12-06 00:40:46 字数 1394 浏览 1 评论 0原文

我们的 Java 2D 应用程序在 Linux 上运行时会出现屏幕撕裂的情况。在 Windows 上运行时,它不会出现任何撕裂现象。我们花费了大量时间分析代码,但尚未找到原因。虽然我从来没有断定这一定不是我的代码的错误,但我也认为问题可能出在 Linux 上的 Java 2D 渲染管道上。顺便说一句,请注意,我们在 Java 6 和 Java 7 中都看到了撕裂现象。在 Java 7 上运行时,无论是否启用 XRender 管道,我们都会看到撕裂现象。

我们当然通过 BufferStrategy 使用双缓冲。调用 Frame.createBufferStrategy(2) 时获得的 BufferStrategy 实现是一个 java.awt.Component$FlipSubRegionBufferStrategy。此外,在 BufferStrategyBufferCapability 上调用 isPageFlipping() 返回 true,并在功能返回 false。我们没有以全屏独占模式运行,尽管我们已经尝试过这样做,但并没有解决问题。 BufferCapability.getFlipContents() 返回 FlipContents.UNDEFINED (但我怀疑这不相关)。

由于据说支持页面翻转,并且我们得到了页面翻转 BufferStrategy (而不是位图传输策略),因此我不认为渲染管道会导致撕裂。然而,我发现 Chet Haase 在 2006 年撰写的邮件列表消息解决了屏幕撕裂问题,其中指出:“您特定平台上的 Flip 策略可能实际上在幕后进行复制,这与BltBufferStrategy,它正好与刷新工件发生冲突。”

如何确定我们获得的翻页策略是否实际上不是翻页?

Chet 还指出,“使用 BufferStrategy 运行全屏是解决此问题的一个不错的方法;具体取决于平台和这种情况,我们通常会给你一个翻转策略,它(通常)与显示器的垂直刷新同步,以避免撕裂。”

如何确定该策略是否与显示器的垂直刷新同步?

(请参阅http://www.mail-archive.com/[email protected]/msg03743.html 查看上面引用的 Chet Haase 的完整消息)

Our Java 2D application exhibits screen tearing when run on Linux. It does not exhibit any tearing when running on Windows. We've spent significant time analyzing our code, and haven't yet found a cause there. While I'm never one to decide that it must not be my code at fault, I'm also entertaining the possibility that the issue is with the Java 2D rendering pipeline on Linux. By the way, please note that we see the tearing with both Java 6 and Java 7. When running on Java 7, we see the tearing regardless of whether we enable the XRender pipeline or not.

We are of course using double-buffering via a BufferStrategy. The BufferStrategy implementation we get when we call Frame.createBufferStrategy(2) is a java.awt.Component$FlipSubRegionBufferStrategy. In addition, calling isPageFlipping() on the BufferStrategy's BufferCapabilities returns true, and calling isFullScreenRequired() on the capabilities returns false. We are not running in full-screen exclusive mode, though we have tried doing so and it did not resolve the issue. BufferCapabilities.getFlipContents() returns FlipContents.UNDEFINED (but I suspect that is not relevant).

Since page-flipping is supposedly supported and we're getting a page-flipping BufferStrategy (rather than a blitting strategy), I would not expect the rendering pipeline to be causing the tearing. However, I found a mailing list message written by Chet Haase back in 2006 addressing a screen tearing problem which states, "It's possible that the Flip strategy on your particular platform is actually doing a copy behind the scenes, which would be the same as the BltBufferStrategy, which runs smack into the refresh artifact."

How can I determine if the flip strategy we're getting is not actually page-flipping?

Chet also states, "Running fullscreen with a BufferStrategy is a decent way to work around this; depending on the platform and the situation, we will usually give you a Flip strategy, which is (usually) synchronized with the vertical refresh of the display to avoid tearing."

How can I determine if the strategy is synchronized with the display's vertical refresh?

(See http://www.mail-archive.com/[email protected]/msg03743.html for the full message from Chet Haase referenced above)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谈情不如逗狗 2024-12-13 00:40:46

根据发行版的不同,许多 Linux 系统现在都提供默认 3D 渲染的桌面。如果您的其中一款显卡的开源驱动程序的 3D 加速性能较差(或缺失),您可能需要安装专有的 3D 驱动程序,以使桌面渲染处于正常桌面使用的可接受容差范围内。

请记住,如果您的代码在其他平台上看起来正确并且性能良好;很可能它在 Linux 上是正确的。只是 Linux 有更多的“渲染架构”差异,考虑到 X 的历史和设计目标,这是可以预料的。很可能您的图形信息正在及时发送,但配置管道却无法跟上(因此它会下降一点,导致撕裂)。

现在针对具体问题

如何确定我们获得的翻页策略是否实际上不是翻页?

通过调用您已经调用的方法。

如何确定该策略是否与显示器的垂直刷新同步?

很难说,因为该策略的全部要点是向 API 用户隐藏令人讨厌的细节。我不是躲在这些掩护下的合适人选;但是,我确实从 X 方面看事情很清楚。

我问你的问题是,“除了你自己的应用程序之外,这种撕裂现象还会出现在其他应用程序中吗?”

Depending on the distro, many Linux systems are now shipping desktops that are 3d rendered by default. If you have one of the graphics cards which has poor (or missing) 3d acceleration with open-source drivers, you may need to install a proprietary 3d driver to get the desktop rendering within the acceptance tolerances for normal desktop use.

Remember that if your code looks right on other platforms, and performs admirably there; odds are it is right on Linux. It's just that Linux has a lot more "rendering architecture" variance, as would be expected considering X's history and design goals. Chances are your graphics information is being sent in a timely manner, but the config pipeline just can't keep up (so it drops a little, resulting in tearing).

Now for the specific questions

How can I determine if the flip strategy we're getting is not actually page-flipping?

By calling the methods you have already called.

How can I determine if the strategy is synchronized with the display's vertical refresh?

Hard to say, because the entire point of the strategy is to hide the nasty details from the API user. I'm not the right person to dive under these covers; but, I do have a good view of things from the X side.

My question to you, "Does this tearing exhibit in any other application besides your own?"

空心空情空意 2024-12-13 00:40:46

您是否考虑过问题可能是在Windows上您使用的是oracle jdk,而在Linux上您使用的是open jdk?

很容易找出来。在您的 Linux 计算机上安装 oracle jdk 并针对 oracle jre 运行。

有关如何安装 此处

有关如何在已安装的 jre 版本之间切换的详细信息 此处

have you considered that the issue may be that on windows you are using oracle jdk and on linux you are using open jdk?

Its easy to find out. Install oracle jdk on your linux machine and run against the oracle jre.

Instructions on how to install here

Details on how to switch between installed versions of jre here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文