Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Android Graphics system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report