为什么要使用JNI在AWT的Canvas上绘画? [英] Why would you use JNI to paint on AWT's Canvas?

查看:81
本文介绍了为什么要使用JNI在AWT的Canvas上绘画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JNI很陌生,在探究JNI时偶然发现了这一点:

I'm pretty new to the JNI, and I stumbled across this while looking into the JNI:

本机代码不仅可以与Java进行接口,还可以在Java Canvas上进行绘制,而Java AWT本机接口则可以实现

Not only can native code interface with Java, it can also draw on a Java Canvas, which is possible with the Java AWT Native Interface

是否有特定原因才能使此功能特定/可用?它可以改善Windows系统上的处理时间吗?请详细说明为什么以及何时使用这种功能

Is there a specific reason why this functionality was made specific/is available? Does it improve processing time on Windows system? Please elaborate why and when one would use such a feature

推荐答案

首先要想到的是Java ...游戏中的本机性能渲染,但实际上要绘制任何需要大量计算或需要高边框的东西利率会受益.

Native performance rendering in Java... games would be the first thing to come to mind but really drawing anything that would be computationally intensive or that requires a high frame-rate would benefit.

官方Java解释:

从本机代码库直接绘制到Java Canvas中的能力对于计划将旧版软件系统迁移到Java的开发人员非常有用,尤其是其中包括高性能渲染引擎的开发人员.它使分阶段迁移变得更加容易,而无需考虑性能敏感的渲染代码,而将其他不那么敏感的代码部分转换为Java.结果可能是一种现代的以Java为中心的应用程序,提供了可移植性和开发效率的好处,但是却没有牺牲对关键本机代码段性能的投资.

The ability to draw directly into a Java Canvas from a native code library is extremely useful for developers planning to migrate a legacy software system to Java, especially one that includes a high-performance rendering engine. It makes it much easier to migrate in stages, leaving performance-sensitive rendering code alone, while other less-sensitive portions of code are converted to Java. The result can be a modern Java-centric application, providing the benefit of portability and development efficiency, but one that does not sacrifice an investment in performance of a key piece of native code.

这篇关于为什么要使用JNI在AWT的Canvas上绘画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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