Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Android Graphics system

Shulou Source: shulou.com Published: 2022-06-02 16:01:43 10月01日 Update

Android graphics system example analysis, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The Android graphics system adopts Client/Server architecture. SurfaceFlinger is mainly written by C++ code, and the Client code is divided into two parts. One part is the api provided by Java for applications, and the other part is the underlying implementation written by C++.

An important concept and clue in Android graphics system is surface. View and its subclasses (such as TextView, Button) should be painted on surface. Each surface creates a Canvas object (but properties change from time to time) to manage view's drawing operations on surface, such as dots and lines. Each canvas object corresponds to a bitmap that stores the content drawn on the surface.

There are several objects that are closely related to the Surface concept:

1. Java Surface (frameworks/base/core/java/android/view/Surface.java). The object is called indirectly by the application (via SurfaceView, ViewRoot, etc.), and the application needs to create a surface (and canvas at the same time), draw the graph onto the object and eventually deliver it to the screen.

2. C++ Surface (frameworks/base/libs/ui/Surface.cpp. This object is called by Java Surface through Jni to implement the function of Java Surface.

3. ISurface (and its derived class BnSurface). This object is the interface between the application and the server. C++ Surface creates the ISurface (BnSurface) and sends commands such as updating surface content to the screen. The Server side accepts this command and performs the corresponding operation.

Android.graphics, android.view and android.widget functions are similar to other similar graphics libraries such as Qt/Gtk+, providing basic graphics primitives (such as drawing dots and lines, setting graphics context, etc.). Event mechanism, as well as controls for developing graphical user interfaces. Canvas is used to develop 2D graphics, and Surface represents a surface that can be drawn by the graphics system. Android graphics can be drawn on it.

The drawing-related code is mainly located in the following directories:

1. Frameworks/base/graphics/java/android/graphics 2, frameworks/base/core/java/android/view 3, frameworks/base/core/java/android/widget 4, frameworks/base/opengl/ 5, frameworks/base/libs/ui 6, frameworks/base/libs/surfaceflinger 7, frameworks/base/core/jni/android/graphics 8, frameworks/base/core/jni/android/opengl 9, frameworks/base/core/jni/android/android_view_*.cpp 10, external/skia Have you mastered the method of example analysis of Android graphics system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Graphics objects systems content caching code applications examples analysis functions commands screens methods are made up of more concepts problems development important helpless Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Redmi MySQL Microsoft