Test cell phone for ZTE Geek. This phone camera is still very good, than the hand of Huawei G700 Strong. Is that occasionally you can't even get on camera Service, Khan.
Can be seen from log. Onsurfacetextureavailable This callback takes some time. Camera.open () This sentence used more than 130 Ms. But two points are different from Surfaceview. First, Textureview is not entered into the onsurfacetexturesizechanged () function during the creation process. and Surfaceview in the creation process, from scratch into the size of changes in the callback.
second. onsurfacetextureupdated () This function comes in one frame of data each time .
This is compared with Surfaceview. One of the greatest places.
Through this interface. Can send the surfacetexture to OpenGL to deal with.
This callback is real-time. Instead of using the camera's previewcallback, this is a 2-time callback method.
From the time, basically every 32ms or so up a frame of data, that is, 30 frames per second. Match the performance of this phone's camera.
3, Camera again run Startpreview must ensure that the Textureview surfacetexture come up, assuming for some performance reasons onsurfacetextureavailable () This callback does not come on the preview, It's not going to open. Assuming this happens, run open and Startpreview operations in the onsurfacetextureavailable () callback to ensure foolproof.
4, Textureview itself has getsurfacetexture () This function, I also encapsulated a:
/* Allow activity to get textureview surfacetexture * @see android.view.textureview#getsurfacetexture () */public Surfacetexture _getsurfacetexture () {return msurface;}
The msurface here is the surfacetexture in the Onsurfacetextureavailable () callback. Test proof. Direct adjustment when opening preview
Textureview.getsurfacetexture (), pass it to Camera:mCamera.setPreviewTexture (surface), and you can preview it normally.
But it is recommended to use the former, for the reasons see the official paragraph:
A Textureview ' s surfacetexture can be obtained either by invokinggetSurfaceTexture()or by using aTextureView.SurfaceTextureListener. It is important to know that a surfacetexture are available only after the Textureview are attached to a window ( andonAttachedToWindow()Has been invoked.) It is therefore highly recommended your use of a listener to being notified when the surfacetexture becomes available.
Two ways to get surfacetexture, the recommended use of monitoring. Only when the Textureview run out of Onattachedtowindow, its tsurfacetexture came up.
5, surfacetexture and Textureview relationships:
Using a textureview is simple:all the need to does is get its surfacetexture . the Surfacetexture can then being used to render content
Assuming that Textureview is a painting, that surfacetexture is the canvas, the real vector of rendering is surfacetexture.
6,Textureview can run a variety of changes like general view. There is a textureview.setalpha (1.0f), the default does not write this sentence, its alpha is also 1.0f, that is, opaque.
If you set it to transparent 0.0f, you can see nothing, which is just the opposite of Surfaceview.
Surfaceview Surfaceholder generally want to set a transparent that is transparent. But Textureview because it is a view, no matter what a PNG photo transparency set to 0 must not see anything.
7, assuming that the preview camera this is the mission of Textureview and Surfacetexture, it is a big mistake, the real intention is to seamlessly connect with OpenGL.
--------------------this article is original. Reprint Please specify the author yanzi1225627
Version number: Playcamera_v2.0.0[2014-6-22].zip
csdn Download Link: http://download.csdn.net/detail/yanzi1225627/7540903
Baidu Cloud Disk: