/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2016-2020. All rights reserved. * Description: Support private hwgraphics hidl interface * Author: Hisilicon * Created: 2016.11.29 */ #ifndef HWGRAPHICS_IAPI_COMIMPL_H #define HWGRAPHICS_IAPI_COMIMPL_H #include #include #include "uapi_win.h" #include "uapi_gfx2d.h" #include "HwGalleryIapiAdapter.h" namespace android { class HwGalleryIapiComImpl : public HwGalleryIapiAdapter { public: class DequeueMessageHandler : public android::MessageHandler { public: void handleMessage(const android::Message& message) override; }; HwGalleryIapiComImpl(); ~HwGalleryIapiComImpl() override; int Init(uint32_t w, uint32_t h) override; int VoDeinit() override; int VoInit(uint32_t w, uint32_t h); int VoWindowSetting(td_u32 w, td_u32 h) override; int VoDoFramex(const private_handle_t& handle, const ExtendFrameInfo &extendInfo) override; int VoGetFormat(td_u32 &type) override; void VoGetWindowHandle(td_u32 &windowHandle) override; int VoDoFramexSync() override; void VoSetFrameInfo(const private_handle_t& handle, uapi_video_frame_info &stFrame, const ExtendFrameInfo &extendInfo); void GetDisplayId(void); bool Is8KFormat(); void GetDefaultWindowAttr(uapi_win_attr &pstWinAttr) const; void VoDoDequeue(void); int CreateDequeueThread() override; void DequeueThreadFun(void); void SendDequeueMessage(void) const; int RMRegister(void) override; int RMUnRegister(void) override; int RMAcquireResource(void) override; struct VideoBufferHandle { td_mem_handle_t handle; uint32_t width; uint32_t height; uint32_t stride; }; int InitVideoBuffer(uint32_t width, uint32_t height); int CreateVideoScreen(VideoBufferHandle &videoBufHandle, uint32_t width, uint32_t height); void DestroyVideoScreen(void); int ConvertARGBToYUV420SP(const private_handle_t& srcBufHandle, const VideoBufferHandle &videoBufHandle); void TdeCreateSrcSurface(uapi_gfx2d_surface &srcSurface, const private_handle_t &srcBufHandle, uapi_gfx2d_attr &attr) const; void TdeCreateDstSurface(uapi_gfx2d_surface &dstSurface, const VideoBufferHandle &videoBufHandle, uapi_gfx2d_attr &attr); private: void DealVideoFrameInfo(const private_handle_t &handle, uapi_video_frame_info &stFrame) const; std::vector m_videoBuffers; std::map m_colorSpaceMap; int m_frameRate; int m_formatType; bool m_isRmRegister; unsigned int m_frameIndex; int m_frameCount; int m_bufCount; bool m_isInitialized; android::sp m_looper; td_handle m_rmService; td_handle m_socWindow; uapi_disp m_displayId; }; } #endif