`
coolerbaosi
  • 浏览: 729693 次
文章分类
社区版块
存档分类
最新评论

Android RenderScript 学习笔记

 
阅读更多

RenderScriptAndroid平台的一种类C脚本语言,Google虽然一直在之前的各个Android版本内置的动态墙纸中使用该技术实现3D图形特效,但一直未将其集成在公开发布的SDK中。至Android3.0版本开始,SDK中已将RenderScript技术集成了进来,开发者可在Eclipse下开发基于RenderScript3D应用,并在Android3.0版本以上的平板电脑中运行。
RenderScript
是一种3D运行时框架,其提供构造3D场景的API函数,同时为最大程度的优化性能,还支持平台无关的shade语言。开发者不仅可以采用RenderScript技术来开发3D应用,还可以用来作特定的高性能数据处理。

关于RenderScript的详细内容大家可参见SDK

http://developer.android.com/guide/topics/renderscript/index.html

http://developer.android.com/guide/topics/renderscript/graphics.html

http://developer.android.com/guide/topics/renderscript/compute.html

本文主要对SDK中对RenderScript的特点作扼要的整理,后续将继续讨论如何采用RenderScript进行应用开发。

RenderScript的优点:

(1)Portability:RenderScript is designed to run on many types of devices withdifferent CPU and GPU architectures. It supports all of thesearchitectures without having to target each device, because thecode is compiled and cached on the device at runtime.

(2)Portability:RenderScript is designed to run on many types of devices withdifferent CPU and GPU architectures. It supports all of thesearchitectures without having to target each device, because thecode is compiled and cached on the device at runtime.

(3)Usability:RenderScript simplifies development when possible, such aseliminating JNI glue code and simplifying mesh setup.

RenderScript的不足:

(1)Portability: RenderScript is designed to run on many types ofdevices with different CPU and GPU architectures. It supports allof these architectures without having to target each device,because the code is compiled and cached on the device at runtime.

(2)Debugging visibility: RenderScript can potentially execute(planned feature for later releases) on processors other than themain CPU (such as the GPU), so if this occurs, debugging becomesmore difficult.

(3)Less features: RenderScript does not provide as many features asOpenGL such as all the compressed texture formats or GL extensions.

RenderScript应用包括三个层次:

(1)Native RenderScript layer

Thenative RenderScript layer consists of your RenderScript code, whichis compiled and executed in a compact and well defined runtime. YourRenderScript code has access to a limited amount of functions becauseit cannot access the NDK or standard C functions, since they must beguaranteed to run on a standard CPU. The RenderScript runtime wasdesigned to run on different types of processors, which may not bethe CPU, so it cannot guarantee support for standard C libraries.What RenderScript does offer is an API that supports intensivecomputation and graphics rendering with a collection of math andgraphics APIs.

(2) Reflected layer

Thereflected layer is a set of classes that the Android build toolsgenerate to allow access to the native RenderScript code from theAndroid VM. This layer defines entry points for RenderScriptfunctions and variables, so that you can interact with them with theAndroid framework. This layer also provides methods and constructorsthat allow you to allocate memory for pointers that are defined inyour RenderScript code.

(3)Android framework layer

TheAndroid framework layer consists of the usual Android framework APIs,which include the RenderScript APIs in android.renderscript.This layer handles things such as the Activity lifecycle and memorymanagement of your application. It issues high level commands to thenative RenderScript code through the reflected layer and receivesevents from the user such as touch and input events and relays themto your RenderScript code, if needed.

RenderScript的实例:

<sdk_root>/samples/android-11/RenderScript.


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics