mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 19:27:49 +08:00
add App argument extantion support
This commit is contained in:
parent
dc28649071
commit
c5a135371b
@ -36,7 +36,7 @@ static CLA::Argument ARGS[]={
|
||||
{CLA::EntryType::Switch, "", "fps" , "Show FPS ",CLA::ValueType::None, (int)CLA::EntryFlags::Optional}
|
||||
};
|
||||
|
||||
App::App(int argc,const char*argv[],const struct option*extoptions){
|
||||
App::App(int argc,const char*argv[],const std::vector<CLA::Argument>&extoptions){
|
||||
int option_index=-1,c=-1;
|
||||
std::string optstring;
|
||||
Choreographer&chograph= Choreographer::getInstance();
|
||||
@ -50,6 +50,7 @@ App::App(int argc,const char*argv[],const struct option*extoptions){
|
||||
}
|
||||
LOGD("App %s started",(argc&&argv)?argv[0]:"");
|
||||
cla.addArguments(ARGS,sizeof(ARGS)/sizeof(CLA::Argument));
|
||||
cla.addArguments(extoptions.data(),extoptions.size());
|
||||
cla.setSwitchChars("-");
|
||||
cla.parse(argc,argv);
|
||||
if(hasSwitch("debug")){
|
||||
|
@ -21,14 +21,13 @@ protected:
|
||||
CLA cla;
|
||||
static App*mInst;
|
||||
public:
|
||||
App(int argc=0,const char*argv[]=NULL,const option*extoptions=NULL);
|
||||
App(int argc=0,const char*argv[]=NULL,const std::vector<CLA::Argument>&extoptions={});
|
||||
~App();
|
||||
static App&getInstance();
|
||||
const std::string getDataPath()const;
|
||||
virtual void setOpacity(unsigned char alpha);
|
||||
virtual void setName(const std::string&appname);
|
||||
virtual const std::string&getName();
|
||||
|
||||
void setArg(const std::string&key,const std::string&value);
|
||||
bool hasArg(const std::string&key)const;
|
||||
bool hasSwitch(const std::string&key)const;
|
||||
|
@ -6,116 +6,115 @@
|
||||
namespace cdroid{
|
||||
|
||||
|
||||
class CLA{
|
||||
public:
|
||||
// Types of arguments
|
||||
enum class EntryType{
|
||||
Switch,
|
||||
Option,
|
||||
Parameter,
|
||||
UsageText,
|
||||
None
|
||||
};
|
||||
class CLA{
|
||||
public:
|
||||
// Types of arguments
|
||||
enum class EntryType{
|
||||
Switch,
|
||||
Option,
|
||||
Parameter,
|
||||
UsageText,
|
||||
None
|
||||
};
|
||||
|
||||
// Types of values for options and parameters
|
||||
enum class ValueType{
|
||||
Int,
|
||||
Float,
|
||||
Double,
|
||||
String,
|
||||
Bool,
|
||||
None
|
||||
};
|
||||
// Types of values for options and parameters
|
||||
enum class ValueType{
|
||||
Int,
|
||||
Float,
|
||||
Double,
|
||||
String,
|
||||
Bool,
|
||||
None
|
||||
};
|
||||
|
||||
enum class EntryFlags{
|
||||
None = 0,
|
||||
Optional = 1 << 1,
|
||||
Manditory = 1 << 2,
|
||||
Multiple = 1 << 3,
|
||||
Help = 1 << 4,
|
||||
Negatable = 1 << 5
|
||||
};
|
||||
// Describes an argument to look for
|
||||
struct Argument{
|
||||
EntryType mEntryType;
|
||||
const std::string mShortName;
|
||||
const std::string mLongName;
|
||||
const std::string mDescription;
|
||||
ValueType mValueType;
|
||||
int mEntryFlags;
|
||||
Argument(EntryType, const std::string &shortName, const std::string &longName,
|
||||
enum class EntryFlags{
|
||||
None = 0,
|
||||
Optional = 1 << 1,
|
||||
Manditory = 1 << 2,
|
||||
Multiple = 1 << 3,
|
||||
Help = 1 << 4,
|
||||
Negatable = 1 << 5
|
||||
};
|
||||
// Describes an argument to look for
|
||||
struct Argument{
|
||||
EntryType mEntryType;
|
||||
const std::string mShortName;
|
||||
const std::string mLongName;
|
||||
const std::string mDescription;
|
||||
ValueType mValueType;
|
||||
int mEntryFlags;
|
||||
Argument(EntryType, const std::string &shortName, const std::string &longName,
|
||||
const std::string &des,ValueType valueType, int entryFlags);
|
||||
};
|
||||
};
|
||||
enum Result{
|
||||
OK,
|
||||
Help,
|
||||
ErrorUnkown,
|
||||
ErrorNullArgument,
|
||||
ErrorArgCount,
|
||||
ErrorMissingArg,
|
||||
ErrorTooManyParams,
|
||||
None
|
||||
};
|
||||
public:
|
||||
CLA();
|
||||
CLA(const Argument *arguments, size_t argumentCount);
|
||||
CLA(const std::vector<Argument>& arguments);
|
||||
~CLA();
|
||||
Result parse(int argc, const char **argv);
|
||||
int addArguments(const std::vector<Argument>& arguments);
|
||||
int addArguments(const Argument *arguments, size_t argumentCount);
|
||||
bool setArgument(const std::string&arg,const std::string&value);
|
||||
void setSwitchChars(const std::string &switchChars);
|
||||
void setSwitchChars(char c);
|
||||
|
||||
enum Result{
|
||||
OK,
|
||||
Help,
|
||||
ErrorUnkown,
|
||||
ErrorNullArgument,
|
||||
ErrorArgCount,
|
||||
ErrorMissingArg,
|
||||
ErrorTooManyParams,
|
||||
None
|
||||
};
|
||||
public:
|
||||
CLA();
|
||||
CLA(const Argument *arguments, size_t argumentCount);
|
||||
CLA(const std::vector<Argument>& arguments);
|
||||
~CLA();
|
||||
Result parse(int argc, const char **argv);
|
||||
int addArguments(const std::vector<Argument>& arguments);
|
||||
int addArguments(const Argument *arguments, size_t argumentCount);
|
||||
bool setArgument(const std::string&arg,const std::string&value);
|
||||
void setSwitchChars(const std::string &switchChars);
|
||||
void setSwitchChars(char c);
|
||||
bool findSwitch(const std::string &argument) const;
|
||||
bool find(const std::string&)const;
|
||||
bool find(const std::string &argument, std::string &value) const;
|
||||
bool find(const std::string &argument, bool &value) const;
|
||||
bool find(const std::string &argument, int &value) const;
|
||||
bool find(const std::string &argument, unsigned &value) const;
|
||||
bool find(const std::string &argument, float &value) const;
|
||||
bool find(const std::string &argument, double &value) const;
|
||||
bool find(const std::string &argument, char &value) const;
|
||||
bool find(const std::string &argument, unsigned char &value) const;
|
||||
|
||||
bool findSwitch(const std::string &argument) const;
|
||||
bool find(const std::string&)const;
|
||||
bool find(const std::string &argument, std::string &value) const;
|
||||
bool find(const std::string &argument, bool &value) const;
|
||||
bool find(const std::string &argument, int &value) const;
|
||||
bool find(const std::string &argument, unsigned &value) const;
|
||||
bool find(const std::string &argument, float &value) const;
|
||||
bool find(const std::string &argument, double &value) const;
|
||||
bool find(const std::string &argument, char &value) const;
|
||||
bool find(const std::string &argument, unsigned char &value) const;
|
||||
size_t getParamCount() const;
|
||||
Result getParam(size_t paramIndex, std::string &destination) const;
|
||||
const std::string &getError() const { return mError; };
|
||||
const std::string &getUsageString();
|
||||
|
||||
size_t getParamCount() const;
|
||||
Result getParam(size_t paramIndex, std::string &destination) const;
|
||||
const std::string &getError() const { return mError; };
|
||||
const std::string &getUsageString();
|
||||
private:
|
||||
const std::string* _getArgumentValue(const std::string& argName) const;
|
||||
std::string _getLongArgName(const std::string& argName) const;
|
||||
std::string _getShortArgName(const std::string& argName) const;
|
||||
|
||||
private:
|
||||
const std::string* _getArgumentValue(const std::string& argName) const;
|
||||
std::string _getLongArgName(const std::string& argName) const;
|
||||
std::string _getShortArgName(const std::string& argName) const;
|
||||
// Generates usage based off of given values
|
||||
void _generateUsageString();
|
||||
|
||||
// Generates usage based off of given values
|
||||
void _generateUsageString();
|
||||
// Arguments stored by their option
|
||||
typedef std::unordered_map<std::string, std::string> ArgumentMap;
|
||||
ArgumentMap mArgumentValues;
|
||||
|
||||
// Arguments stored by their option
|
||||
typedef std::unordered_map<std::string, std::string> ArgumentMap;
|
||||
ArgumentMap mArgumentValues;
|
||||
// Switches found
|
||||
std::vector<std::string> mSwitches;
|
||||
|
||||
// Switches found
|
||||
std::vector<std::string> mSwitches;
|
||||
// Parameters found
|
||||
std::vector<std::string> mParameters;
|
||||
|
||||
// Parameters found
|
||||
std::vector<std::string> mParameters;
|
||||
std::vector<Argument> mArguments;
|
||||
|
||||
std::vector<Argument> mArguments;
|
||||
// Error string if any occur
|
||||
mutable std::string mError;
|
||||
|
||||
// Error string if any occur
|
||||
mutable std::string mError;
|
||||
// Characters that are used as switches
|
||||
std::string mSwitchChars;
|
||||
|
||||
// Characters that are used as switches
|
||||
std::string mSwitchChars;
|
||||
|
||||
// Use string displayed if queried
|
||||
std::string mUsageString;
|
||||
// Use string displayed if queried
|
||||
std::string mUsageString;
|
||||
|
||||
// Name of application
|
||||
std::string mApplicationName;
|
||||
};
|
||||
// Name of application
|
||||
std::string mApplicationName;
|
||||
};
|
||||
|
||||
} //endof namespace
|
||||
|
@ -35,7 +35,7 @@ typedef struct {
|
||||
size_t msize;
|
||||
char*buffer;//drawbuffer
|
||||
char*orig_buffer;//used only in double buffer*/
|
||||
char*kbuffer;/*kernel buffer address*/
|
||||
MI_PHY kbuffer;/*kernel buffer address*/
|
||||
} FBSURFACE;
|
||||
|
||||
static FBDEVICE devs[2]= {-1};
|
||||
@ -246,9 +246,11 @@ INT GFXCreateSurface(int dispid,HANDLE*surface,UINT width,UINT height,INT format
|
||||
#if DOUBLE_BUFFER
|
||||
surf->msize*=2;
|
||||
#endif
|
||||
surf->buffer=mmap(dev->fix.smem_start,surf->msize,PROT_READ | PROT_WRITE, MAP_SHARED,dev->fb, 0);
|
||||
surf->buffer=mmap(0/*dev->fix.smem_start*/,surf->msize,PROT_READ | PROT_WRITE, MAP_SHARED,dev->fb, 0);
|
||||
//MI_SYS_MMA_Alloc(NULL/*"mma_heap_name0"*/,surf->msize,&phaddr);
|
||||
//ret=MI_SYS_Mmap(phaddr,surf->msize, (void**)&surf->buffer, FALSE);
|
||||
dev->var.yoffset=0;
|
||||
LOGI("ioctl offset(0)=%d dev=%p",ioctl(dev->fb,FBIOPAN_DISPLAY,&dev->var),dev);
|
||||
LOGI("ioctl offset(0)=%d dev=%p ret=%d",ioctl(dev->fb,FBIOPAN_DISPLAY,&dev->var),dev,ret);
|
||||
#if DOUBLE_BUFFER
|
||||
dev->var.yoffset=1280;
|
||||
LOGI("ioctl offset(0)=%d dev=%p",ioctl(dev->fb,FBIOPAN_DISPLAY,&dev->var),dev);
|
||||
@ -257,19 +259,20 @@ INT GFXCreateSurface(int dispid,HANDLE*surface,UINT width,UINT height,INT format
|
||||
} else {
|
||||
int i=0;
|
||||
char name[32];
|
||||
sprintf(name,"surf_%p",surf);
|
||||
//while((i++<3)&&(phaddr==dev->fix.smem_start)){
|
||||
ret=MI_SYS_MMA_Alloc("mma_heap_name0",surf->msize,&phaddr);
|
||||
ret=MI_SYS_MMA_Alloc(NULL/*"mma_heap_name0"*/,surf->msize,&phaddr);
|
||||
//}
|
||||
LOGI("surface %p phyaddr=%x ret=%d",surf,phaddr,ret);
|
||||
MI_SYS_Mmap(phaddr, surf->msize, (void**)&surf->buffer, FALSE);
|
||||
}
|
||||
surf->kbuffer=(char*)phaddr;
|
||||
surf->kbuffer = phaddr;
|
||||
MI_SYS_MemsetPa(phaddr,0x000000,surf->msize);
|
||||
surf->orig_buffer=surf->buffer;
|
||||
if(hwsurface) setfbinfo(surf);
|
||||
surf->ishw=hwsurface;
|
||||
surf->alpha=255;
|
||||
LOGI("Surface=%p buf=%p/%p size=%dx%d/%d hw=%d\r\n",surf,surf->buffer,surf->kbuffer,surf->width,surf->height,surf->msize,hwsurface);
|
||||
LOGI("Surface=%p buf=%p/%llx/%llu size=%dx%d/%d hw=%d\r\n",surf,surf->buffer,phaddr,surf->kbuffer,surf->width,surf->height,surf->msize,hwsurface);
|
||||
*surface=surf;
|
||||
return E_OK;
|
||||
}
|
||||
@ -292,7 +295,6 @@ INT GFXBlit(HANDLE dstsurface,int dx,int dy,HANDLE srcsurface,const GFXRect*srcr
|
||||
rs.h=nsrc->height;
|
||||
if(srcrect)rs=*srcrect;
|
||||
LOGD_IF(ndst!=primarySurface&&ndst->ishw,"dst is not primarySurface");
|
||||
ndst = primarySurface;
|
||||
|
||||
toMIGFX(nsrc,&gfxsrc);
|
||||
toMIGFX(ndst,&gfxdst);
|
||||
@ -341,8 +343,7 @@ INT GFXDestroySurface(HANDLE surface) {
|
||||
LOGI("GFXDestroySurface %p/%p",surf,surf->buffer);
|
||||
if(surf->kbuffer) {
|
||||
MI_SYS_Munmap(surf->buffer,surf->msize);
|
||||
if(surf->ishw==0)
|
||||
MI_SYS_MMA_Free((MI_PHY)surf->kbuffer);
|
||||
MI_SYS_MMA_Free((MI_PHY)surf->kbuffer);
|
||||
} else if(surf->buffer) {
|
||||
free(surf->buffer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user