1
. Preface:
If the processor only has
2d
Hardware acceleration
3D
Hardware acceleration, you can use
OpenGL
In
Libagl
, Which is encapsulated in
Libagl
In
Copybit
Because
3D API
The encapsulation of this module
Google
Basically, you only need to implement one
Copybit hal
If the processor
2D/3D
Hardware acceleration is available, so it can be dropped out.
Copybit
To implement
OpenGL
Es 2D/3D API
.
2
.
Android
System hardware acceleration process:
Frameworks/base/OpenGL/libs/EGL. cpp
File through
Egl_init_drivers ()->
Egl_init_drivers_locked ()
The call is defined in
Frameworks/base/OpenGL/libs/EGL/loader. c
File
Loader: Open
Function Open Software and Hardware
EGL
Acceleration driver.
Frameworks/base/OpenGL/libs/EGL/loader. c
File
Loader: Loader ()
Function to open the hardware acceleration configuration file
/System/lib/EGL. cfg
And assigned
Dpy
,
Impl
,
Tag
Three variables, if the hardware acceleration configuration file
/System/lib/EGL. cfg
Does not exist, then
Dpy = 0
,
Impl = 0
,
Tag = android
, So
Loader: open ()
Function
Dpy
,
Impl
And
Tag
To decide to load the default dynamic library for Software Acceleration
/System/lib/EGL/libgles_android.so
In
EGL
,
Glesv450cm
,
Glesv2
Three functions. If the load is successful
New
One
Driver_t
Architecture, and use the loaded function for initialization. The system studied in this article exists
/System/lib/EGL. cfg
File in the format
0 1 sxwboy
, So
Dpy = 0
,
Impl = 1
,
Tag = sxwboy
.
Loader: open ()
Function
Dpy
,
Impl
And
Tag
To determine whether to load the dynamic hardware library.
/System/lib/EGL/libgles_sxwboy.so
In
EGL
,
Glesv450cm
,
Glesv2
Three functions. If the load is successful
New
One
Driver_t
And use the loaded functions for initialization. If the loading fails, load them separately.
/System/lib/EGL/libegl_sxwboy.so
,
/System/lib/EGL/libglesv1_cm_sxwboy.so
,
/System/lib/EGL/libglesv2_sxwboy.so
The corresponding functions in the Three dynamic libraries.
Note:
Libgles_android.so
For Compilation
Frameworks/base/OpenGL/libagl/
Directory, which has a dedicated
Copybit. cpp
File pair
Copybit
Modules are further encapsulated.
Libagl
In
Frameworks/base/OpenGL/libagl/Android. mk
File Definition
Libagl_use_gralloc_copybits: = 1
To load
Copybit
Module; if not defined
Libagl_use_gralloc_copybits
Is not used through software.
Copybit
Module to achieve
2d
Hardware acceleration.
3
. Only
2d
Hardware acceleration:
Frameworks/base/OpenGL/libagl/EGL. cpp
File used in
Hardware/libhardware/hardware. c
The
Hw_get_module ()
Function, which determines whether the obtained system attribute is in
Variant_keys []
Defined in the array, through
Load ()
Function load the corresponding hardware module; otherwise, load
Default
Hardware module. Therefore, we need to study
Libagl
, Implement the corresponding
Copybit
Hardware module.
Note: not all codes use encapsulated
Copybit
, Not just
OpenGL
Available
Copybit
Module. For example:
Libagl/EGL. cpp
File contains
Copybit
The function is used directly.
Copybit
Of
Bits
;
Frameworks/base/libs/surfaceflinger/layerbuffer. cpp
File
Layerbuffer: buffersource: ondraw ()
The function is used directly.
Copybit
Of
Set_parameter
,
Layerbuffer: onfirstref ()
The function is opened directly.
Copybit
Module.
4
.
2D/3D
Hardware acceleration requires:
Research required
OpenGL
Es
And implement
/System/lib/EGL/libgles_sxwboy.so or
/System/lib/EGL/libegl_sxwboy.so
,
/System/lib/EGL/libglesv1_cm_sxwboy.so
,
/System/lib/EGL/libglesv2_sxwboy.so
Dynamic library to provide
OpenGL ES 2D/3D
Hardware acceleration
API
.