Surface Flinger, SurfaceView, Surface, SurfaceHolder and Bitmap are Android

I learn from the Sufice Documentation, Sufi Flinger, SurfaceView, SurfaceHolder, and Bitmap. I found the following definitions:

Surface A surface is a collection of pixels. A Surface is an object that contains pixels that fit on the screen. Each window that you see on the screen (dialogue, full-screen activity, status bar) has its own surface that it accesses, and Surface Flinger displays them on the final display in their correct Z-order. A surface usually has more than one buffer (usually two) for double-buffering rendering: an application can draw its next UI state, while a surface flinger composes a screen using the last buffer, without waiting for the application to complete drawing.

SurfaceView This class is used to preview the camera in real time. SurfaceView is a special implementation of View that also creates its own dedicated Surface for an application that is directly retracted (outside the usual hierarchy of views, which otherwise would have to share one surface for the window).

Bitmap raster is a shell for collecting pixels, it is just an array of pixels with some other convenient features.

Canvas Canvas is a class that contains all the drawing methods. It is similar to the Graphics class in AWT / Swing in Java. It has all the logic about how to draw, drawer, etc. Canvas works with a bitmap.

But I do not know about SurfaceHolder and SurfaceFlinger , and according to the definition above, the bitmap is also a container of the pixel and the surface.

Can you help me clearly understand the definition of all these objects?

+4
source share
1 answer

A Canvas is the main context for drawing using the graphics API. You can create your own canvas that wraps a bitmap for off-screen drawing, and, of course, the user interface structure will skip the canvas for widgets so that they can attract themselves. All of these widgets are subclasses of View. Or, if they can contain other widgets, then they are a subclass of the ViewGroup (which is a subclass of View).

If you want to perform animation with a high frame rate, you need a subclass of SurfaceView (or its subclass GLSurfaceView, if you want to render OpenGL-ES on-screen). Each SurfaceView has a SurfaceHolder that has lockCanvas methods that you can call at any time to get a Canvas into which you could draw an updated display and send it back to the user to immediately see it through unlockCanvasAndPost.

For more information, see 2D Graphic Concepts and Custom Widget Tips

+2
source

Source: https://habr.com/ru/post/1412935/


All Articles