change some bitmapdrawable debug message

This commit is contained in:
侯歌 2024-05-11 21:40:01 +08:00
parent ad41f9cac3
commit 59c112a714
5 changed files with 41 additions and 21 deletions

View File

@ -371,7 +371,7 @@ RefPtr<ImageSurface>ImageSurface:: create_from_stream(std::istream& stream){
if(!stream.good())return nullptr;
for(int i=0;i<sizeof(head);i++)stream.unget();
if(memcmp("jpg",ftype,3)==0){
if( memcmp("jpg",ftype,3) == 0 ){
cairo_surface_t* cobject = nullptr;
#ifdef ENABLE_TURBOJPEG
cobject = cairo_image_surface_create_from_turbojpeg_stdstream(stream);
@ -380,13 +380,13 @@ RefPtr<ImageSurface>ImageSurface:: create_from_stream(std::istream& stream){
if(nullptr==cobject )cobject = cairo_image_surface_create_from_jpeg_stdstream(stream);
#endif
if(cobject) img = RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
}else if(memcmp("png",ftype,3)==0){
img=create_from_png(stream_read,&stream);
}else if( memcmp("png",ftype,3) == 0 ){
img = create_from_png(stream_read,&stream);
}/*else if(memcmp("bmp",ftype,3)==0){
Bitmap bmp;;
bmp.ReadFromStream(stream);
img=(RefPtr<ImageSurface>)bmp;
}*/else if(memcmp("svg",ftype,3)==0){
}*/else if( memcmp("svg",ftype,3) == 0 ){
#ifdef ENABLE_CAIROSVG
svg_cairo_t *svg;
unsigned int width,height;
@ -399,16 +399,16 @@ RefPtr<ImageSurface>ImageSurface:: create_from_stream(std::istream& stream){
}
svg_cairo_parse_chunk_end(svg);
svg_cairo_get_size(svg,&width,&height);
LOGD("svg.viewport=%dx%d",width,height);
if(width>0&&height>0){
img=ImageSurface::create(Surface::Format::ARGB32,width,height);
RefPtr<Context>ctx=Context::create(img);
LOGD("svg.viewport = %dx%d",width,height);
if( (width > 0) && ( height > 0) ){
img = ImageSurface::create(Surface::Format::ARGB32,width,height);
RefPtr<Context>ctx = Context::create(img);
svg_cairo_render(svg,(cairo_t*)ctx->cobj());
}
svg_cairo_destroy(svg);
#endif
}
t2=steady_clock::now();
t2 = steady_clock::now();
LOGV_IF(img.get(),"img.size=%dx%d used %.5f stype=%s",img->get_width(),img->get_height(),duration_cast<duration<double>>(t2 - t1),ftype);
return img;
}

View File

@ -92,13 +92,10 @@ BitmapDrawable::BitmapDrawable(Context*ctx,const std::string&resname)
DisplayMetrics dm = ctx->getDisplayMetrics();
const size_t fullScreenSize=dm.widthPixels*dm.heightPixels;
const size_t bitmapSize = b->get_width()*b->get_height();
char mime[32] = {0};
size_t len = 0;
b->get_mime_data(mime,len);
LOGD_IF( ( (mBitmapState->mTransparency!=PixelFormat::OPAQUE)&&(bitmapSize>=fullScreenSize/4) )
|| (b->get_stride()<b->get_width()*4),
"is %-12s bpp:%d %s/%d '%s' maby cause compose more slowly" , tNames[mBitmapState->mTransparency],
b->get_stride()/b->get_width(), mime,len,mBitmapState->mResource.c_str());
LOGI_IF( ( (mBitmapState->mTransparency!=PixelFormat::OPAQUE) && (bitmapSize>=fullScreenSize/4) )
|| (b->get_stride()<b->get_width()*4||(b->get_format()!=Cairo::Surface::Format::ARGB32)),
"is %-12s %d*%d*%d format=%d '%s' maby cause compose more slowly" , tNames[mBitmapState->mTransparency],
b->get_width(),b->get_height(),b->get_stride()/b->get_width(),b->get_format(),mBitmapState->mResource.c_str());
#endif
}

View File

@ -76,14 +76,37 @@ static void make_jpeg_stream (j_decompress_ptr cinfo, std::istream* in) {
src->pub.next_input_byte = NULL; /* until buffer loaded */
}
#ifndef LIBJPEG_TURBO_VERSION
static void pix_conv(unsigned char *dst, int dw, const unsigned char *src, int sw, int num) {
int si, di;
// safety check
if (dw < 3 || sw < 3 || dst == NULL || src == NULL)
return;
num--;
for (si = num * sw, di = num * dw; si >= 0; si -= sw, di -= dw) {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
dst[di + 2] = src[si ];
dst[di + 1] = src[si + 1];
dst[di + 0] = src[si + 2];
#else
// FIXME: This is untested, it may be wrong.
dst[di - 3] = src[si - 3];
dst[di - 2] = src[si - 2];
dst[di - 1] = src[si - 1];
#endif
}
}
#endif
static int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
// 定义一个函数,将小数转换为最简分数形式
static void decimalToFraction(double decimal,int& scale_num,int& scale_denom) {
const int precision = 1000000; // 精度,可以根据需要调整
const int precision = 1000000;
const int numerator = decimal * precision;
const int denominator = precision;
const int commonDivisor = gcd(numerator, denominator);

View File

@ -24,7 +24,7 @@ static void* X11EventProc(void*p);
static GFXRect screenMargin= {0}; //{60,0,60,0};
#define SENDKEY(k,down) {InjectKey(EV_KEY,k,down);}
#if 0
#if 1
#define SENDMOUSE(time,x,y) {\
InjectABS(time,EV_ABS,ABS_MT_TRACKING_ID,12);\
InjectABS(time,EV_ABS,ABS_MT_POSITION_X,x);\

View File

@ -129,12 +129,12 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo) {
strcpy(devinfo->name,"Touch-Inject");
devinfo->vendor = INJECTDEV_TOUCH>>16;
devinfo->product= INJECTDEV_TOUCH&0xFF;
#if 0//case to make injectdevice as single touch
#if 0 //case to make injectdevice as single touch
SET_BIT(devinfo->keyBitMask,BTN_TOUCH);
SET_BIT(devinfo->absBitMask,ABS_X);
SET_BIT(devinfo->absBitMask,ABS_Y);
#else
//SET_BIT(devinfo->keyBitMask,BTN_TOUCH);
SET_BIT(devinfo->keyBitMask,BTN_TOUCH);
SET_BIT(devinfo->absBitMask,ABS_MT_POSITION_X);
SET_BIT(devinfo->absBitMask,ABS_MT_POSITION_Y);
#endif