From 5dc819f7b87373d813e08c1aab40455d80214244 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 15 Jan 2015 05:51:37 +0000 Subject: [PATCH] Fplay: use pixlib3 for renderig. git-svn-id: svn://kolibrios.org@5372 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/media/fplay/Makefile | 2 +- contrib/media/fplay/fplay.h | 8 +- contrib/media/fplay/utils.c | 8 +- contrib/media/fplay/video.c | 146 +++++++++++++-------------- contrib/media/fplay/winlib/button.c | 42 +++----- contrib/media/fplay/winlib/caption.c | 51 +++------- contrib/media/fplay/winlib/control.h | 9 +- contrib/media/fplay/winlib/fontlib.c | 12 +-- contrib/media/fplay/winlib/frame.c | 6 ++ contrib/media/fplay/winlib/panel.c | 63 ++++-------- contrib/media/fplay/winlib/window.c | 38 ++----- contrib/media/fplay/winlib/winlib.h | 8 +- 12 files changed, 156 insertions(+), 237 deletions(-) diff --git a/contrib/media/fplay/Makefile b/contrib/media/fplay/Makefile index 8b864622ff..5d90f34ddc 100644 --- a/contrib/media/fplay/Makefile +++ b/contrib/media/fplay/Makefile @@ -19,7 +19,7 @@ LIB_DIR:= $(SDK_DIR)/lib INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/ffmpeg -I$(SDK_DIR)/sources/freetype/include LIBS:= -lavdevice.dll -lavformat.dll -lavcodec.dll -lavutil.dll -lswscale.dll -LIBS+= -lswresample.dll -lsound -lpixlib.dll -lfreetype.dll -lgcc -lc.dll -lapp +LIBS+= -lswresample.dll -lsound -lpixlib3 -lfreetype.dll -lgcc -lc.dll -lapp LIBPATH:= -L$(LIB_DIR) -L/home/autobuild/tools/win32/mingw32/lib diff --git a/contrib/media/fplay/fplay.h b/contrib/media/fplay/fplay.h index b60e52bdf2..ffb262dff2 100644 --- a/contrib/media/fplay/fplay.h +++ b/contrib/media/fplay/fplay.h @@ -1,5 +1,5 @@ -#include "pixlib2.h" +#include "pixlib3.h" #define BLACK_MAGIC_SOUND #define BLACK_MAGIC_VIDEO @@ -30,7 +30,7 @@ struct render rect_t rcbottom; uint32_t layout; - bitmap_t bitmap[4]; + bitmap_t *bitmap[4]; bitmap_t *last_bitmap; uint32_t ctx_format; @@ -135,9 +135,7 @@ static inline void GetNotify(void *event) } - int init_fontlib(); -int draw_text(bitmap_t *winbitmap, int face, char *text, int x, int y, int color); -int draw_text_ext(bitmap_t *winbitmap, int face, char *text, rect_t *rc, int color); +//int draw_text_ext(void *pixmap, uint32_t pitch, FT_Face face, char *text, rect_t *rc, int color); char *get_moviefile(); diff --git a/contrib/media/fplay/utils.c b/contrib/media/fplay/utils.c index b6c820793b..bb3f827c68 100644 --- a/contrib/media/fplay/utils.c +++ b/contrib/media/fplay/utils.c @@ -100,18 +100,18 @@ int get_packet(queue_t *q, AVPacket *pkt) void blit_raw(ctx_t *ctx, void *raw, int x, int y, int w, int h, int pitch) { - int *dst = (int*)ctx->pixmap->data; + int *dst; int *src = raw; int i, j; - dst+= y * ctx->pixmap->pitch/4 + x; - + dst = ctx->pixmap_data; + dst+= y * ctx->pixmap_pitch/4 + x; for(i=0; i < h; i++) { for(j = 0; j < w; j++) dst[j] = src[j]; - dst+= ctx->pixmap->pitch/4; + dst+= ctx->pixmap_pitch/4; src+= pitch/4; }; }; diff --git a/contrib/media/fplay/video.c b/contrib/media/fplay/video.c index d7ddb908e6..f8c58e8542 100644 --- a/contrib/media/fplay/video.c +++ b/contrib/media/fplay/video.c @@ -184,8 +184,6 @@ extern volatile enum player_state player_state; extern volatile enum player_state decoder_state; extern volatile enum player_state sound_state; -//rect_t win_rect; - extern int64_t rewind_pos; static void player_stop() @@ -219,7 +217,6 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) switch(msg) { case MSG_SIZE: - //printf("MSG_SIZE\n"); if(main_render) { render_adjust_size(main_render, win); @@ -268,10 +265,10 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) win->win_state = win->saved_state; window_update_layout(win); // if(win->saved_state == MAXIMIZED) - { - blit_caption(&win->caption); - blit_panel(&win->panel); - } +// { +// blit_caption(&win->caption); +// blit_panel(&win->panel); +// } } ent_down = 1; }; @@ -567,6 +564,9 @@ int video_thread(void *param) AVCodecContext *ctx = param; window_t *MainWindow; + + printf("%s\n", __FUNCTION__); + init_winlib(); MainWindow = create_window(movie_file,0, @@ -622,14 +622,14 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) render->ctx_format = ctx->pix_fmt; mutex_lock(&driver_lock); - render->caps = init_pixlib(flags); + render->caps = pxInit(1); mutex_unlock(&driver_lock); right = win->w; bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; - // printf("window width %d height %d\n", - // right, bottom); + printf("window width %d height %d\n", + right, bottom); render->win_state = win->win_state; @@ -653,13 +653,12 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) render_set_size(render, draw_w, draw_h); + pxCreateClient(0, CAPTION_HEIGHT, right, bottom); if(render->caps==0) { - render->bitmap[0].width = draw_w; - render->bitmap[0].height = draw_h; - - if( create_bitmap(&render->bitmap[0]) != 0 ) + render->bitmap[0] = pxCreateBitmap(draw_w, draw_h); + if(render->bitmap[0] == NULL) { free(render); return NULL; @@ -668,31 +667,24 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) } else { - int width, height, flags; + int width, height; int i; if(render->caps & HW_TEX_BLIT) { - sna_create_mask(); - width = render->ctx_width; height = render->ctx_height; - flags = HW_TEX_BLIT; } else { width = draw_w; height = draw_h;; - flags = HW_BIT_BLIT; } for( i=0; i < 2; i++) { - render->bitmap[i].width = width; - render->bitmap[i].height = height; - render->bitmap[i].flags = flags; - - if( create_bitmap(&render->bitmap[i]) != 0 ) + render->bitmap[i] = pxCreateBitmap(width, height); + if( render->bitmap[i] == NULL ) { player_state = CLOSED; free(render); @@ -705,28 +697,24 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) render->draw = draw_hw_picture; }; - printf("FPlay %s render engine: context %dx%d picture %dx%d\n", render->caps & HW_TEX_BLIT ? "hw_tex_blit": render->caps & HW_BIT_BLIT ? "hw_bit_blit":"software", render->ctx_width, render->ctx_height, draw_w, draw_h); -// if(init_hw_context(ctx) == 0) -// printf("create hardware decoder context\n"); - return render; }; void destroy_render(render_t *render) { - destroy_bitmap(&render->bitmap[0]); + pxDestroyBitmap(render->bitmap[0]); if(render->caps & (HW_BIT_BLIT|HW_TEX_BLIT)) /* hw blitter */ - destroy_bitmap(&render->bitmap[1]); + pxDestroyBitmap(render->bitmap[1]); - done_pixlib(); + pxFini(); }; void render_set_size(render_t *render, int width, int height) @@ -830,28 +818,32 @@ void render_adjust_size(render_t *render, window_t *win) render_set_size(render, new_w, new_h); if(render->caps & HW_TEX_BLIT) /* hw scaler */ - return; + { + if(render->win->win_state == FULLSCREEN) + pxResizeClient(render->rcvideo.l, render->rcvideo.t, new_w, new_h); + else + pxResizeClient(render->rcvideo.l, render->rcvideo.t+CAPTION_HEIGHT, new_w, new_h); - render->bitmap[0].width = new_w; - render->bitmap[0].height = new_h; - resize_bitmap(&render->bitmap[0]); + return; + }; + + pxResizeBitmap(render->bitmap[0], new_w, new_h); if(render->caps & HW_BIT_BLIT) /* hw blitter */ - { - render->bitmap[1].width = new_w; - render->bitmap[1].height = new_h; - resize_bitmap(&render->bitmap[1]); - }; + pxResizeBitmap(render->bitmap[1], new_w, new_h); + return; }; void draw_hw_picture(render_t *render, AVPicture *picture) { - int dst_width, dst_height; - bitmap_t *bitmap; - uint8_t *data[4]; - int linesize[4]; - int ret; + int dst_width; + int dst_height; + bitmap_t *bitmap; + uint8_t *bitmap_data; + uint32_t bitmap_pitch; + uint8_t *data[4]; + int linesize[4]; if(render->win->win_state == MINIMIZED || render->win->win_state == ROLLED) @@ -878,25 +870,25 @@ void draw_hw_picture(render_t *render, AVPicture *picture) return ; }; - bitmap = &render->bitmap[render->target]; + bitmap = render->bitmap[render->target]; - ret = lock_bitmap(bitmap); - if( ret != 0) + bitmap_data = pxLockBitmap(bitmap, &bitmap_pitch); + if( bitmap_data == NULL) { printf("Cannot lock bitmap!\n"); return ; } // printf("sws_getCachedContext\n"); - data[0] = bitmap->data; - data[1] = bitmap->data+1; - data[2] = bitmap->data+2; - data[3] = bitmap->data+3; + data[0] = bitmap_data; + data[1] = bitmap_data+1; + data[2] = bitmap_data+2; + data[3] = bitmap_data+3; - linesize[0] = bitmap->pitch; - linesize[1] = bitmap->pitch; - linesize[2] = bitmap->pitch; - linesize[3] = bitmap->pitch; + linesize[0] = bitmap_pitch; + linesize[1] = bitmap_pitch; + linesize[2] = bitmap_pitch; + linesize[3] = bitmap_pitch; sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, picture->linesize, 0, render->ctx_height, data, linesize); @@ -907,20 +899,20 @@ void draw_hw_picture(render_t *render, AVPicture *picture) { if(render->win->win_state == FULLSCREEN) - fplay_blit_bitmap(bitmap,render->rcvideo.l,render->rcvideo.t, - render->rcvideo.r, render->rcvideo.b); + pxBlitBitmap(bitmap,render->rcvideo.l,render->rcvideo.t, + render->rcvideo.r, render->rcvideo.b,0,0); else - fplay_blit_bitmap(bitmap, render->rcvideo.l, + pxBlitBitmap(bitmap, render->rcvideo.l, CAPTION_HEIGHT+render->rcvideo.t, - render->rcvideo.r, render->rcvideo.b); + render->rcvideo.r, render->rcvideo.b,0,0); } else { if(render->win->win_state == FULLSCREEN) - blit_bitmap(bitmap,render->rcvideo.l,render->rcvideo.t, + pxBlitBitmap(bitmap,render->rcvideo.l,render->rcvideo.t, render->rcvideo.r, render->rcvideo.b, 0,0); else - blit_bitmap(bitmap, render->rcvideo.l, + pxBlitBitmap(bitmap, render->rcvideo.l, CAPTION_HEIGHT+render->rcvideo.t, render->rcvideo.r, render->rcvideo.b, 0, 0); }; @@ -932,6 +924,8 @@ void draw_hw_picture(render_t *render, AVPicture *picture) void draw_sw_picture(render_t *render, AVPicture *picture) { + uint8_t *bitmap_data; + uint32_t bitmap_pitch; uint8_t *data[4]; int linesize[4]; @@ -950,30 +944,30 @@ void draw_sw_picture(render_t *render, AVPicture *picture) return ; } - lock_bitmap(&render->bitmap[0]); + bitmap_data = pxLockBitmap(render->bitmap[0],&bitmap_pitch); - data[0] = render->bitmap[0].data; - data[1] = render->bitmap[0].data+1; - data[2] = render->bitmap[0].data+2; - data[3] = render->bitmap[0].data+3; + data[0] = bitmap_data; + data[1] = bitmap_data+1; + data[2] = bitmap_data+2; + data[3] = bitmap_data+3; - linesize[0] = render->bitmap[0].pitch; - linesize[1] = render->bitmap[0].pitch; - linesize[2] = render->bitmap[0].pitch; - linesize[3] = render->bitmap[0].pitch; + linesize[0] = bitmap_pitch; + linesize[1] = bitmap_pitch; + linesize[2] = bitmap_pitch; + linesize[3] = bitmap_pitch; sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, picture->linesize, 0, render->ctx_height, data, linesize); if(render->win->win_state == FULLSCREEN) - fplay_blit_bitmap(&render->bitmap[0],render->rcvideo.l,render->rcvideo.t, - render->rcvideo.r, render->rcvideo.b); + pxBlitBitmap(render->bitmap[0],render->rcvideo.l,render->rcvideo.t, + render->rcvideo.r, render->rcvideo.b,0,0); else - fplay_blit_bitmap(&render->bitmap[0], render->rcvideo.l, + pxBlitBitmap(render->bitmap[0], render->rcvideo.l, CAPTION_HEIGHT+render->rcvideo.t, - render->rcvideo.r, render->rcvideo.b); + render->rcvideo.r, render->rcvideo.b,0,0); - render->last_bitmap = &render->bitmap[0]; + render->last_bitmap = render->bitmap[0]; } void render_draw_client(render_t *render) diff --git a/contrib/media/fplay/winlib/button.c b/contrib/media/fplay/winlib/button.c index bed33db805..f1cf7d48e9 100644 --- a/contrib/media/fplay/winlib/button.c +++ b/contrib/media/fplay/winlib/button.c @@ -20,7 +20,6 @@ static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2) ctrl_t *create_control(size_t size, int id, int x, int y, int w, int h, ctrl_t *parent) { - ctrl_t *ctrl; if( !parent ) @@ -126,8 +125,6 @@ int draw_button_cairo(button_t *btn) ctx = btn->ctrl.ctx; - lock_bitmap(ctx->pixmap); - x = btn->ctrl.rc.l - ctx->offset_x; y = btn->ctrl.rc.t - ctx->offset_y; @@ -258,8 +255,6 @@ int draw_progress(progress_t *prg, int background) int len = prg->ctrl.w; ctx = prg->ctrl.ctx; - - lock_bitmap(ctx->pixmap); x = prg->ctrl.rc.l - ctx->offset_x; y = prg->ctrl.rc.t - ctx->offset_y; @@ -268,32 +263,31 @@ int draw_progress(progress_t *prg, int background) { src = res_progress_bar; - pixmap = (int*)ctx->pixmap->data; - pixmap+= y * ctx->pixmap->pitch/4 + x; + pixmap = (int*)ctx->pixmap_data; + pixmap+= y * ctx->pixmap_pitch/4 + x; for(i=0; i < 10; i++) { for(j = 0; j < len; j++) pixmap[j] = *src; - pixmap+= ctx->pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; src++; }; }; - len = prg->current*prg->ctrl.w/(prg->max - prg->min); src = res_prg_level; - pixmap = (int*)ctx->pixmap->data; - pixmap+= y*ctx->pixmap->pitch/4 + x; + pixmap = (int*)ctx->pixmap_data; + pixmap+= y*ctx->pixmap_pitch/4 + x; for(i=0; i < prg->ctrl.h ;i++) { for(j=0; j < len; j++) pixmap[j] = *src; - pixmap+= ctx->pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; src++; }; @@ -353,8 +347,8 @@ progress_t *create_progress(char *caption, int id, int x, int y, int draw_level(level_t *lvl) { - int *pixmap; - ctx_t *ctx; + int *pixmap; + ctx_t *ctx; int i, j; int x, y; @@ -363,8 +357,6 @@ int draw_level(level_t *lvl) ctx = lvl->ctrl.ctx; - lock_bitmap(ctx->pixmap); - x = lvl->ctrl.rc.l - ctx->offset_x; y = lvl->ctrl.rc.t - ctx->offset_y; @@ -377,15 +369,15 @@ int draw_level(level_t *lvl) if(len > 96) len = 96; - pixmap = (int*)ctx->pixmap->data; + pixmap = (int*)ctx->pixmap_data; - pixmap+= y*ctx->pixmap->pitch/4 + x; + pixmap+= y*ctx->pixmap_pitch/4 + x; for(i=0; i < 10; i++) { for(j = 0; j < 96; j++) pixmap[j] = 0xFF1C1C1C; - pixmap+= ctx->pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; }; blit_raw(ctx, lvl->img_level, x, y, len, 10, 96*4); @@ -397,7 +389,6 @@ int draw_level(level_t *lvl) int lvl_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { level_t *lvl = (level_t*)ctrl; -// int pos; switch( msg ) { @@ -444,7 +435,7 @@ level_t *create_level(char *caption, int id, int x, int y, int draw_slider(slider_t *sld) { - int *pixmap; + int *pixmap; ctx_t *ctx; int i, j; int x, y; @@ -454,25 +445,22 @@ int draw_slider(slider_t *sld) ctx = sld->ctrl.ctx; - lock_bitmap(ctx->pixmap); - x = sld->ctrl.rc.l - ctx->offset_x; y = sld->ctrl.rc.t - ctx->offset_y; len = 96 + 12; - pixmap = (int*)ctx->pixmap->data; - pixmap+= y*ctx->pixmap->pitch/4 + x; + pixmap = (int*)ctx->pixmap_data; + pixmap+= y*ctx->pixmap_pitch/4 + x; for(i=0; i < 11; i++) { for(j = 0; j < len; j++) pixmap[j] = 0xFF1C1C1C; - pixmap+= ctx->pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; }; blit_raw(ctx, sld->img_vol_slider, x+6, y+4, 96, 4, 96*4); - blit_raw(ctx, res_slider, x+sld->pos, y, 12, 11, 12*4); return 0; diff --git a/contrib/media/fplay/winlib/caption.c b/contrib/media/fplay/winlib/caption.c index 52c9017919..9385975661 100644 --- a/contrib/media/fplay/winlib/caption.c +++ b/contrib/media/fplay/winlib/caption.c @@ -44,19 +44,8 @@ int init_caption(window_t *win) cpt->text = win->caption_txt; - cpt->bitmap.width = 1920; - cpt->bitmap.height = CAPTION_HEIGHT; - cpt->bitmap.flags = 0; - - if( create_bitmap(&cpt->bitmap) ) - { - printf("not enough memory for caption bitmap\n"); - return 0; - } - - -// printf("win_w %d win_h %d\n", win->w, win->h); - ctx->pixmap = &cpt->bitmap; + ctx->pixmap_data = user_alloc(1920*CAPTION_HEIGHT*4); + ctx->pixmap_pitch= 1920*4; ctx->offset_x = 0; ctx->offset_y = 0; @@ -92,10 +81,9 @@ int init_caption(window_t *win) void update_caption_size(window_t *win) { caption_t *cpt = &win->caption; - bitmap_t *bitmap = &cpt->bitmap; + ctx_t *ctx = &cpt->ctx; - bitmap->width = win->w; - resize_bitmap(bitmap); + ctx->pixmap_pitch = win->w * 4; cpt->ctrl.rc.l = 0; cpt->ctrl.rc.t = 0; @@ -116,27 +104,24 @@ void update_caption_size(window_t *win) cpt->full_btn->ctrl.rc.l = win->w - 27 - 18 -18 - 5 - 5; cpt->full_btn->ctrl.rc.r = cpt->full_btn->ctrl.rc.l + cpt->full_btn->ctrl.w; - }; - extern int win_font; void draw_caption(caption_t *cpt) { - int *pixmap, *src; - rect_t rc; - int i, j, w; + ctx_t *ctx = &cpt->ctx; + int *pixmap, *src; + rect_t rc; + int i, j, w; - lock_bitmap(&cpt->bitmap); - - blit_raw(&cpt->ctx, res_caption_left, 0, 0, + blit_raw(ctx, res_caption_left, 0, 0, CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4); w = cpt->ctrl.w - (2*CAPTION_CORNER_W); if( w > 0) { - pixmap = (int*)cpt->ctx.pixmap->data; + pixmap = (int*)ctx->pixmap_data; pixmap+= CAPTION_CORNER_W; src = res_caption_body; @@ -144,16 +129,11 @@ void draw_caption(caption_t *cpt) { for(j = 0; j < w; j++) pixmap[j] = src[i]; - pixmap+= cpt->ctx.pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; } - -// blit_raw(&cpt->ctx,res_caption_body, CAPTION_CORNER_W, 0, -// w, CAPTION_HEIGHT, 0); - }; - - blit_raw(&cpt->ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0, + blit_raw(ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0, CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4); rc.l = 8; @@ -161,7 +141,7 @@ void draw_caption(caption_t *cpt) rc.r = cpt->ctrl.w - 27 - 18 - 18 - 5 - 5 - 8; rc.b = 18; - draw_text_ext(cpt->ctx.pixmap, win_font, cpt->text, &rc, 0xFFFFFFFF); + draw_text_ext(ctx->pixmap_data, ctx->pixmap_pitch, win_font, cpt->text, &rc, 0xFFFFFFFF); ctrl_t *child; child = (ctrl_t*)cpt->ctrl.child.next; @@ -264,9 +244,8 @@ void blit_caption(caption_t *cpt) // printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, // cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); - lock_bitmap(&cpt->bitmap); - Blit(cpt->ctx.pixmap->data, 0, 0, 0, 0, cpt->ctrl.w, cpt->ctrl.h, - cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap->pitch); + Blit(cpt->ctx.pixmap_data, 0, 0, 0, 0, cpt->ctrl.w, cpt->ctrl.h, + cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap_pitch); }; diff --git a/contrib/media/fplay/winlib/control.h b/contrib/media/fplay/winlib/control.h index 162f58257a..f0b92cc96a 100644 --- a/contrib/media/fplay/winlib/control.h +++ b/contrib/media/fplay/winlib/control.h @@ -1,7 +1,7 @@ #ifndef __CONTROL_H__ #define __CONTROL_H_ -#include +#include #include "link.h" typedef struct @@ -14,9 +14,10 @@ typedef struct typedef struct ctx { - bitmap_t *pixmap; - int offset_x; - int offset_y; + int offset_x; + int offset_y; + int *pixmap_data; + int pixmap_pitch; }ctx_t; ctx_t *get_window_ctx(); diff --git a/contrib/media/fplay/winlib/fontlib.c b/contrib/media/fplay/winlib/fontlib.c index 0c5d7adf58..d8518d68ee 100644 --- a/contrib/media/fplay/winlib/fontlib.c +++ b/contrib/media/fplay/winlib/fontlib.c @@ -23,7 +23,7 @@ typedef unsigned int color_t; unsigned int ansi2utf32(unsigned char ch); -void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int col) +static void my_draw_bitmap(uint8_t *pixmap, uint32_t pitch, FT_Bitmap *bitmap, int dstx, int dsty, int col) { uint8_t *dst; uint8_t *src, *tmpsrc; @@ -31,7 +31,7 @@ void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int co uint32_t *tmpdst; int i, j; - dst = win->data + dsty * win->pitch + dstx*4; + dst = pixmap + dsty * pitch + dstx*4; src = bitmap->buffer; for( i = 0; i < bitmap->rows; i++ ) @@ -39,7 +39,7 @@ void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int co tmpdst = (uint32_t*)dst; tmpsrc = src; - dst+= win->pitch; + dst+= pitch; src+= bitmap->pitch; for( j = 0; j < bitmap->width; j++) @@ -68,7 +68,7 @@ void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int co }; -int draw_text_ext(bitmap_t *winbitmap, FT_Face face, char *text, rect_t *rc, int color) +int draw_text_ext(void *pixmap, uint32_t pitch, FT_Face face, char *text, rect_t *rc, int color) { FT_UInt glyph_index; FT_Bool use_kerning = 0; @@ -107,8 +107,8 @@ int draw_text_ext(bitmap_t *winbitmap, FT_Face face, char *text, rect_t *rc, int if ( err ) continue; - my_draw_bitmap(winbitmap, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left, - y - face->glyph->bitmap_top, color); + my_draw_bitmap(pixmap, pitch, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left, + y - face->glyph->bitmap_top, color); x += face->glyph->advance.x; previous = glyph_index; diff --git a/contrib/media/fplay/winlib/frame.c b/contrib/media/fplay/winlib/frame.c index 224588c587..4f8cac001b 100644 --- a/contrib/media/fplay/winlib/frame.c +++ b/contrib/media/fplay/winlib/frame.c @@ -67,8 +67,12 @@ void init_frame(window_t *win) extern int res_border_left[]; extern int res_border_right[]; +#if 0 int draw_frame(window_t *win) { + void *pixmap_data; + uint32_t pixmap_pitch; + int *pixmap, *src; int i, j; @@ -124,6 +128,8 @@ int draw_frame(window_t *win) return 0; }; +#endif + int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { diff --git a/contrib/media/fplay/winlib/panel.c b/contrib/media/fplay/winlib/panel.c index fc0e51ebce..50822c46f7 100644 --- a/contrib/media/fplay/winlib/panel.c +++ b/contrib/media/fplay/winlib/panel.c @@ -52,18 +52,8 @@ int init_panel(window_t *win) panel->ctrl.parent = (ctrl_t*)win; panel->layout = 0; - - panel->bitmap.width = 1920; - panel->bitmap.height = PANEL_HEIGHT; - panel->bitmap.flags = 0; - if( create_bitmap(&panel->bitmap) ) - { - printf("not enough memory for panel bitmap\n"); - return 0; - } - - ctx->pixmap = &panel->bitmap; + ctx->pixmap_data = user_alloc(1920*PANEL_HEIGHT*4); ctx->offset_x = 0; ctx->offset_y = 0; @@ -89,10 +79,10 @@ int init_panel(window_t *win) lvl = create_level(NULL, ID_VOL_LEVEL, 0, 20, 96, 10, &panel->ctrl); lvl->vol = -1875; panel->lvl = lvl; - + sld = create_slider(NULL, ID_VOL_CTRL, 0, 20, 96+12, 12, &panel->ctrl); - panel->sld = sld; - + panel->sld = sld; + // btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt); // cpt->minimize_btn = btn; @@ -100,8 +90,6 @@ int init_panel(window_t *win) // btn->img_hilite = res_minimize_btn_hl; // btn->img_pressed = res_minimize_btn_pressed; - - update_panel_size(win); return 1; @@ -112,7 +100,7 @@ static void panel_update_layout(panel_t *panel) { progress_t *prg = panel->prg; level_t *lvl = panel->lvl; - + if(panel->layout == 0) { prg->ctrl.rc.l = panel->ctrl.rc.l; @@ -132,7 +120,7 @@ static void panel_update_layout(panel_t *panel) lvl->ctrl.rc.t = panel->ctrl.rc.t+7; lvl->ctrl.rc.r = lvl->ctrl.rc.l + lvl->ctrl.w; lvl->ctrl.rc.b = lvl->ctrl.rc.t + lvl->ctrl.h; - + prg->ctrl.rc.l = lvl->ctrl.rc.r; prg->ctrl.rc.t = panel->ctrl.rc.t+7; prg->ctrl.rc.r = panel->ctrl.rc.r; @@ -143,25 +131,23 @@ static void panel_update_layout(panel_t *panel) void panel_set_layout(panel_t *panel, int layout) { - panel->layout = layout; + panel->layout = layout; panel->lvl->visible = layout; - + panel_update_layout(panel); - + send_message(&panel->prg->ctrl, MSG_PAINT, 0, 0); - + if(layout) send_message(&panel->lvl->ctrl, MSG_PAINT, 0, 0); }; void update_panel_size(window_t *win) { - panel_t *panel = &win->panel; - bitmap_t *bitmap = &panel->bitmap; + panel_t *panel = &win->panel; + + panel->ctx.pixmap_pitch = win->w*4; - bitmap->width = win->w; - resize_bitmap(bitmap); - panel->ctx.offset_x = 0; panel->ctx.offset_y = win->h-PANEL_HEIGHT; @@ -194,25 +180,23 @@ void update_panel_size(window_t *win) panel->sld->ctrl.rc.r = panel->sld->ctrl.rc.l + panel->sld->ctrl.w; panel->sld->ctrl.rc.b = panel->sld->ctrl.rc.t + panel->sld->ctrl.h; - panel_update_layout(panel); + panel_update_layout(panel); }; void draw_panel(panel_t *panel) { + ctx_t *ctx = &panel->ctx; int *pixmap, *src; int i, j, w; - lock_bitmap(&panel->bitmap); - - blit_raw(&panel->ctx, res_panel_left, 0, 0, + blit_raw(ctx, res_panel_left, 0, 0, PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4); - w = panel->ctrl.w - (2*PANEL_CORNER_W); if( w > 0) { - pixmap = (int*)panel->ctx.pixmap->data; + pixmap = (int*)ctx->pixmap_data; pixmap+= PANEL_CORNER_W; src = res_panel_body; @@ -220,7 +204,7 @@ void draw_panel(panel_t *panel) { for(j = 0; j < w; j++) pixmap[j] = src[i]; - pixmap+= panel->ctx.pixmap->pitch/4; + pixmap+= ctx->pixmap_pitch/4; } }; @@ -283,7 +267,7 @@ int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) case ID_PLAY: case ID_STOP: case ID_PROGRESS: - case ID_VOL_CTRL: + case ID_VOL_CTRL: win = get_parent_window(ctrl); send_message(win, msg, arg1, arg2); break; @@ -302,13 +286,10 @@ int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) void blit_panel(panel_t *panel) { -// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, -// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); + ctx_t *ctx = &panel->ctx; - lock_bitmap(&panel->bitmap); - - Blit(panel->ctx.pixmap->data, panel->draw.l, panel->draw.t, + Blit(ctx->pixmap_data, panel->draw.l, panel->draw.t, 0, 0, panel->ctrl.w, panel->ctrl.h, - panel->ctrl.w, panel->ctrl.h, panel->ctx.pixmap->pitch); + panel->ctrl.w, panel->ctrl.h, ctx->pixmap_pitch); }; diff --git a/contrib/media/fplay/winlib/window.c b/contrib/media/fplay/winlib/window.c index 125bdc6b50..8fcb049e09 100644 --- a/contrib/media/fplay/winlib/window.c +++ b/contrib/media/fplay/winlib/window.c @@ -79,7 +79,7 @@ window_t *create_window(char *caption, int style, int x, int y, if(handler==0) return 0; BeginDraw(); - DrawWindow(x, y, w-1, h-1, + DrawWindow(x, y, w, h, NULL,0,0x41); EndDraw(); @@ -213,13 +213,14 @@ static int draw_window(window_t *win) void blit_client(window_t *win) { + ctx_t *ctx = &win->ctx; int w, h; w = win->client.r - win->client.l; h = win->client.b - win->client.t; - Blit(win->ctx->pixmap->data, win->client.l, win->client.t, - 0, 0, w, h, w, h,win->ctx->pixmap->pitch); + Blit(ctx->pixmap_data, win->client.l, win->client.t, + 0, 0, w, h, w, h, ctx->pixmap_pitch); }; @@ -366,7 +367,6 @@ void do_sys_draw(window_t *win) BeginDraw(); DrawWindow(0,0,0,0, NULL, 0x000000,0x41); -// DefineButton(15, 15, 0x00000001, 0); EndDraw(); send_message((ctrl_t*)win, MSG_DRAW_CLIENT, 0, 0); @@ -628,6 +628,8 @@ void init_winlib(void) void update_rect(ctrl_t *ctrl) { + ctx_t *ctx = ctrl->ctx; + int ctx_w, ctx_h; int src_x, src_y; @@ -637,36 +639,12 @@ void update_rect(ctrl_t *ctrl) ctx_w = ctrl->parent->w; ctx_h = ctrl->parent->h; - Blit(ctrl->ctx->pixmap->data, ctrl->rc.l, ctrl->rc.t, src_x, src_y, - ctrl->w, ctrl->h, ctx_w, ctx_h, ctrl->ctx->pixmap->pitch); + Blit(ctx->pixmap_data, ctrl->rc.l, ctrl->rc.t, src_x, src_y, + ctrl->w, ctrl->h, ctx_w, ctx_h, ctx->pixmap_pitch); // need_update++; }; - -void Blit(void *bitmap, int dst_x, int dst_y, - int src_x, int src_y, int w, int h, - int src_w, int src_h, int stride) -{ - volatile struct blit_call bc; - - bc.dstx = dst_x; - bc.dsty = dst_y; - bc.w = w; - bc.h = h; - bc.srcx = src_x; - bc.srcy = src_y; - bc.srcw = src_w; - bc.srch = src_h; - bc.stride = stride; - bc.bitmap = bitmap; - - __asm__ __volatile__( - "int $0x40" - ::"a"(73),"b"(0x20),"c"(&bc.dstx)); - -}; - ctrl_t *get_child(ctrl_t *ctrl, int x, int y) { ctrl_t *child = NULL; diff --git a/contrib/media/fplay/winlib/winlib.h b/contrib/media/fplay/winlib/winlib.h index 0865e50e50..03c4e2fc62 100644 --- a/contrib/media/fplay/winlib/winlib.h +++ b/contrib/media/fplay/winlib/winlib.h @@ -36,7 +36,6 @@ typedef struct { ctrl_t ctrl; ctx_t ctx; - bitmap_t bitmap; char *text; ctrl_t *child_over; @@ -50,7 +49,6 @@ typedef struct { ctrl_t ctrl; ctx_t ctx; - bitmap_t bitmap; rect_t draw; ctrl_t *child_over; int layout; @@ -73,7 +71,7 @@ typedef struct handler_t *handler; ctrl_t *parent; - ctx_t *ctx; + ctx_t ctx; uint32_t id; uint32_t style; @@ -84,10 +82,6 @@ typedef struct rect_t saved; rect_t client; -// ctx_t client_ctx; -// bitmap_t bitmap; - bitmap_t bitmap; - char *caption_txt; ctrl_t *child_over; ctrl_t *child_focus;