Android的TextureView硬件加速lockCanvas() [英] Android TextureView hardware acceleration with lockCanvas()

查看:2905
本文介绍了Android的TextureView硬件加速lockCanvas()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用硬件加速为Android与我的画布。我曾经有一个 SurfaceView 我照做了 lockCanvas()上获得的画布这是我后来借鉴,但我改成 TextureView ,因为我不能让 SurfaceView 来使用硬件加速。目前,我正在试图让这个画布上使用硬件加速。

I'm trying to use the hardware acceleration for Android with my canvas. I used to have a SurfaceView which I did lockCanvas() on to get a canvas which I later draw on, but I changed to TextureView since I couldn't get SurfaceView to use hardware acceleration. I'm currently trying to get this canvas to use hardware acceleration.

Canvas canvas = this.lockCanvas();
System.out.println(this.isHardwareAccelerated() + ", " + canvas.isHardwareAccelerated());

给我的输出:真的,假的 ( TextureView

Gives me the output: true, false (this is a TextureView)

有谁知道为什么画布不是硬件加速,以及如何使这样呢?

Does anyone know why the canvas is not hardware accelerated, and how to make it so?

编辑:据我发现,似乎我必须使用OpenGL。不过,我仍想知道是否有任何宣布,计划使硬件加速,可能对于这样的画布。

As far as I have found, it seems that I have to use OpenGL. However, I would still like to know if there are any announced plans to make hardware acceleration possible for such a canvas.

推荐答案

TextureView 仅当应用程序的硬件加速,但画布 lockCanvas返回()目前从来没有硬件加速。这意味着你将绘制在 TextureView 的软件画布,而 TextureView 本身将被使用GPU绘制。目前,获得硬的唯一途径加速Canvas是要使用的视图的的OnDraw(画布)方法。

TextureView works only when the application is hardware accelerated, but the Canvas it returns from lockCanvas() is currently never hardware accelerated. This means that you will draw inside the TextureView's Canvas in software, but TextureView itself will be drawn using the GPU. Currently, the only way to get a hardware accelerated Canvas is to use the onDraw(Canvas) method of a View.

这篇关于Android的TextureView硬件加速lockCanvas()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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