关于Canvas 绘制层中硬件加速的问题_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2273 | 回复: 0   主题:  关于Canvas 绘制层中硬件加速的问题        下一篇 
fozhyn
注册用户
等级:上士
经验:317
发帖:101
精华:0
注册:2011-10-18
状态:离线
发送短消息息给fozhyn 加好友    发送短消息息给fozhyn 发消息
发表于: IP:您无权察看 2015-3-26 18:02:28 | [全部帖] [楼主帖] 楼主

关于 Hardware Acceleration

  1、不同层级的加速:

Application

<applicationandroid:hardwareAccelerated="true" ...>

;
Activity

<application android:hardwareAccelerated="true">
<activity ... />
<activity android:hardwareAccelerated="false" />
</application>

;
Window

getWindow().setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

;
View

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

;

2、如何判断是否开启了硬件加速

在绘制之前,你必须做该测试 Canvas.isHardwareAccelerated() 替代View.isHardwareAccelerated() 在必要时。

View.isHardwareAccelerated() ;//returns true if the View is attached to a hardware accelerated window.
Canvas.isHardwareAccelerated();// returns true if the Canvas is hardware accelerated

;

3、开启硬件加速之后,许多2D的绘制方法会抛出异常:

clipPath()
clipRegion()
drawPicture()
drawTextOnPath()
drawVertices()
Paint
setLinearText()
setMaskFilter()
setRasterizer()
Xfermodes
AvoidXfermode
PixelXorXfermode
In addition, some operations behave differently with hardware acceleration enabled:
Canvas
clipRect(): XOR, Difference and ReverseDifference clip modes are ignored. 3D transforms do not apply to the clip rectangle
drawBitmapMesh(): colors array is ignored
Paint
setDither(): ignored
setFilterBitmap(): filtering is always on
setShadowLayer(): works with text only
PorterDuffXfermode
PorterDuff.Mode.DARKEN will be equivalent to SRC_OVER when blending against the framebuffer.
PorterDuff.Mode.LIGHTEN will be equivalent to SRC_OVER when blending against the framebuffer.
PorterDuff.Mode.OVERLAY will be equivalent to SRC_OVER when blending against the framebuffer.
ComposeShader
ComposeShader can only contain shaders of different types (a BitmapShader and a LinearGradient for instance, but not two instances of BitmapShader )
ComposeShader cannot contain a ComposeShader


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论