You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
4.1 KiB
132 lines
4.1 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2020. All rights reserved.
|
|
* Description: DolGLDrawSurface
|
|
* Author:
|
|
* Create: 2020-01-03
|
|
*/
|
|
|
|
#ifndef GL_DRAW_THREAD_H
|
|
#define GL_DRAW_THREAD_H
|
|
|
|
#include <queue>
|
|
|
|
#include "EGLManager.h"
|
|
#include "FontAtlas.h"
|
|
#include "FBOManager.h"
|
|
#include "OSDText.h"
|
|
#include "OSDBitmap.h"
|
|
#include "OSDFrame.h"
|
|
#include "OSDRect.h"
|
|
#include "OSDRound.h"
|
|
#include "OSDBlit.h"
|
|
#include "FontStyleAtlas.h"
|
|
#include "DrawCmd.h"
|
|
|
|
namespace dolgles {
|
|
// DolGLES function
|
|
constexpr EGL_U32 ENDABLE_DRAW_TEXT = 0x1;
|
|
constexpr EGL_U32 ENDABLE_BLIT = 0x2;
|
|
constexpr EGL_U32 ENDABLE_DISPLAY_BITMAP = 0x4;
|
|
constexpr EGL_U32 ENDABLE_DRAW_RECT = 0x8;
|
|
constexpr EGL_U32 ENDABLE_DISPLAY_FBO = 0x10;
|
|
constexpr EGL_U32 ENDABLE_FBO = 0X20;
|
|
constexpr EGL_U32 ENDABLE_DRAW_ROUND = 0X40;
|
|
|
|
constexpr EGL_U32 DEFAULT_WINDOW_WIDTH = 1920;
|
|
constexpr EGL_U32 DEFAULT_WINDOW_HEIGHT = 1080;
|
|
|
|
constexpr char DEFAULT_FONT_LIB[] = "/system/fonts/CC3.ttf";
|
|
|
|
struct TagFboInfo {
|
|
EGL_U32 fboHandleIndex = FBO_INVALID_HANDLE;
|
|
GLsizei width = 0;
|
|
GLsizei height = 0;
|
|
GLint glFormat = 0;
|
|
};
|
|
|
|
using FboInfo = TagFboInfo;
|
|
|
|
struct TagFontLibInfo {
|
|
std::string fontLibPath = DEFAULT_FONT_LIB;
|
|
EGL_U32 fontSize = FONTSIZE_STANDARD;
|
|
};
|
|
|
|
using FontLibInfo = TagFontLibInfo;
|
|
|
|
class GLDrawThread {
|
|
public:
|
|
GLDrawThread();
|
|
~GLDrawThread();
|
|
EGL_S32 Init();
|
|
EGL_S32 DeInit();
|
|
void DrawThread();
|
|
void SendCmdToQueue(std::shared_ptr<DrawCmd> &drawCmd);
|
|
EGL_S32 SendCmdAndWaitResponse(std::shared_ptr<DrawCmd> &drawCmd);
|
|
void SetNativeWindow(EGLNativeWindowType nativeWindow);
|
|
EGL_U32 GetWindowWidth() const;
|
|
EGL_U32 GetWindowHeight() const;
|
|
void SetEnable(EGL_U32 enable);
|
|
void SetFontLibInfo(const std::string &fontLibPath, EGL_U32 fontSize);
|
|
void SetFboInfo(GLsizei width, GLsizei height, GLint glFormat);
|
|
EGL_S32 GetFBOInst(EGL_U32 fboHandleIndex, FrameBuffObject &fbo);
|
|
void SetBitmapInfo(const GLBitmapInfo &info);
|
|
EGL_S32 GetTextSize(const GLTextInfo &textInfo, EGL_U32 &width, EGL_U32 &height);
|
|
|
|
private:
|
|
std::shared_ptr<DrawCmd> ReadCmdFromQueue();
|
|
EGL_S32 DrawCmdProc(std::shared_ptr<DrawCmd> &drawCmd);
|
|
void ResultProc(std::shared_ptr<DrawCmd> &drawCmd, EGL_S32 result);
|
|
|
|
EGL_S32 SetupGLESConext();
|
|
EGL_S32 ResetGLESConext();
|
|
EGL_S32 GLInit(EGL_U32 enable);
|
|
EGL_S32 ConnectWindowSurface();
|
|
EGL_S32 LoadFont();
|
|
EGL_S32 CreateGLFBO(std::shared_ptr<DrawCmd> &drawCmd);
|
|
EGL_S32 DestoryGLFBO(EGL_U32 fboHandleIndex) const;
|
|
EGL_S32 ClearGLFBO(EGL_U32 fboHandleIndex);
|
|
EGL_S32 DrawFBO(const std::unique_ptr<BlitInfo> &blitInfo);
|
|
EGL_S32 Blit(const std::unique_ptr<BlitInfo> &blitInfo);
|
|
EGL_S32 DrawText(const std::unique_ptr<TextInfo> &textInfo);
|
|
EGL_S32 DisplayBitmap();
|
|
EGL_S32 DrawBitmap(EGL_U32 fboHandleIndex);
|
|
EGL_S32 DrawRect(const std::unique_ptr<RectInfo> &rectInfo);
|
|
EGL_S32 DrawRound(const std::unique_ptr<RoundInfo> &roundInfo);
|
|
EGL_S32 RefreshOnSrceen() const;
|
|
EGL_S32 CheckGLContext(std::shared_ptr<DrawCmd> &drawCmd);
|
|
|
|
void FBOManagerInit(EGL_U32 enable);
|
|
EGL_S32 OSDTextInit(EGL_U32 enable);
|
|
EGL_S32 OSDBlitInit(EGL_U32 enable);
|
|
EGL_S32 OSDBitmapInit(EGL_U32 enable);
|
|
EGL_S32 OSDFrameInit(EGL_U32 enable);
|
|
EGL_S32 OSDRectInit(EGL_U32 enable);
|
|
EGL_S32 OSDRoundInit(EGL_U32 enable);
|
|
|
|
std::unique_ptr<EGLManager> eglManager;
|
|
std::unique_ptr<FBOManager> fboManager;
|
|
std::unique_ptr<OSDText> osdText;
|
|
std::unique_ptr<OSDBlit> osdBlit;
|
|
std::unique_ptr<OSDBitmap> osdBitmap;
|
|
std::unique_ptr<OSDFrame> osdFrame;
|
|
std::unique_ptr<OSDRect> osdRect;
|
|
std::unique_ptr<OSDRound> osdRound;
|
|
std::unique_ptr<DolGLSemaphore> cmdSemaphore;
|
|
|
|
bool threadStop;
|
|
bool isSetupGLESConext;
|
|
EGL_S32 mResult;
|
|
EGL_U32 winWidth;
|
|
EGL_U32 winHeight;
|
|
std::queue<std::shared_ptr<DrawCmd>> drawQueue;
|
|
|
|
EGLNativeWindowType mNativeWindow;
|
|
EGL_U32 mEnable;
|
|
FboInfo mFboInfo;
|
|
FontLibInfo mFontLibInfo;
|
|
GLBitmapInfo mBitmapInfo;
|
|
mutex mMutex;
|
|
};
|
|
}; // namespace dolgles
|
|
|
|
#endif // end GL_DRAW_THREAD_H
|