Android SurfaceView vs TextureView

This page is intended to briefly introduce the differences between SurfaceView and TextureView.

SurfaceView and TextureView

Both SurfaceView and TextureView are inherited from android.view.View class. They can be drawn and rendered from a separate thread, which is the major difference from other views. The feature of drawing separately is employed by Crosswalk to improve rendering performance greatly by a dedicated GPU thread.

SurfaceView provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen. Its behavior is more or less similar as an onscreen Window on a traditional desktop system, for example, XWindow on X11 system which can be frameless and embedded inside another XWindow.

The followings are two limitations of SurfaceView:

  • You can not be animated, transformed and scaled;
  • You can not overlay two SurfaceView.

TextureView looks like a general View. You can animate, transform and scale it, just like a TextView. TextureView can only be used in a hardware accelerated window. However, TextureView will consume much more memory than SurfaceView, and also may have a 1~3 frame latency. See the discussion on [3]

Use Animitable XWalkView

Crosswalk Embedding API for Android supports both SurfaceView and TextureView very well. TheXWalkView uses SurfaceView as default, but it allows your to use TextureView as well in case of:

  • You want to make XWalkView can be animated and transformed, or
  • You want to overlay two XWalkViews

by setting the boolean flag ANIMATIBLE_XWALK_VIEW to true for TextureView usage.

  1. http://developer.android.com/reference/android/view/SurfaceView.html
  2. http://developer.android.com/reference/android/view/TextureView.html
  3. https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/Z0yE-PWQXc4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值