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.
180 lines
6.5 KiB
180 lines
6.5 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2016-2019. All rights reserved.
|
|
* Description: bootvideo ui head file
|
|
*/
|
|
|
|
#ifndef BOOTVIDEOUI_H
|
|
#define BOOTVIDEOUI_H
|
|
|
|
#include <string>
|
|
#include <sys/types.h>
|
|
#include <utils/Thread.h>
|
|
#include <binder/IBinder.h>
|
|
|
|
#include <png.h>
|
|
#include <memory>
|
|
#include <DolGLDrawSurface.h>
|
|
#include <gui/SurfaceComposerClient.h>
|
|
#include <gui/SurfaceControl.h>
|
|
#include <gui/Surface.h>
|
|
|
|
#include "SurfaceUI.h"
|
|
|
|
|
|
namespace android {
|
|
class Surface;
|
|
class SurfaceComposerClient;
|
|
class SurfaceControl;
|
|
|
|
class BaseView : public RefBase {
|
|
public:
|
|
BaseView(unsigned int tempW, unsigned int tempH, unsigned int tempScale);
|
|
virtual ~BaseView();
|
|
virtual void InitView() = 0;
|
|
virtual void DrawView(std::unique_ptr<dolgles::DolGLDrawSurface> &gles) = 0;
|
|
static void FreePNG(dolgles::DolBitmapInfo &bitmapInfo);
|
|
static bool DecodePNG(dolgles::DolBitmapInfo &bitmapInfo, const std::string path);
|
|
protected:
|
|
const float CENTRE_PARAM = 0.5f; // centre param
|
|
static const unsigned short HEAD_BYTES = 8; // png file header size
|
|
static const unsigned short RGBA_BYTES = 4; // png file pixel size of RGBA
|
|
static const unsigned short PNG_MAX_PIXEL = 8192; // max support 8k
|
|
static const std::string VIEW_PNG_PATH;
|
|
unsigned short w;
|
|
unsigned short h;
|
|
unsigned short scale;
|
|
};
|
|
|
|
class MuteView : public BaseView {
|
|
public:
|
|
MuteView(unsigned int tempW, unsigned int tempH, unsigned int tempScale);
|
|
void InitView() override;
|
|
void DrawView(std::unique_ptr<dolgles::DolGLDrawSurface> &gles) override;
|
|
~MuteView() override;
|
|
void SetMuteInfo(const bool able, const bool mute);
|
|
protected:
|
|
static const unsigned int MUTE_PNG_MARGIN = 50; // png margin
|
|
static const std::string MUTE_PNG_NAME;
|
|
private:
|
|
bool isAble;
|
|
bool isMute;
|
|
dolgles::DolBitmapInfo bitmapInfo;
|
|
};
|
|
|
|
class VolumeBarView : public BaseView {
|
|
public:
|
|
VolumeBarView(unsigned int tempW, unsigned int tempH, unsigned int tempScale);
|
|
void InitView() override;
|
|
void DrawView(std::unique_ptr<dolgles::DolGLDrawSurface> &gles) override;
|
|
~VolumeBarView() override;
|
|
void SetVolumeInfo(const bool able, const int vol);
|
|
protected:
|
|
static const std::string VOLUME_PNG_NAME; // png path
|
|
static const unsigned short VOLUME_BG_HEIGHT = 92; // def volume height is 92
|
|
static const unsigned short VOLUME_BUF_SIZE = 10; // text buffer(bufW) max size
|
|
static const unsigned short VOLUME_PNG_MARGIN = 50; // png margin
|
|
static const unsigned short VOLUME_BAR_MARGIN = 2; // bar margin
|
|
static const unsigned short VOLUME_BAR_OFFSET = 5; // bar offset
|
|
static const unsigned short VOLUME_MAX_BYTES = 3; // volume max value is bytes
|
|
const float VOLUME_BG_WIDTH_MIX = 0.625; // bar width is 62.5% of screen width
|
|
const float VOLUME_TEXT_X_MIX = 0.9; // text x coord is 90% of view width
|
|
const float VOLUME_BAR_H_MIX = 0.333; // bar height is 1/3 of view height
|
|
const float VOLUME_BAR_W_MIX = 0.725; // bar width is 72.5% of view width
|
|
const float VOLUME_MAX_VALUE = 100; // volume max value is 100
|
|
private:
|
|
void SetVolumeBarW(unsigned int w);
|
|
void SetVolumeBarX(unsigned int x);
|
|
unsigned int GetVolumeBarW();
|
|
unsigned int GetVolumeBarX();
|
|
dolgles::DolColorRGBA fgColor; // volume bar and value color
|
|
dolgles::DolBitmapInfo bitmapBG; // background png
|
|
dolgles::DolTextInfo volumeText; // volume value text info
|
|
dolgles::DolRectInfo volumeRect; // volume value text rect
|
|
dolgles::DolRectInfo barRect; // volume bar rect
|
|
dolgles::DolRoundInfo barRoundL; // volume bar left round
|
|
dolgles::DolRoundInfo barRoundR; // volume bar right round
|
|
bool isAble;
|
|
unsigned int volumeValue;
|
|
unsigned int volumeBarW;
|
|
unsigned int volumeBarX;
|
|
unsigned short bufW[VOLUME_BUF_SIZE] = {0};
|
|
};
|
|
|
|
class CountDownView : public BaseView {
|
|
public:
|
|
CountDownView(unsigned int tempW, unsigned int tempH, unsigned int tempScale);
|
|
void InitView() override;
|
|
void DrawView(std::unique_ptr<dolgles::DolGLDrawSurface> &gles) override;
|
|
~CountDownView() override;
|
|
void SetRemainTime(int remain);
|
|
std::string GetTextPngPath();
|
|
protected:
|
|
static const std::string COUNTDOWN_BG_NAME;
|
|
static const std::string COUNTDOWN_CH_NAME;
|
|
static const std::string COUNTDOWN_EN_NAME;
|
|
static const unsigned short COUNTDOWN_BUF_SIZE = 10; // text buffer max size
|
|
static const unsigned short COUNTDOWN_VIEW_W = 250; // view width
|
|
static const unsigned short COUNTDOWN_VIEW_H = 50; // view height
|
|
static const unsigned short COUNTDOWN_TEXT_MARGIN = 20; // text png margin of time text
|
|
const float COUNTDOWN_TEXT_X_MIX = 0.7; // text png width is 70% of view width
|
|
private:
|
|
int remainTime; // remaining time
|
|
char bufN[COUNTDOWN_BUF_SIZE] = {0}; // buffer utf-8
|
|
unsigned short bufW[COUNTDOWN_BUF_SIZE] = {0}; // buffer utf-16
|
|
dolgles::DolBitmapInfo bitmapBG; // background png
|
|
dolgles::DolBitmapInfo bitmapText; // text png
|
|
dolgles::DolTextInfo textTime; // time text
|
|
dolgles::DolRectInfo rectTime; // time rect
|
|
};
|
|
|
|
class BootvideoUI : public Thread {
|
|
public:
|
|
BootvideoUI();
|
|
~BootvideoUI();
|
|
void Release();
|
|
void DrawCountDown();
|
|
void SetCountdownTime(int time) const;
|
|
void SetVolumeStatus(int needUI, int mute, int volume) const;
|
|
void SetUIFinish();
|
|
bool CheckExit() const;
|
|
bool CheckReady() const;
|
|
sp<IGraphicBufferProducer> GetSideBand() const;
|
|
private:
|
|
const int NATIVE_WINDOW_BUFFER_COUNT = 5; // the max dequeued buffer count
|
|
const int TEXT_FONT_SIZE = 32;
|
|
const std::string TEXT_FONT_PATH = "/system/fonts/CarroisGothicSC-Regular.ttf";
|
|
int GetDisplayOrientation() const;
|
|
void SetUIReady();
|
|
bool WaitSurfaceFlinger() const;
|
|
bool CreateSurface();
|
|
bool InitSurfacePlayer();
|
|
bool InitSurfaceUI();
|
|
void CheckViewRefresh(int waitDelayUs, bool isEnableMute, bool isEnableVolume, bool isEnableCountDown);
|
|
|
|
virtual status_t readyToRun();
|
|
virtual void onFirstRef();
|
|
virtual bool threadLoop();
|
|
|
|
bool isExitUI = false;
|
|
bool isGlesReady = false;
|
|
unsigned int surfaceW = 0;
|
|
unsigned int surfaceH = 0;
|
|
unsigned int surfaceScale = 2; // def 4k mode, scale is 2
|
|
std::unique_ptr<dolgles::DolGLDrawSurface> glesSurface;
|
|
|
|
#if PLATFORM_SDK_VERSION <= __ANDROID_API_Q__
|
|
sp<SurfaceQverUI> surface;
|
|
#else
|
|
sp<SurfaceSverUI> surface;
|
|
#endif
|
|
sp<Surface> surfacePlayer;
|
|
sp<Surface> surfaceUi;
|
|
|
|
// all view
|
|
sp<MuteView> muteView;
|
|
sp<VolumeBarView> volumeView;
|
|
sp<CountDownView> countView;
|
|
}; // class BootvideoUI
|
|
}; // namespace android
|
|
#endif
|