Fplay: use pixlib3 for renderig.

git-svn-id: svn://kolibrios.org@5372 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2015-01-15 05:51:37 +00:00
parent 3287cff0b2
commit 5dc819f7b8
12 changed files with 156 additions and 237 deletions

View File

@ -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 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:= -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 LIBPATH:= -L$(LIB_DIR) -L/home/autobuild/tools/win32/mingw32/lib

View File

@ -1,5 +1,5 @@
#include "pixlib2.h" #include "pixlib3.h"
#define BLACK_MAGIC_SOUND #define BLACK_MAGIC_SOUND
#define BLACK_MAGIC_VIDEO #define BLACK_MAGIC_VIDEO
@ -30,7 +30,7 @@ struct render
rect_t rcbottom; rect_t rcbottom;
uint32_t layout; uint32_t layout;
bitmap_t bitmap[4]; bitmap_t *bitmap[4];
bitmap_t *last_bitmap; bitmap_t *last_bitmap;
uint32_t ctx_format; uint32_t ctx_format;
@ -135,9 +135,7 @@ static inline void GetNotify(void *event)
} }
int init_fontlib(); int init_fontlib();
int draw_text(bitmap_t *winbitmap, int face, char *text, int x, int y, int color); //int draw_text_ext(void *pixmap, uint32_t pitch, FT_Face face, char *text, rect_t *rc, int color);
int draw_text_ext(bitmap_t *winbitmap, int face, char *text, rect_t *rc, int color);
char *get_moviefile(); char *get_moviefile();

View File

@ -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) 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 *src = raw;
int i, j; 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(i=0; i < h; i++)
{ {
for(j = 0; j < w; j++) for(j = 0; j < w; j++)
dst[j] = src[j]; dst[j] = src[j];
dst+= ctx->pixmap->pitch/4; dst+= ctx->pixmap_pitch/4;
src+= pitch/4; src+= pitch/4;
}; };
}; };

View File

@ -184,8 +184,6 @@ extern volatile enum player_state player_state;
extern volatile enum player_state decoder_state; extern volatile enum player_state decoder_state;
extern volatile enum player_state sound_state; extern volatile enum player_state sound_state;
//rect_t win_rect;
extern int64_t rewind_pos; extern int64_t rewind_pos;
static void player_stop() static void player_stop()
@ -219,7 +217,6 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
switch(msg) switch(msg)
{ {
case MSG_SIZE: case MSG_SIZE:
//printf("MSG_SIZE\n");
if(main_render) if(main_render)
{ {
render_adjust_size(main_render, win); 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; win->win_state = win->saved_state;
window_update_layout(win); window_update_layout(win);
// if(win->saved_state == MAXIMIZED) // if(win->saved_state == MAXIMIZED)
{ // {
blit_caption(&win->caption); // blit_caption(&win->caption);
blit_panel(&win->panel); // blit_panel(&win->panel);
} // }
} }
ent_down = 1; ent_down = 1;
}; };
@ -567,6 +564,9 @@ int video_thread(void *param)
AVCodecContext *ctx = param; AVCodecContext *ctx = param;
window_t *MainWindow; window_t *MainWindow;
printf("%s\n", __FUNCTION__);
init_winlib(); init_winlib();
MainWindow = create_window(movie_file,0, 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; render->ctx_format = ctx->pix_fmt;
mutex_lock(&driver_lock); mutex_lock(&driver_lock);
render->caps = init_pixlib(flags); render->caps = pxInit(1);
mutex_unlock(&driver_lock); mutex_unlock(&driver_lock);
right = win->w; right = win->w;
bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT; bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
// printf("window width %d height %d\n", printf("window width %d height %d\n",
// right, bottom); right, bottom);
render->win_state = win->win_state; 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); render_set_size(render, draw_w, draw_h);
pxCreateClient(0, CAPTION_HEIGHT, right, bottom);
if(render->caps==0) if(render->caps==0)
{ {
render->bitmap[0].width = draw_w; render->bitmap[0] = pxCreateBitmap(draw_w, draw_h);
render->bitmap[0].height = draw_h; if(render->bitmap[0] == NULL)
if( create_bitmap(&render->bitmap[0]) != 0 )
{ {
free(render); free(render);
return NULL; return NULL;
@ -668,31 +667,24 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags)
} }
else else
{ {
int width, height, flags; int width, height;
int i; int i;
if(render->caps & HW_TEX_BLIT) if(render->caps & HW_TEX_BLIT)
{ {
sna_create_mask();
width = render->ctx_width; width = render->ctx_width;
height = render->ctx_height; height = render->ctx_height;
flags = HW_TEX_BLIT;
} }
else else
{ {
width = draw_w; width = draw_w;
height = draw_h;; height = draw_h;;
flags = HW_BIT_BLIT;
} }
for( i=0; i < 2; i++) for( i=0; i < 2; i++)
{ {
render->bitmap[i].width = width; render->bitmap[i] = pxCreateBitmap(width, height);
render->bitmap[i].height = height; if( render->bitmap[i] == NULL )
render->bitmap[i].flags = flags;
if( create_bitmap(&render->bitmap[i]) != 0 )
{ {
player_state = CLOSED; player_state = CLOSED;
free(render); free(render);
@ -705,28 +697,24 @@ render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags)
render->draw = draw_hw_picture; render->draw = draw_hw_picture;
}; };
printf("FPlay %s render engine: context %dx%d picture %dx%d\n", printf("FPlay %s render engine: context %dx%d picture %dx%d\n",
render->caps & HW_TEX_BLIT ? "hw_tex_blit": render->caps & HW_TEX_BLIT ? "hw_tex_blit":
render->caps & HW_BIT_BLIT ? "hw_bit_blit":"software", render->caps & HW_BIT_BLIT ? "hw_bit_blit":"software",
render->ctx_width, render->ctx_height, render->ctx_width, render->ctx_height,
draw_w, draw_h); draw_w, draw_h);
// if(init_hw_context(ctx) == 0)
// printf("create hardware decoder context\n");
return render; return render;
}; };
void destroy_render(render_t *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 */ 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) 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); render_set_size(render, new_w, new_h);
if(render->caps & HW_TEX_BLIT) /* hw scaler */ 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; return;
render->bitmap[0].height = new_h; };
resize_bitmap(&render->bitmap[0]);
pxResizeBitmap(render->bitmap[0], new_w, new_h);
if(render->caps & HW_BIT_BLIT) /* hw blitter */ if(render->caps & HW_BIT_BLIT) /* hw blitter */
{ pxResizeBitmap(render->bitmap[1], new_w, new_h);
render->bitmap[1].width = new_w;
render->bitmap[1].height = new_h;
resize_bitmap(&render->bitmap[1]);
};
return; return;
}; };
void draw_hw_picture(render_t *render, AVPicture *picture) void draw_hw_picture(render_t *render, AVPicture *picture)
{ {
int dst_width, dst_height; int dst_width;
bitmap_t *bitmap; int dst_height;
uint8_t *data[4]; bitmap_t *bitmap;
int linesize[4]; uint8_t *bitmap_data;
int ret; uint32_t bitmap_pitch;
uint8_t *data[4];
int linesize[4];
if(render->win->win_state == MINIMIZED || if(render->win->win_state == MINIMIZED ||
render->win->win_state == ROLLED) render->win->win_state == ROLLED)
@ -878,25 +870,25 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
return ; return ;
}; };
bitmap = &render->bitmap[render->target]; bitmap = render->bitmap[render->target];
ret = lock_bitmap(bitmap); bitmap_data = pxLockBitmap(bitmap, &bitmap_pitch);
if( ret != 0) if( bitmap_data == NULL)
{ {
printf("Cannot lock bitmap!\n"); printf("Cannot lock bitmap!\n");
return ; return ;
} }
// printf("sws_getCachedContext\n"); // printf("sws_getCachedContext\n");
data[0] = bitmap->data; data[0] = bitmap_data;
data[1] = bitmap->data+1; data[1] = bitmap_data+1;
data[2] = bitmap->data+2; data[2] = bitmap_data+2;
data[3] = bitmap->data+3; data[3] = bitmap_data+3;
linesize[0] = bitmap->pitch; linesize[0] = bitmap_pitch;
linesize[1] = bitmap->pitch; linesize[1] = bitmap_pitch;
linesize[2] = bitmap->pitch; linesize[2] = bitmap_pitch;
linesize[3] = bitmap->pitch; linesize[3] = bitmap_pitch;
sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, sws_scale(cvt_ctx, (const uint8_t* const *)picture->data,
picture->linesize, 0, render->ctx_height, data, linesize); 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) if(render->win->win_state == FULLSCREEN)
fplay_blit_bitmap(bitmap,render->rcvideo.l,render->rcvideo.t, pxBlitBitmap(bitmap,render->rcvideo.l,render->rcvideo.t,
render->rcvideo.r, render->rcvideo.b); render->rcvideo.r, render->rcvideo.b,0,0);
else else
fplay_blit_bitmap(bitmap, render->rcvideo.l, pxBlitBitmap(bitmap, render->rcvideo.l,
CAPTION_HEIGHT+render->rcvideo.t, CAPTION_HEIGHT+render->rcvideo.t,
render->rcvideo.r, render->rcvideo.b); render->rcvideo.r, render->rcvideo.b,0,0);
} }
else else
{ {
if(render->win->win_state == FULLSCREEN) 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); render->rcvideo.r, render->rcvideo.b, 0,0);
else else
blit_bitmap(bitmap, render->rcvideo.l, pxBlitBitmap(bitmap, render->rcvideo.l,
CAPTION_HEIGHT+render->rcvideo.t, CAPTION_HEIGHT+render->rcvideo.t,
render->rcvideo.r, render->rcvideo.b, 0, 0); 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) void draw_sw_picture(render_t *render, AVPicture *picture)
{ {
uint8_t *bitmap_data;
uint32_t bitmap_pitch;
uint8_t *data[4]; uint8_t *data[4];
int linesize[4]; int linesize[4];
@ -950,30 +944,30 @@ void draw_sw_picture(render_t *render, AVPicture *picture)
return ; return ;
} }
lock_bitmap(&render->bitmap[0]); bitmap_data = pxLockBitmap(render->bitmap[0],&bitmap_pitch);
data[0] = render->bitmap[0].data; data[0] = bitmap_data;
data[1] = render->bitmap[0].data+1; data[1] = bitmap_data+1;
data[2] = render->bitmap[0].data+2; data[2] = bitmap_data+2;
data[3] = render->bitmap[0].data+3; data[3] = bitmap_data+3;
linesize[0] = render->bitmap[0].pitch; linesize[0] = bitmap_pitch;
linesize[1] = render->bitmap[0].pitch; linesize[1] = bitmap_pitch;
linesize[2] = render->bitmap[0].pitch; linesize[2] = bitmap_pitch;
linesize[3] = render->bitmap[0].pitch; linesize[3] = bitmap_pitch;
sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, sws_scale(cvt_ctx, (const uint8_t* const *)picture->data,
picture->linesize, 0, render->ctx_height, data, linesize); picture->linesize, 0, render->ctx_height, data, linesize);
if(render->win->win_state == FULLSCREEN) if(render->win->win_state == FULLSCREEN)
fplay_blit_bitmap(&render->bitmap[0],render->rcvideo.l,render->rcvideo.t, pxBlitBitmap(render->bitmap[0],render->rcvideo.l,render->rcvideo.t,
render->rcvideo.r, render->rcvideo.b); render->rcvideo.r, render->rcvideo.b,0,0);
else else
fplay_blit_bitmap(&render->bitmap[0], render->rcvideo.l, pxBlitBitmap(render->bitmap[0], render->rcvideo.l,
CAPTION_HEIGHT+render->rcvideo.t, 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) void render_draw_client(render_t *render)

View File

@ -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, ctrl_t *create_control(size_t size, int id, int x, int y,
int w, int h, ctrl_t *parent) int w, int h, ctrl_t *parent)
{ {
ctrl_t *ctrl; ctrl_t *ctrl;
if( !parent ) if( !parent )
@ -126,8 +125,6 @@ int draw_button_cairo(button_t *btn)
ctx = btn->ctrl.ctx; ctx = btn->ctrl.ctx;
lock_bitmap(ctx->pixmap);
x = btn->ctrl.rc.l - ctx->offset_x; x = btn->ctrl.rc.l - ctx->offset_x;
y = btn->ctrl.rc.t - ctx->offset_y; y = btn->ctrl.rc.t - ctx->offset_y;
@ -259,8 +256,6 @@ int draw_progress(progress_t *prg, int background)
ctx = prg->ctrl.ctx; ctx = prg->ctrl.ctx;
lock_bitmap(ctx->pixmap);
x = prg->ctrl.rc.l - ctx->offset_x; x = prg->ctrl.rc.l - ctx->offset_x;
y = prg->ctrl.rc.t - ctx->offset_y; y = prg->ctrl.rc.t - ctx->offset_y;
@ -268,32 +263,31 @@ int draw_progress(progress_t *prg, int background)
{ {
src = res_progress_bar; src = res_progress_bar;
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(i=0; i < 10; i++)
{ {
for(j = 0; j < len; j++) for(j = 0; j < len; j++)
pixmap[j] = *src; pixmap[j] = *src;
pixmap+= ctx->pixmap->pitch/4; pixmap+= ctx->pixmap_pitch/4;
src++; src++;
}; };
}; };
len = prg->current*prg->ctrl.w/(prg->max - prg->min); len = prg->current*prg->ctrl.w/(prg->max - prg->min);
src = res_prg_level; src = res_prg_level;
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 < prg->ctrl.h ;i++) for(i=0; i < prg->ctrl.h ;i++)
{ {
for(j=0; j < len; j++) for(j=0; j < len; j++)
pixmap[j] = *src; pixmap[j] = *src;
pixmap+= ctx->pixmap->pitch/4; pixmap+= ctx->pixmap_pitch/4;
src++; src++;
}; };
@ -353,8 +347,8 @@ progress_t *create_progress(char *caption, int id, int x, int y,
int draw_level(level_t *lvl) int draw_level(level_t *lvl)
{ {
int *pixmap; int *pixmap;
ctx_t *ctx; ctx_t *ctx;
int i, j; int i, j;
int x, y; int x, y;
@ -363,8 +357,6 @@ int draw_level(level_t *lvl)
ctx = lvl->ctrl.ctx; ctx = lvl->ctrl.ctx;
lock_bitmap(ctx->pixmap);
x = lvl->ctrl.rc.l - ctx->offset_x; x = lvl->ctrl.rc.l - ctx->offset_x;
y = lvl->ctrl.rc.t - ctx->offset_y; y = lvl->ctrl.rc.t - ctx->offset_y;
@ -377,15 +369,15 @@ int draw_level(level_t *lvl)
if(len > 96) if(len > 96)
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(i=0; i < 10; i++)
{ {
for(j = 0; j < 96; j++) for(j = 0; j < 96; j++)
pixmap[j] = 0xFF1C1C1C; 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); 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) int lvl_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{ {
level_t *lvl = (level_t*)ctrl; level_t *lvl = (level_t*)ctrl;
// int pos;
switch( msg ) 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 draw_slider(slider_t *sld)
{ {
int *pixmap; int *pixmap;
ctx_t *ctx; ctx_t *ctx;
int i, j; int i, j;
int x, y; int x, y;
@ -454,25 +445,22 @@ int draw_slider(slider_t *sld)
ctx = sld->ctrl.ctx; ctx = sld->ctrl.ctx;
lock_bitmap(ctx->pixmap);
x = sld->ctrl.rc.l - ctx->offset_x; x = sld->ctrl.rc.l - ctx->offset_x;
y = sld->ctrl.rc.t - ctx->offset_y; y = sld->ctrl.rc.t - ctx->offset_y;
len = 96 + 12; len = 96 + 12;
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 < 11; i++) for(i=0; i < 11; i++)
{ {
for(j = 0; j < len; j++) for(j = 0; j < len; j++)
pixmap[j] = 0xFF1C1C1C; 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, 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); blit_raw(ctx, res_slider, x+sld->pos, y, 12, 11, 12*4);
return 0; return 0;

View File

@ -44,19 +44,8 @@ int init_caption(window_t *win)
cpt->text = win->caption_txt; cpt->text = win->caption_txt;
cpt->bitmap.width = 1920; ctx->pixmap_data = user_alloc(1920*CAPTION_HEIGHT*4);
cpt->bitmap.height = CAPTION_HEIGHT; ctx->pixmap_pitch= 1920*4;
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->offset_x = 0; ctx->offset_x = 0;
ctx->offset_y = 0; ctx->offset_y = 0;
@ -92,10 +81,9 @@ int init_caption(window_t *win)
void update_caption_size(window_t *win) void update_caption_size(window_t *win)
{ {
caption_t *cpt = &win->caption; caption_t *cpt = &win->caption;
bitmap_t *bitmap = &cpt->bitmap; ctx_t *ctx = &cpt->ctx;
bitmap->width = win->w; ctx->pixmap_pitch = win->w * 4;
resize_bitmap(bitmap);
cpt->ctrl.rc.l = 0; cpt->ctrl.rc.l = 0;
cpt->ctrl.rc.t = 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.l = win->w - 27 - 18 -18 - 5 - 5;
cpt->full_btn->ctrl.rc.r = cpt->full_btn->ctrl.rc.l + cpt->full_btn->ctrl.rc.r = cpt->full_btn->ctrl.rc.l +
cpt->full_btn->ctrl.w; cpt->full_btn->ctrl.w;
}; };
extern int win_font; extern int win_font;
void draw_caption(caption_t *cpt) void draw_caption(caption_t *cpt)
{ {
int *pixmap, *src; ctx_t *ctx = &cpt->ctx;
rect_t rc; int *pixmap, *src;
int i, j, w; rect_t rc;
int i, j, w;
lock_bitmap(&cpt->bitmap); blit_raw(ctx, res_caption_left, 0, 0,
blit_raw(&cpt->ctx, res_caption_left, 0, 0,
CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4); CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4);
w = cpt->ctrl.w - (2*CAPTION_CORNER_W); w = cpt->ctrl.w - (2*CAPTION_CORNER_W);
if( w > 0) if( w > 0)
{ {
pixmap = (int*)cpt->ctx.pixmap->data; pixmap = (int*)ctx->pixmap_data;
pixmap+= CAPTION_CORNER_W; pixmap+= CAPTION_CORNER_W;
src = res_caption_body; src = res_caption_body;
@ -144,16 +129,11 @@ void draw_caption(caption_t *cpt)
{ {
for(j = 0; j < w; j++) for(j = 0; j < w; j++)
pixmap[j] = src[i]; 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(ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0,
blit_raw(&cpt->ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0,
CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4); CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4);
rc.l = 8; 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.r = cpt->ctrl.w - 27 - 18 - 18 - 5 - 5 - 8;
rc.b = 18; 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; ctrl_t *child;
child = (ctrl_t*)cpt->ctrl.child.next; 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__, // printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); // 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, 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); cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.pixmap_pitch);
}; };

View File

@ -1,7 +1,7 @@
#ifndef __CONTROL_H__ #ifndef __CONTROL_H__
#define __CONTROL_H_ #define __CONTROL_H_
#include <pixlib2.h> #include <pixlib3.h>
#include "link.h" #include "link.h"
typedef struct typedef struct
@ -14,9 +14,10 @@ typedef struct
typedef struct ctx typedef struct ctx
{ {
bitmap_t *pixmap; int offset_x;
int offset_x; int offset_y;
int offset_y; int *pixmap_data;
int pixmap_pitch;
}ctx_t; }ctx_t;
ctx_t *get_window_ctx(); ctx_t *get_window_ctx();

View File

@ -23,7 +23,7 @@ typedef unsigned int color_t;
unsigned int ansi2utf32(unsigned char ch); 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 *dst;
uint8_t *src, *tmpsrc; 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; uint32_t *tmpdst;
int i, j; int i, j;
dst = win->data + dsty * win->pitch + dstx*4; dst = pixmap + dsty * pitch + dstx*4;
src = bitmap->buffer; src = bitmap->buffer;
for( i = 0; i < bitmap->rows; i++ ) 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; tmpdst = (uint32_t*)dst;
tmpsrc = src; tmpsrc = src;
dst+= win->pitch; dst+= pitch;
src+= bitmap->pitch; src+= bitmap->pitch;
for( j = 0; j < bitmap->width; j++) 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_UInt glyph_index;
FT_Bool use_kerning = 0; 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 ) if ( err )
continue; continue;
my_draw_bitmap(winbitmap, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left, my_draw_bitmap(pixmap, pitch, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left,
y - face->glyph->bitmap_top, color); y - face->glyph->bitmap_top, color);
x += face->glyph->advance.x; x += face->glyph->advance.x;
previous = glyph_index; previous = glyph_index;

View File

@ -67,8 +67,12 @@ void init_frame(window_t *win)
extern int res_border_left[]; extern int res_border_left[];
extern int res_border_right[]; extern int res_border_right[];
#if 0
int draw_frame(window_t *win) int draw_frame(window_t *win)
{ {
void *pixmap_data;
uint32_t pixmap_pitch;
int *pixmap, *src; int *pixmap, *src;
int i, j; int i, j;
@ -124,6 +128,8 @@ int draw_frame(window_t *win)
return 0; return 0;
}; };
#endif
int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{ {

View File

@ -53,17 +53,7 @@ int init_panel(window_t *win)
panel->layout = 0; panel->layout = 0;
panel->bitmap.width = 1920; ctx->pixmap_data = user_alloc(1920*PANEL_HEIGHT*4);
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->offset_x = 0; ctx->offset_x = 0;
ctx->offset_y = 0; ctx->offset_y = 0;
@ -100,8 +90,6 @@ int init_panel(window_t *win)
// btn->img_hilite = res_minimize_btn_hl; // btn->img_hilite = res_minimize_btn_hl;
// btn->img_pressed = res_minimize_btn_pressed; // btn->img_pressed = res_minimize_btn_pressed;
update_panel_size(win); update_panel_size(win);
return 1; return 1;
@ -156,11 +144,9 @@ void panel_set_layout(panel_t *panel, int layout)
void update_panel_size(window_t *win) void update_panel_size(window_t *win)
{ {
panel_t *panel = &win->panel; panel_t *panel = &win->panel;
bitmap_t *bitmap = &panel->bitmap;
bitmap->width = win->w; panel->ctx.pixmap_pitch = win->w*4;
resize_bitmap(bitmap);
panel->ctx.offset_x = 0; panel->ctx.offset_x = 0;
panel->ctx.offset_y = win->h-PANEL_HEIGHT; panel->ctx.offset_y = win->h-PANEL_HEIGHT;
@ -200,19 +186,17 @@ void update_panel_size(window_t *win)
void draw_panel(panel_t *panel) void draw_panel(panel_t *panel)
{ {
ctx_t *ctx = &panel->ctx;
int *pixmap, *src; int *pixmap, *src;
int i, j, w; int i, j, w;
lock_bitmap(&panel->bitmap); blit_raw(ctx, res_panel_left, 0, 0,
blit_raw(&panel->ctx, res_panel_left, 0, 0,
PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4); PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4);
w = panel->ctrl.w - (2*PANEL_CORNER_W); w = panel->ctrl.w - (2*PANEL_CORNER_W);
if( w > 0) if( w > 0)
{ {
pixmap = (int*)panel->ctx.pixmap->data; pixmap = (int*)ctx->pixmap_data;
pixmap+= PANEL_CORNER_W; pixmap+= PANEL_CORNER_W;
src = res_panel_body; src = res_panel_body;
@ -220,7 +204,7 @@ void draw_panel(panel_t *panel)
{ {
for(j = 0; j < w; j++) for(j = 0; j < w; j++)
pixmap[j] = src[i]; pixmap[j] = src[i];
pixmap+= panel->ctx.pixmap->pitch/4; pixmap+= ctx->pixmap_pitch/4;
} }
}; };
@ -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) void blit_panel(panel_t *panel)
{ {
// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, ctx_t *ctx = &panel->ctx;
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
lock_bitmap(&panel->bitmap); Blit(ctx->pixmap_data, panel->draw.l, panel->draw.t,
Blit(panel->ctx.pixmap->data, panel->draw.l, panel->draw.t,
0, 0, panel->ctrl.w, panel->ctrl.h, 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);
}; };

View File

@ -79,7 +79,7 @@ window_t *create_window(char *caption, int style, int x, int y,
if(handler==0) return 0; if(handler==0) return 0;
BeginDraw(); BeginDraw();
DrawWindow(x, y, w-1, h-1, DrawWindow(x, y, w, h,
NULL,0,0x41); NULL,0,0x41);
EndDraw(); EndDraw();
@ -213,13 +213,14 @@ static int draw_window(window_t *win)
void blit_client(window_t *win) void blit_client(window_t *win)
{ {
ctx_t *ctx = &win->ctx;
int w, h; int w, h;
w = win->client.r - win->client.l; w = win->client.r - win->client.l;
h = win->client.b - win->client.t; h = win->client.b - win->client.t;
Blit(win->ctx->pixmap->data, win->client.l, win->client.t, Blit(ctx->pixmap_data, win->client.l, win->client.t,
0, 0, w, h, w, h,win->ctx->pixmap->pitch); 0, 0, w, h, w, h, ctx->pixmap_pitch);
}; };
@ -366,7 +367,6 @@ void do_sys_draw(window_t *win)
BeginDraw(); BeginDraw();
DrawWindow(0,0,0,0, NULL, 0x000000,0x41); DrawWindow(0,0,0,0, NULL, 0x000000,0x41);
// DefineButton(15, 15, 0x00000001, 0);
EndDraw(); EndDraw();
send_message((ctrl_t*)win, MSG_DRAW_CLIENT, 0, 0); send_message((ctrl_t*)win, MSG_DRAW_CLIENT, 0, 0);
@ -628,6 +628,8 @@ void init_winlib(void)
void update_rect(ctrl_t *ctrl) void update_rect(ctrl_t *ctrl)
{ {
ctx_t *ctx = ctrl->ctx;
int ctx_w, ctx_h; int ctx_w, ctx_h;
int src_x, src_y; int src_x, src_y;
@ -637,36 +639,12 @@ void update_rect(ctrl_t *ctrl)
ctx_w = ctrl->parent->w; ctx_w = ctrl->parent->w;
ctx_h = ctrl->parent->h; ctx_h = ctrl->parent->h;
Blit(ctrl->ctx->pixmap->data, ctrl->rc.l, ctrl->rc.t, src_x, src_y, Blit(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); ctrl->w, ctrl->h, ctx_w, ctx_h, ctx->pixmap_pitch);
// need_update++; // 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 *get_child(ctrl_t *ctrl, int x, int y)
{ {
ctrl_t *child = NULL; ctrl_t *child = NULL;

View File

@ -36,7 +36,6 @@ typedef struct
{ {
ctrl_t ctrl; ctrl_t ctrl;
ctx_t ctx; ctx_t ctx;
bitmap_t bitmap;
char *text; char *text;
ctrl_t *child_over; ctrl_t *child_over;
@ -50,7 +49,6 @@ typedef struct
{ {
ctrl_t ctrl; ctrl_t ctrl;
ctx_t ctx; ctx_t ctx;
bitmap_t bitmap;
rect_t draw; rect_t draw;
ctrl_t *child_over; ctrl_t *child_over;
int layout; int layout;
@ -73,7 +71,7 @@ typedef struct
handler_t *handler; handler_t *handler;
ctrl_t *parent; ctrl_t *parent;
ctx_t *ctx; ctx_t ctx;
uint32_t id; uint32_t id;
uint32_t style; uint32_t style;
@ -84,10 +82,6 @@ typedef struct
rect_t saved; rect_t saved;
rect_t client; rect_t client;
// ctx_t client_ctx;
// bitmap_t bitmap;
bitmap_t bitmap;
char *caption_txt; char *caption_txt;
ctrl_t *child_over; ctrl_t *child_over;
ctrl_t *child_focus; ctrl_t *child_focus;