English 中文(简体)
Java 加速硬件
原标题:Java Hardware Acceleration

我花了一些时间来审视 Java的硬件加速特征,我仍然感到困惑,因为我没有发现任何直接和明确地回答我所提问题的网站。 因此,我不得不在 Java加速硬件:

(1) 在Eclipse版本3.6.0中,最近对McOS X(我认为是1.6u10)的 Java更新是因违约而加速硬件? 我读到了其他地方。

someCanvas.getGraphicsConfiguration().getBufferCapabilities().isPageFlipping()

本来应该说明是否能够加速硬件,而我的方案报告在我的主要Canvas案件进行提取时,情况就已经恢复。 如果现在无法加速我的硬件,或者由于违约,我必须做些什么才能做到这一点?

2) 我在这里看到了两篇文章,其中谈到BufferedImage和VolalessImage之间的区别,主要是说,VolalessImage是硬件加速图像,储存在VRAM,用于快速复制业务。 然而,我也发现有些事例说,布莱多伊姆奇也加速了硬件。 我的环境是否也加速了变形的硬件? 如果这两种类型的硬件都加速,那么使用挥发性循环会有什么好处? 我的主要假设是,如果两个加速因素都能够产生挥发性,那就是,挥发性免疫力能够在其甚微变迁时发现。 但是,如果BufferedImage现在也支持加快速度,那么如果记忆被丢弃,它是否也不存在同样类型的发现,只是从使用者那里隐蔽的。

3) 是否有使用的任何好处

someGraphicsConfiguration.getCompatibleImage/getCompatibleVolatileImage()

而不是

ImageIO.read()

在一篇论文中,我读到了一些关于适当建立窗口的一般概念(>tutorial)中,它使用了“可比较的”方法,我认为这种方法回收了一种BufferedImage,以获取其“硬性加速”图像,如果硬件加速,这种图像就会与问题2相联系。

4) 硬件的加速程度较低,但我很想知道:我是否需要订购哪些图表? 我知道,在通过C/C++使用开放式GL时 最好确保在需要一劳永逸地抽取的所有地点打同样的图象,以减少目前案文需要改换的次数。 从我所读的角度来看,似乎 Java如果会照顾我,并确保以最优化的方式提取物品,但同样,从来没有说过像这一点这样的话。

5) 有哪些AWT/Swing级支持加速硬件,应当使用哪些级? 我目前正在使用一个把JFrame延伸到一个窗口的班子,并增加一个Canvas,我从这个班子里创立一种战略。 这种做法是不是好的做法,还是应该以某种其他方式实施?

我非常感谢你的时间,我希望我为回答我的几个问题提供了明确的问题和充分的信息。

最佳回答

1) So far hardware acceleration is never enabled by default, and to my knowledge it has not changed yet. To activate rendering acceleration pass this arg (-Dsun.java2d.opengl=true) to the Java launcher at program start up, or set it before using any rendering libraries. System.setProperty("sun.java2d.opengl", "true"); It is an optional parameter.

2) Yes BufferedImage encapsulates some of the details of managing the Volatile Memory because, when the BufferdImage is accelerated a copy of it is stored in V-Ram as a VolatileImage.

BufferedImage外,只要你不随带的颜料,仅将其照相照相打graphics.drawImage (, 则Buffered 页: 1

缩略语 图像是,如果您正在对图像进行编辑,改动<代码>BufferedImage中的标记,则在某些情况下,如果您正在寻找使编辑的表演者,你需要考虑管理自己的<代码> 图像/编码。 我不知道什么业务使<条码>BufferedImage放弃努力加快为你服务。

3) The advantage of using the createCompatibleImage()/createCompatibleVolatileImage() is that ImageIO.read() does not do any conversion to a default supported Image Data Model. So if you import a PNG it will represent it in the format built by the PNG reader. This means that every time it is rendered by a GraphicsDevice it must first be converted to a compatible Image Data Model.

BufferedImage image = ImageIO.read ( url );
BufferedImage convertedImage = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();
GraphicsDevice gd = ge.getDefaultScreenDevice ();
GraphicsConfiguration gc = gd.getDefaultConfiguration ();
convertedImage = gc.createCompatibleImage (image.getWidth (), 
                                           image.getHeight (), 
                                           image.getTransparency () );
Graphics2D g2d = convertedImage.createGraphics ();
g2d.drawImage ( image, 0, 0, image.getWidth (), image.getHeight (), null );
g2d.dispose()

以上程序将把图像与图像io相阅读的图像转换成一个有图像数据模型与缺省筛选装置相容的变异构体,因此在进行转换时不必进行转换。 最为有利的时代是你非常经常地使形象化。

4) You do not need to make an effort to batch your image rendering because for the most part Java will attempt to do this for you. There is no reason why you cant attempt to do this but in general it is better to profile your applications and confirm that there is a bottleneck at the image rendering code before you attempt to carry out a performance optimization such as this. The main disadvantage is that it my be implemented slightly differently in each JVM and then the enhancements might be worthless.

5) To the best of my knowledge the design you have outlined is one of the better strategies out there when doing Double Buffering manually and actively rendering an application. http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferStrategy.html At this link you will find a description of the BufferStrategy. In the description it shows a code snippet that is the recommended way to do active rendering with a BufferStrategy object. I use this particular technique for my active rendering code. The only major difference is that in my code. like you, I have created the BufferStrategy on an instance of a Canvas which I put on a JFrame.

问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签