Android Overlay HAL架构初探



1 overlay可能支持的颜色格式
/* possible overlay formats可能支持的颜色格式 */
enum {
    OVERLAY_FORMAT_RGBA_8888    = HAL_PIXEL_FORMAT_RGBA_8888,
    OVERLAY_FORMAT_RGB_565      = HAL_PIXEL_FORMAT_RGB_565,
    OVERLAY_FORMAT_BGRA_8888    = HAL_PIXEL_FORMAT_BGRA_8888,
    OVERLAY_FORMAT_YCbCr_422_SP = HAL_PIXEL_FORMAT_YCbCr_422_SP,
    OVERLAY_FORMAT_YCbCr_420_SP = HAL_PIXEL_FORMAT_YCbCr_420_SP,
    OVERLAY_FORMAT_YCbYCr_422_I = HAL_PIXEL_FORMAT_YCbCr_422_I,
    OVERLAY_FORMAT_YCbYCr_420_I = HAL_PIXEL_FORMAT_YCbCr_420_I,
    OVERLAY_FORMAT_CbYCrY_422_I = HAL_PIXEL_FORMAT_CbYCrY_422_I,
    OVERLAY_FORMAT_CbYCrY_420_I = HAL_PIXEL_FORMAT_CbYCrY_420_I,
    OVERLAY_FORMAT_DEFAULT      = 99    // The actual color format is determined
                                        // by the overlay
};

2 overlay_control_device_t结构的子函数

   /* get static informations about the capabilities of the overlay engine 获取overlay引擎的固定信息*/
    int (*get)(struct overlay_control_device_t *dev, int name);

    /* creates an overlay matching the given parameters as closely as possible.根据所给的参数,尽可能得创建一个overlay。
     * returns an error if no more overlays are available. The actual 如果没有更多的overlay可获取,返回错误。
     * size and format is returned in overlay_t. 实际的尺寸和格式通过overlay_t结构返回*/
    overlay_t* (*createOverlay)(struct overlay_control_device_t *dev,
            uint32_t w, uint32_t h, int32_t format);
   
    /* destroys an overlay. This call releases all 销毁一个overlay,释放所有资源
     * resources associated with overlay_t and make it invalid */
    void (*destroyOverlay)(struct overlay_control_device_t *dev,
            overlay_t* overlay);

    /* set position and scaling of the given overlay as closely as possible. 根据所给的参数,尽可能的设置坐标和缩放。
     * if scaling cannot be performed, overlay must be centered. 如果无法执行尺寸变化,必须为中心覆盖*/
    int (*setPosition)(struct overlay_control_device_t *dev,
            overlay_t* overlay,
            int x, int y, uint32_t w, uint32_t h);

    /* returns the actual position and size of the overlay 获取overlay的实际位置*/
    int (*getPosition)(struct overlay_control_device_t *dev,
            overlay_t* overlay,
            int* x, int* y, uint32_t* w, uint32_t* h);

    /* sets configurable parameters for this overlay. returns an error if not设置配置参数,如果不支持返回错误
     * supported. */
    int (*setParameter)(struct overlay_control_device_t *dev,
            overlay_t* overlay, int param, int value);
/*以下两个函数没有实现*/
    int (*stage)(struct overlay_control_device_t *dev, overlay_t* overlay);
    int (*commit)(struct overlay_control_device_t *dev, overlay_t* overlay);


3、 overlay_data_device_t结构体函数子函数
    /* initialize the overlay from the given handle. this associates this通过传入的handle初始化overlay
     * overlay data module to its control module将data模块附加到控制模块上 */
    int (*initialize)(struct overlay_data_device_t *dev,
            overlay_handle_t handle);

    /* can be called to change the width and height of the overlay.改变overlay的宽度和高度 */
    int (*resizeInput)(struct overlay_data_device_t *dev,
            uint32_t w, uint32_t h);
/*以下三个函数没有实现*/
    int (*setCrop)(struct overlay_data_device_t *dev,
            uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;

    int (*getCrop)(struct overlay_data_device_t *dev,
       uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;

    int (*setParameter)(struct overlay_data_device_t *dev,
            int param, int value);

    /* blocks until an overlay buffer is available and return that buffer.阻塞直到一个overlay释放buffer */
    int (*dequeueBuffer)(struct overlay_data_device_t *dev,
           overlay_buffer_t *buf);

    /* release the overlay buffer and post it释放overlay buffer,post我理解是贴到screen上 */
    int (*queueBuffer)(struct overlay_data_device_t *dev,
            overlay_buffer_t buffer);

    /* returns the address of a given buffer if supported, NULL otherwise.返回given buffer的地址 */
    void* (*getBufferAddress)(struct overlay_data_device_t *dev,
            overlay_buffer_t buffer);
/*暂未实现*/
    int (*getBufferCount)(struct overlay_data_device_t *dev);

4、get()函数可以提供的种类
enum {
    /* Maximum amount of minification supported by the hardware硬件支持的最大缩小倍数*/
    OVERLAY_MINIFICATION_LIMIT      = 1,
    /* Maximum amount of magnification supported by the hardware硬件支持的最大放大倍数 */
    OVERLAY_MAGNIFICATION_LIMIT     = 2,
    /* Number of fractional bits support by the overlay scaling engine 缩放引擎支持的小数位数 */
    OVERLAY_SCALING_FRAC_BITS       = 3,
    /* Supported rotation step in degrees. 旋转步进*/
    OVERLAY_ROTATION_STEP_DEG       = 4,
    /* horizontal alignment in pixels 像素中的水平对齐?*/
    OVERLAY_HORIZONTAL_ALIGNMENT    = 5,
    /* vertical alignment in pixels 像素中的垂直对齐*/
    OVERLAY_VERTICAL_ALIGNMENT      = 6,
    /* width alignment restrictions. negative number for max. power-of-two 宽度对齐限制。负数为最大值。双功率?*/
    OVERLAY_WIDTH_ALIGNMENT         = 7,
    /* height alignment restrictions. negative number for max. power-of-two 高度对齐限制。负数为最大值。双功率?*/
    OVERLAY_HEIGHT_ALIGNMENT        = 8,
};

5、设置setParameter()函数可设置的种类
enum {
    /* rotation of the source image in degrees (0 to 359)源图像旋转角度(0 到 359)6410好像还不支持任意角度旋转 */
    OVERLAY_ROTATION_DEG = 1,
    /* enable or disable dithering */
    OVERLAY_DITHER        = 3,
    /* transformation applied (this is a superset of COPYBIT_ROTATION_DEG) */
    OVERLAY_TRANSFORM    = 4,
};

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android overlay是一种在Android应用程序中实现界面定制化的技术。通过使用overlay,开发者可以在不修改原始应用程序代码的情况下,添加、修改或替换应用程序的布局、样式和资源。在Android中,overlay通常是通过创建一个新的AndroidManifest.xml文件来实现的。\[1\] 在创建AndroidManifest.xml文件时,需要指定overlay的优先级、是否静态以及目标包名。优先级决定了overlay的显示顺序,静态表示overlay在运行时不会被修改,目标包名指定了要进行定制化的应用程序。\[1\] 除了创建AndroidManifest.xml文件,还可以参考一些相关的资料来了解更多关于Android overlay的信息。例如,可以参考http://mmmyddd.github.io/wiki/android/overlay.html和https://developer.sonymobile.com/2014/04/22/sony-contributes-runtime-resource-overlay-framework-to-android-code-example/。\[2\] 在编译后生成的apk中,overlay的路径可以根据不同的方案进行调整。一种常见的路径是vendor/overlay/TestOverlay/TestOverlay.apk,可以通过设置LOCAL_MODULE_PATH来指定路径。\[3\] #### 引用[.reference_title] - *1* *3* [Android Overlay机制](https://blog.csdn.net/weixin_44021334/article/details/130421043)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Android overlay简单总结](https://blog.csdn.net/Dylan_Sen/article/details/78878641)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值