mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-29 18:59:14 +08:00
add functions check
This commit is contained in:
parent
b48b2da3bb
commit
796682dfff
@ -132,10 +132,6 @@ if(ENABLE_PINYIN2HZ)
|
||||
list(APPEND CDROID_DEPINCLUDES ${CMAKE_SOURCE_DIR}/src/3rdparty/pinyin/include)
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/src/gui/gui_features.h.cmake")
|
||||
configure_file(src/gui/gui_features.h.cmake ${CMAKE_BINARY_DIR}/include/gui/gui_features.h)
|
||||
configure_file(src/gui/gui_features.h.cmake ${CMAKE_SOURCE_DIR}/src/gui/gui_features.h)
|
||||
endif()
|
||||
set(SKIP_INSTALL_EXPORT TRUE)
|
||||
|
||||
if(NOT VCPKG_TARGET_TRIPLET)
|
||||
|
@ -34,7 +34,9 @@ include_directories(
|
||||
${CDROID_DEPINCLUDES}
|
||||
${LIBUNIBREAK_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#message(FATAL_ERROR "VERSION=${VERSION}")
|
||||
set(CDROID_VERSION 1.2)
|
||||
set(CDROID_VERSION_MAJOR 1)
|
||||
add_definitions(--include cdtypes.h)
|
||||
add_definitions(--include cdlog.h)
|
||||
add_definitions(--include stdpatch.h)
|
||||
@ -82,6 +84,11 @@ foreach( each_file ${filtered_files} )
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/${each_file} DESTINATION "${CMAKE_BINARY_DIR}/include/gui/${FILE_PATH}")
|
||||
endforeach(each_file)
|
||||
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(mallinfo2 HAVE_MALLINFO2)
|
||||
check_function_exists(mallinfo HAVE_MALLINFO)
|
||||
|
||||
configure_file(gui_features.h.cmake ${PROJECT_BINARY_DIR}/gui_features.h)
|
||||
configure_file("cdroid.pc.in" "cdroid.pc" @ONLY)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cdroid.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <sys/resource.h>
|
||||
#include <malloc.h>
|
||||
#include <fstream>
|
||||
#include <gui_features.h>
|
||||
|
||||
using namespace Cairo;
|
||||
|
||||
namespace cdroid{
|
||||
@ -23,8 +25,8 @@ namespace cdroid{
|
||||
GraphDevice*GraphDevice::mInst = nullptr;
|
||||
|
||||
GraphDevice&GraphDevice::GraphDevice::getInstance(){
|
||||
if(nullptr==mInst)
|
||||
mInst=new GraphDevice();
|
||||
if(nullptr == mInst)
|
||||
mInst = new GraphDevice();
|
||||
return *mInst;
|
||||
}
|
||||
|
||||
@ -156,9 +158,6 @@ void GraphDevice::invalidate(const Rect&r){
|
||||
LOGV("(%d,%d,%d,%d)",r.left,r.top,r.width,r.height);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
/*make gcc happy for mallinfo()*/
|
||||
void GraphDevice::trackFPS(Canvas& canvas) {
|
||||
// Tracks frames per second drawn. First value in a series of draws may be bogus
|
||||
// because it down not account for the intervening idle time
|
||||
@ -174,10 +173,17 @@ void GraphDevice::trackFPS(Canvas& canvas) {
|
||||
if (totalTime > 1000) {
|
||||
char buffer[64];
|
||||
const float fps = (float) mFpsNumFrames * 1000 / totalTime;
|
||||
#if HAVE_MALLINFO2
|
||||
struct mallinfo2 mi = mallinfo2();
|
||||
sprintf(buffer,"%.2ffps,%ldK",fps,long(mi.uordblks>>10));
|
||||
#elif HAVE_MALLINFO
|
||||
struct mallinfo mi = mallinfo();
|
||||
sprintf(buffer,"%.2ffps,%ldK",fps,long(mi.uordblks>>10));
|
||||
#else
|
||||
sprintf(buffer,"%.2ffps",fps);
|
||||
#endif
|
||||
mFpsStartTime = nowTime;
|
||||
mFpsNumFrames = 0;
|
||||
sprintf(buffer,"%.2ffps,%ldK",fps,long(mi.uordblks>>10));
|
||||
mFPSText = buffer;
|
||||
}
|
||||
}
|
||||
@ -191,7 +197,6 @@ void GraphDevice::trackFPS(Canvas& canvas) {
|
||||
canvas.draw_text(mRectBanner,mFPSText,Gravity::CENTER);
|
||||
canvas.restore();
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void GraphDevice::getScreenSize(int &w,int&h)const{
|
||||
w = mScreenWidth;
|
||||
|
@ -1,14 +0,0 @@
|
||||
/*gui_features.h.cmake Generated from configure.ac by autoheader.*/
|
||||
#define ENABLE_GIF 1
|
||||
/* #undef ENABLE_JPEG */
|
||||
#define ENABLE_WEBP 1
|
||||
/* #undef ENABLE_TURBOJPEG */
|
||||
#define ENABLE_MBEDTLS 1
|
||||
/* #undef ENABLE_UPNP */
|
||||
/* #undef ENABLE_GESTURE */
|
||||
/* #undef ENABLE_MP3ID3 */
|
||||
#define ENABLE_FRIBIDI 1
|
||||
#define ENABLE_PINYIN2HZ 1
|
||||
/* #undef ENABLE_PLPLOT */
|
||||
/* #undef ENABLE_BARCODE */
|
||||
/* #undef ENABLE_LITEHTML */
|
@ -13,5 +13,9 @@
|
||||
#cmakedefine ENABLE_BARCODE 1
|
||||
#cmakedefine ENABLE_LITEHTML 1
|
||||
|
||||
|
||||
#cmakedefine HAVE_MALLINFO 1
|
||||
#cmakedefine HAVE_MALLINFO2 1
|
||||
|
||||
#define CDROID_VERSION "@CDROID_VERSION@"
|
||||
#define CDROID_VERSION_MAJOR "@CDROID_VERSION_MAJOR@"
|
||||
|
@ -29,51 +29,52 @@ FORMAT formats[]={
|
||||
};
|
||||
|
||||
class GRAPH:public testing::Test{
|
||||
public :
|
||||
static void SetUpTestCase(){
|
||||
GFXInit();
|
||||
for(int f=GPF_ARGB4444;f<=GPF_ABGR;f++){
|
||||
printf("format %d whitepixel=%x\r\n",f,Color2Pixel(f,0xFFFFFFFF));
|
||||
printf("format %d whitealphapixel=%x\r\n",f,Color2Pixel(f,0x00FFFFFF));
|
||||
}
|
||||
}
|
||||
static void TearDownTestCase(){
|
||||
sleep(20);
|
||||
}
|
||||
virtual void SetUp(){
|
||||
}
|
||||
static UINT Color2Pixel(INT fmt,UINT color){
|
||||
FORMAT*f=formats+fmt;
|
||||
BYTE a,r,g,b;
|
||||
UINT pixel;
|
||||
a=color>>24;
|
||||
r=color>>16;
|
||||
g=color>>8;
|
||||
b=color;
|
||||
pixel=((a&f->amask)<<f->ashift)|((r&f->rmask)<<f->rshift)|((g&f->gmask)<<f->gshift)|((b&f->bmask)<<f->bshift);
|
||||
return pixel;
|
||||
}
|
||||
virtual void TearDown(){
|
||||
}
|
||||
unsigned long long gettime(){
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
return tv.tv_sec*1000+tv.tv_usec/1000;
|
||||
}
|
||||
unsigned int getPixel(HANDLE surface,int x,int y){
|
||||
//for pixel(x,y)out of surface,we return INVALID_COLOR
|
||||
BYTE*buffer;
|
||||
UINT w,h,f,pitch;
|
||||
GFXLockSurface(surface,(void**)&buffer,&pitch);
|
||||
GFXGetSurfaceInfo(surface,&w,&h,(int*)&f);
|
||||
if(x<0||y<0||x>=w||y>=h)return INVALID_COLOR;
|
||||
buffer+=pitch*y;
|
||||
switch(f){
|
||||
case GPF_ARGB4444:
|
||||
case GPF_ARGB1555:return *(USHORT*)(buffer+2*x);
|
||||
case GPF_ARGB:
|
||||
case GPF_ABGR:
|
||||
case GPF_RGB32:return *(UINT*)(buffer+4*x);
|
||||
public :
|
||||
static void SetUpTestCase(){
|
||||
GFXInit();
|
||||
for(int f=GPF_ARGB4444;f<=GPF_ABGR;f++){
|
||||
printf("format %d whitepixel=%x\r\n",f,Color2Pixel(f,0xFFFFFFFF));
|
||||
printf("format %d whitealphapixel=%x\r\n",f,Color2Pixel(f,0x00FFFFFF));
|
||||
}
|
||||
}
|
||||
static void TearDownTestCase(){
|
||||
sleep(20);
|
||||
}
|
||||
virtual void SetUp(){
|
||||
}
|
||||
static UINT Color2Pixel(INT fmt,UINT color){
|
||||
FORMAT*f = formats+fmt;
|
||||
BYTE a,r,g,b;
|
||||
UINT pixel;
|
||||
a = color>>24;
|
||||
r = color>>16;
|
||||
g = color>>8;
|
||||
b = color;
|
||||
pixel = ((a&f->amask)<<f->ashift)|((r&f->rmask)<<f->rshift)|((g&f->gmask)<<f->gshift)|((b&f->bmask)<<f->bshift);
|
||||
return pixel;
|
||||
}
|
||||
virtual void TearDown(){
|
||||
}
|
||||
unsigned long long gettime(){
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
return tv.tv_sec*1000+tv.tv_usec/1000;
|
||||
}
|
||||
unsigned int getPixel(HANDLE surface,int x,int y){
|
||||
//for pixel(x,y)out of surface,we return INVALID_COLOR
|
||||
BYTE*buffer;
|
||||
UINT w,h,f,pitch;
|
||||
GFXLockSurface(surface,(void**)&buffer,&pitch);
|
||||
GFXGetSurfaceInfo(surface,&w,&h,(int*)&f);
|
||||
if(x<0||y<0||x>=w||y>=h)return INVALID_COLOR;
|
||||
buffer+=pitch*y;
|
||||
switch(f){
|
||||
case GPF_ARGB4444:
|
||||
case GPF_ARGB1555:return *(USHORT*)(buffer+2*x);
|
||||
case GPF_ARGB:
|
||||
case GPF_ABGR:
|
||||
case GPF_RGB32:return *(UINT*)(buffer+4*x);
|
||||
default:return 0xCCCCCCCC;
|
||||
}
|
||||
}
|
||||
BOOL errorPixel(HANDLE surface,int x,int y,UINT color){
|
||||
|
Loading…
Reference in New Issue
Block a user