/* * 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 "uapi_disp.h" #include "uapi_video.h" #include "uapi_gfx2d.h" #include "HwGraphicsIapiAdapter.h" namespace android { class HwGraphicsIapiComImpl : public HwGraphicsIapiAdapter { public: HwGraphicsIapiComImpl(); ~HwGraphicsIapiComImpl() override; int InitVoModule() override; int CloseVoWindow(uint32_t window) override; int DeinitVoModule() override; int CaptureScreenByVDP(CaptureInfoData captureInfo) override; int InitCast(uint64_t display, uint32_t format, uint32_t width, uint32_t height) override; int CastFrame(int32_t castHandle, const private_handle_t &handle, int fence, int &acquireFence) override; void SetBlackCastFrame(const bool isBlack) override; int CloseCast(int32_t castHandle) override; private: int AcquireSnapshot(CaptureInfoData captureInfo, uapi_disp_snap_attr &ptSnapAttr, uapi_video_frame_info &ptCapPicture); int CaptureWinPicture(CaptureInfoData captureInfo, uapi_video_frame_info &ptCapPicture); int InitTdeData(uapi_gfx2d_list &surfaceList, uapi_gfx2d_surface &srcSurface, uapi_gfx2d_surface &dstSurface, uapi_gfx2d_attr &attr) const; void ConvertFormatToTDE(int andrFormat, uapi_gfx2d_color_fmt &gfx2dFormat) const; void ConvertFormatFromVideoToTDE(uapi_gfx2d_color_fmt &srcSurfaceFormat, const uapi_video_pixel_format &captureFormat) const; void PrepareTdeSourceSurfaceData(uapi_gfx2d_surface &srcSurface, const uapi_video_frame_info &capPicture, HwRect rect); void PrepareTdeDstSurfaceData(uapi_gfx2d_surface &dstSurface, const CaptureInfoData &data); int ConvertSnapShotByTDE(const CaptureInfoData &outCaptureInfo, const uapi_video_frame_info &pstCapPicture); int CopyBufferByTDE(const uapi_video_frame_info &frameInfo, const private_handle_t &dstHandle); void PrepareSrcSurface(uapi_gfx2d_surface &srcSurface, const uapi_video_frame_info &frameInfo) const; void PrepareDstSurface(uapi_gfx2d_surface &dstSurface, const private_handle_t &dstHandle) const; bool IsSimultaneousDisplay() const; bool IsDiscardFrame(int32_t systemFrameRate, int32_t needFrameRate, int32_t frameRateCount) const; int fillFrame(uapi_video_frame_info& frameInfo, const private_handle_t &handle); bool m_debugCapture; bool m_debugCast; bool m_enableTdeCopy; bool m_needSetBlackFrame = false; bool m_lastBlackFrame = false; int64_t castFrameStart = 0; const unsigned int uMax16K = 15360; const unsigned int uMax16KMul4 = 61440; const int half = 2; const int max16K = 15360; const int max16KMul4 = 61440; const int rateMulToMills = 1000; bool m_lastNeedBlackFrame = false; bool m_isRecord = false; uint32_t m_needBlackFrameCount = 0; const int delayBlackFrame = 10; uint32_t m_frameWidth = 0; uint32_t m_frameHeight = 0; uapi_gfx2d_color_fmt tdeFormat; // the frame that we need uint32_t setFrameRate = 0; // Counting the total number of recorded and dropped frames int32_t allFrameCount = 0; // timing frame rate uint32_t timingFrameRate = 0; // default frame rate const uint32_t defaultFrameRate = 30; }; } #endif