Surface Flinger,SurfaceView,Surface,SurfaceHolder和Bitmap是Android

I am studying Suface document, Suface Flinger, SurfaceView, SurfaceHolder and Bitmap. I found the following definition:

Surface
Surface is pixel Collection. Surface is an object that saves pixels synthesized with the screen. Each window you see on the screen (dialog box, full-screen activity, status bar) has its own drawing surface, and Surface Flinger will correct it Z-order renders these windows to the final display. The surface usually has multiple buffers (usually two) for double-buffer rendering: the application can draw its next UI state, and the surface polisher uses the last buffer to compose the screen Without waiting for the application to finish drawing.

SurfaceView
This class is used to present a real-time camera preview to the user.
SurfaceView is a special implementation of View, which also creates its own for the application Dedicated Surface for direct drawing (outside of the normal view hierarchy, otherwise a single Surface of the window must be shared)

Bitmap
Bitmap is a wrapper for pixel collections, it is just a package with some Pixel array for other convenient functions.

Canvas
Canvas is a class that contains all drawing methods. It is similar to the Graphics class in AWT/Swing in Java. It has how to draw, boxes, etc. All logic. Anvas runs on Bitmap.

But I don’t know about SurfaceHolder and SurfaceFlinger. According to the above definition, bitmaps are also containers of pixels and Surface.

Can you help me understand? Understand the definitions of all these objects?

Canvas is the basic context for drawing using graphics API. You can create your own Canvas wrapper Bitmap to For off-screen drawing, of course the UI framework will pass Canvases to the widgets so that they can draw themselves. All these widgets are subclasses of View. Or, if they can contain other widgets, then they are subclasses of ViewGroup ( It is a subclass of View).

If you want to do high frame rate animation, then you need to start from SurfaceView (or its subclass GLSurfaceView, if you want to perform OpenGL-ES rendering on the screen) ) Is inherited from subclasses. Each SurfaceView has a SurfaceHolder, which has a lockCanvas method. You can call these methods at any time to get the Canvas, draw the updated display in it and post it back for the user to view immediately through unlockCanvasAndPost.

For more information, please refer to 2D graphics concepts and Custom widget tips

I am learning Suface documentation, Suface Flinger, SurfaceView, SurfaceHolder and Bitmap. I found the following Definition:

Surface
Surface is a collection of pixels. Surface is an object that saves pixels synthesized with the screen. Every window you see on the screen (dialog box, Full screen activity, status bar) has its own drawing surface, and Surface Flinger will render these windows to the final display in the correct Z order. The surface usually has multiple buffers (usually two) for double-buffer rendering: application The program can draw its next UI state, and the surface polisher uses the last buffer to synthesize the screen without waiting for the application to finish drawing.

SurfaceView
This class is used to present a real-time camera to the user Preview.
SurfaceView is a special implementation of View. It also creates its own dedicated Surface for the application for direct drawing (outside the normal view hierarchy, otherwise it must share a single Surface of the window)

Bitmap
Bitmap is a wrapper for pixel collection, it is just a pixel array with some other convenient functions.

Canvas
Canvas is a class that contains all drawing methods. It is similar AWT in Java The Graphics class in /Swing. It has all the logic of how to draw, boxes, etc. Anvas runs on Bitmap.

But I don’t know SurfaceHolder and SurfaceFlinger. According to the definition above, bitmaps are also pixels and Surface Container.

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

Canvas is the basic context for drawing using graphics API. You can create your own Canvas wrapper Bitmap for off-screen drawing, of course the UI framework will pass Canvases Give widgets so they can draw on their own. All these widgets are subclasses of View. Or, if they can contain other widgets, then they are subclasses of ViewGroup (it is a subclass of View).

< /p>

If you want to do high frame rate animation, then you need to inherit a subclass from SurfaceView (or its subclass GLSurfaceView, if you want to perform OpenGL-ES rendering on the screen). Each SurfaceView has one SurfaceHolder, it has lockCanvas methods, you can call these methods at any time to get the Canvas, draw the updated display in it and post it back for the user to view through unlockCanvasAndPost immediately.

For more information, please refer to 2D graphics concepts And Custom widget tips

Leave a Comment

Your email address will not be published.