FPlay: intel-2D render frontend
git-svn-id: svn://kolibrios.org@3292 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b1b1064a10
commit
886c9d6c64
149
programs/media/Fplay/OPENDIAL.ASM
Normal file
149
programs/media/Fplay/OPENDIAL.ASM
Normal file
@ -0,0 +1,149 @@
|
||||
format MS COFF
|
||||
|
||||
public _get_moviefile
|
||||
|
||||
section '.text' align 16
|
||||
|
||||
align 4
|
||||
getprocaddress:
|
||||
mov edx, [esp + 8] ; hlib
|
||||
xor eax, eax
|
||||
test edx, edx ; If hlib = 0 then goto .end
|
||||
jz .end
|
||||
|
||||
.next:
|
||||
cmp [edx], dword 0 ; If end of export table then goto .end
|
||||
jz .end
|
||||
|
||||
xor eax, eax
|
||||
mov esi, [edx]
|
||||
mov edi, [esp + 4] ; name
|
||||
|
||||
.next_:
|
||||
lodsb
|
||||
scasb
|
||||
jne .fail
|
||||
or al, al
|
||||
jnz .next_
|
||||
jmp .ok
|
||||
.fail:
|
||||
add edx, 8
|
||||
jmp .next
|
||||
|
||||
.ok: ; return address
|
||||
mov eax, [edx + 4]
|
||||
.end:
|
||||
ret 8
|
||||
|
||||
|
||||
|
||||
align 8
|
||||
_get_moviefile:
|
||||
|
||||
pushad
|
||||
mov eax, 68
|
||||
mov ebx, 19
|
||||
mov ecx, sz_proc_lib
|
||||
int 0x40
|
||||
mov [proclib], eax
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
push [proclib]
|
||||
push sz_OpenDialog_init
|
||||
call getprocaddress
|
||||
mov [opendialog_init], eax
|
||||
|
||||
push dword[proclib]
|
||||
push sz_OpenDialog_start
|
||||
call getprocaddress
|
||||
mov [opendialog_start], eax
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
mov ecx, 4096*3
|
||||
int 0x40
|
||||
|
||||
mov [od.procinfo], eax
|
||||
|
||||
add eax, 1024
|
||||
mov [od.filename_area], eax
|
||||
|
||||
add eax, 3072
|
||||
mov [od.opendir_path], eax
|
||||
|
||||
add eax, 4096
|
||||
mov [od.openfile_path], eax
|
||||
|
||||
push od
|
||||
call [opendialog_init]
|
||||
|
||||
mov eax, [od.openfile_path]
|
||||
mov [eax], byte 0 ; end of ASCIIZ-string(may be don't need?)
|
||||
|
||||
push od
|
||||
call [opendialog_start]
|
||||
|
||||
popad
|
||||
mov eax, [od.openfile_path]; selected filePath
|
||||
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
fake_on_redraw:
|
||||
ret
|
||||
|
||||
section '.rdata' align 16
|
||||
|
||||
sz_proc_lib db "/rd/1/lib/proc_lib.obj",0
|
||||
sz_OpenDialog_init db "OpenDialog_init",0
|
||||
sz_OpenDialog_start db "OpenDialog_start",0
|
||||
sz_com_area_name db "FFFFFFFF_open_dialog",0
|
||||
sz_dir_default_path db "/rd/1",0
|
||||
sz_start_path db "/rd/1/File managers/opendial",0
|
||||
|
||||
|
||||
section '.data' align 16
|
||||
|
||||
od:
|
||||
.mode dd 0
|
||||
.procinfo dd 0
|
||||
.com_area_name dd sz_com_area_name
|
||||
.com_area dd 0
|
||||
.opendir_path dd 0
|
||||
.dir_default_path dd sz_dir_default_path
|
||||
.start_path dd sz_start_path
|
||||
.draw_window dd fake_on_redraw
|
||||
.status dd 0
|
||||
.openfile_path dd 0
|
||||
.filename_area dd 0
|
||||
.filter_area dd filefilter
|
||||
.x_size dw 512
|
||||
.x_start dw 512
|
||||
.y_size dw 512
|
||||
.y_start dw 512
|
||||
|
||||
filefilter:
|
||||
dd filefilter.end - filefilter
|
||||
db 'avi',0
|
||||
db 'flv',0
|
||||
db 'mov',0
|
||||
db 'mpg',0
|
||||
db 'mpeg',0
|
||||
db 'mkv',0
|
||||
db 'mp4',0
|
||||
db 'webm',0
|
||||
db 'wmv',0
|
||||
.end:
|
||||
db 0
|
||||
|
||||
|
||||
section '.bssd' align 16
|
||||
|
||||
proclib dd ?
|
||||
opendialog_init dd ?
|
||||
opendialog_start dd ?
|
||||
|
@ -299,16 +299,16 @@ int audio_thread(void *param)
|
||||
|
||||
for(i = 0, val = 0; i < samples/2; i++, src++)
|
||||
if(val < abs(*src))
|
||||
val= abs(*src); // * *src;
|
||||
val= abs(*src); // * *src;
|
||||
|
||||
sound_level_0 = val; //sqrt(val / (samples/2));
|
||||
|
||||
|
||||
for(i = 0, val = 0; i < samples/2; i++, src++)
|
||||
if(val < abs(*src))
|
||||
val= abs(*src); // * *src;
|
||||
val= abs(*src); // * *src;
|
||||
|
||||
sound_level_1 = val; //sqrt(val / (samples/2));
|
||||
|
||||
|
||||
// printf("%d\n", sound_level);
|
||||
};
|
||||
|
||||
|
@ -106,12 +106,11 @@ int get_packet(queue_t *q, AVPacket *pkt);
|
||||
extern astream_t astream;
|
||||
extern AVRational video_time_base;
|
||||
|
||||
render_t *create_render(uint32_t width, uint32_t height,
|
||||
uint32_t ctx_format, uint32_t flags);
|
||||
|
||||
render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags);
|
||||
void destroy_render(render_t *render);
|
||||
int init_render(render_t *render, int width, int height);
|
||||
void render_adjust_size(render_t *render, window_t *win);
|
||||
int render_set_size(render_t *render, int width, int height);
|
||||
void render_set_size(render_t *render, int width, int height);
|
||||
void render_draw_client(render_t *render);
|
||||
|
||||
|
||||
|
@ -23,6 +23,16 @@
|
||||
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
|
||||
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
|
||||
|
||||
int sna_init(uint32_t service);
|
||||
void sna_fini();
|
||||
|
||||
int sna_create_bitmap(bitmap_t *bitmap);
|
||||
void sna_destroy_bitmap(bitmap_t *bitmap);
|
||||
void sna_lock_bitmap(bitmap_t *bitmap);
|
||||
int sna_blit_copy(bitmap_t *src_bitmap, int dst_x, int dst_y,
|
||||
int w, int h, int src_x, int src_y);
|
||||
int sna_blit_tex(bitmap_t *src_bitmap, int dst_x, int dst_y,
|
||||
int w, int h, int src_x, int src_y);
|
||||
|
||||
|
||||
static uint32_t service;
|
||||
@ -41,7 +51,6 @@ typedef struct
|
||||
}ioctl_t;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t idx;
|
||||
@ -121,6 +130,7 @@ uint32_t init_pixlib(uint32_t caps)
|
||||
(DISPLAY_VERSION < (api_version >> 16)))
|
||||
goto fail;
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Let's see what this service can do
|
||||
*/
|
||||
@ -145,8 +155,16 @@ uint32_t init_pixlib(uint32_t caps)
|
||||
(blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"",
|
||||
(blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"",
|
||||
(blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":"");
|
||||
#endif
|
||||
|
||||
blit_caps&= caps;
|
||||
blit_caps = caps & sna_init(service);
|
||||
|
||||
if( blit_caps )
|
||||
printf("service caps %s%s%s\n",
|
||||
(blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"",
|
||||
(blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"",
|
||||
(blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":"");
|
||||
|
||||
return blit_caps;
|
||||
|
||||
fail:
|
||||
@ -154,62 +172,28 @@ fail:
|
||||
return 0;
|
||||
};
|
||||
|
||||
void done_pixlib()
|
||||
{
|
||||
|
||||
sna_fini();
|
||||
|
||||
};
|
||||
|
||||
|
||||
int create_bitmap(bitmap_t *bitmap)
|
||||
{
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
|
||||
{
|
||||
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */
|
||||
{
|
||||
uint32_t handle; // ignored
|
||||
void *data; // ignored
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t pitch; // ignored
|
||||
|
||||
uint32_t max_width;
|
||||
uint32_t max_height;
|
||||
uint32_t format; // reserved mbz
|
||||
}io_10;
|
||||
|
||||
ioctl_t io;
|
||||
int err;
|
||||
|
||||
// printf("create bitmap %d x %d\n",
|
||||
// bitmap->width, bitmap->height);
|
||||
|
||||
io_10.width = bitmap->width;
|
||||
io_10.height = bitmap->height;
|
||||
io_10.max_width = screen_width;
|
||||
io_10.max_height = screen_height;
|
||||
io_10.format = 0;
|
||||
|
||||
io.handle = service;
|
||||
io.io_code = SRV_CREATE_SURFACE;
|
||||
io.input = &io_10;
|
||||
io.inp_size = BUFFER_SIZE(8);
|
||||
io.output = NULL;
|
||||
io.out_size = 0;
|
||||
|
||||
err = call_service(&io);
|
||||
if(err==0)
|
||||
{
|
||||
bitmap->handle = io_10.handle;
|
||||
bitmap->pitch = io_10.pitch;
|
||||
bitmap->data = io_10.data;
|
||||
// printf("Create hardware surface %x pitch %d, buffer %x\n",
|
||||
// bitmap->handle, bitmap->pitch, bitmap->data);
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
|
||||
uint32_t size;
|
||||
uint32_t pitch;
|
||||
uint8_t *buffer;
|
||||
|
||||
if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT ))
|
||||
return sna_create_bitmap(bitmap);
|
||||
|
||||
// if( bitmap->flags && blit_caps & HW_BIT_BLIT )
|
||||
// return sna_create_bitmap(bitmap);
|
||||
|
||||
pitch = ALIGN(bitmap->width*4, 16);
|
||||
size = pitch * bitmap->height;
|
||||
|
||||
@ -226,47 +210,24 @@ int create_bitmap(bitmap_t *bitmap)
|
||||
printf("Cannot alloc frame buffer\n\r");
|
||||
|
||||
return -1;
|
||||
|
||||
};
|
||||
|
||||
int destroy_bitmap(bitmap_t *bitmap)
|
||||
{
|
||||
if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT ))
|
||||
sna_destroy_bitmap(bitmap);
|
||||
return 0;
|
||||
};
|
||||
|
||||
int lock_bitmap(bitmap_t *bitmap)
|
||||
{
|
||||
// __asm__ __volatile__("int3");
|
||||
int err = 0;
|
||||
|
||||
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
|
||||
{
|
||||
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */
|
||||
{
|
||||
uint32_t handle;
|
||||
void *data;
|
||||
uint32_t pitch;
|
||||
if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT ))
|
||||
sna_lock_bitmap(bitmap);
|
||||
|
||||
}io_12;
|
||||
|
||||
ioctl_t io;
|
||||
|
||||
io_12.handle = bitmap->handle;
|
||||
io_12.pitch = 0;
|
||||
io_12.data = 0;
|
||||
|
||||
io.handle = service;
|
||||
io.io_code = SRV_LOCK_SURFACE;
|
||||
io.input = &io_12;
|
||||
io.inp_size = BUFFER_SIZE(3);
|
||||
io.output = NULL;
|
||||
io.out_size = 0;
|
||||
|
||||
err = call_service(&io);
|
||||
if(err==0)
|
||||
{
|
||||
bitmap->pitch = io_12.pitch;
|
||||
bitmap->data = io_12.data;
|
||||
// printf("Lock hardware surface %x pitch %d, buffer %x\n",
|
||||
// bitmap->handle, bitmap->pitch, bitmap->data);
|
||||
};
|
||||
};
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
};
|
||||
|
||||
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||
@ -274,46 +235,9 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||
{
|
||||
int err;
|
||||
|
||||
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
|
||||
{
|
||||
if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT ) )
|
||||
return sna_blit_tex(bitmap, dst_x, dst_y, w, h, 0, 0);
|
||||
|
||||
/*
|
||||
* Now you will experience the full power of the dark side...
|
||||
*/
|
||||
|
||||
struct __attribute__((packed))
|
||||
{
|
||||
uint32_t handle;
|
||||
int dst_x;
|
||||
int dst_y;
|
||||
int src_x;
|
||||
int src_y;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
}io_15;
|
||||
|
||||
ioctl_t io;
|
||||
|
||||
io_15.handle = bitmap->handle;
|
||||
io_15.dst_x = dst_x;
|
||||
io_15.dst_y = dst_y;
|
||||
io_15.src_x = 0;
|
||||
io_15.src_y = 0;
|
||||
io_15.w = w;
|
||||
io_15.h = h;
|
||||
|
||||
io.handle = service;
|
||||
io.io_code = SRV_BLIT_BITMAP;
|
||||
io.input = &io_15;
|
||||
io.inp_size = BUFFER_SIZE(7);
|
||||
io.output = NULL;
|
||||
io.out_size = 0;
|
||||
|
||||
// printf("do blit %x pitch %d\n",bitmap->handle,
|
||||
// bitmap->pitch);
|
||||
err = call_service(&io);
|
||||
return err;
|
||||
};
|
||||
|
||||
struct blit_call bc;
|
||||
|
||||
|
@ -68,17 +68,6 @@ int init_video(AVCodecContext *ctx)
|
||||
width = ctx->width;
|
||||
height = ctx->height;
|
||||
|
||||
printf("w = %d h = %d\n\r", ctx->width, ctx->height);
|
||||
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
main_render = create_render(ctx->width, ctx->height,
|
||||
ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT);
|
||||
if( main_render == NULL)
|
||||
{
|
||||
printf("Cannot create render\n\r");
|
||||
return 0;
|
||||
};
|
||||
|
||||
Frame = avcodec_alloc_frame();
|
||||
if ( Frame == NULL )
|
||||
@ -229,7 +218,11 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
||||
{
|
||||
case MSG_SIZE:
|
||||
//printf("MSG_SIZE\n");
|
||||
render_adjust_size(main_render, win);
|
||||
if(main_render)
|
||||
{
|
||||
render_adjust_size(main_render, win);
|
||||
render_draw_client(main_render);
|
||||
};
|
||||
break;
|
||||
|
||||
case MSG_DRAW_CLIENT:
|
||||
@ -494,8 +487,9 @@ extern char *movie_file;
|
||||
|
||||
int video_thread(void *param)
|
||||
{
|
||||
window_t *MainWindow;
|
||||
|
||||
AVCodecContext *ctx = param;
|
||||
window_t *MainWindow;
|
||||
|
||||
init_winlib();
|
||||
|
||||
MainWindow = create_window(movie_file,0,
|
||||
@ -504,15 +498,23 @@ int video_thread(void *param)
|
||||
MainWindow->panel.prg->max = stream_duration;
|
||||
// printf("MainWindow %x\n", MainWindow);
|
||||
|
||||
main_render->win = MainWindow;
|
||||
|
||||
show_window(MainWindow, NORMAL);
|
||||
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
main_render = create_render(MainWindow, ctx, HW_BIT_BLIT|HW_TEX_BLIT);
|
||||
if( main_render == NULL)
|
||||
{
|
||||
printf("Cannot create render\n\r");
|
||||
return 0;
|
||||
};
|
||||
|
||||
render_draw_client(main_render);
|
||||
player_state = PLAY;
|
||||
|
||||
run_render(MainWindow, main_render);
|
||||
|
||||
destroy_render(main_render);
|
||||
fini_winlib();
|
||||
|
||||
player_state = CLOSED;
|
||||
@ -523,40 +525,129 @@ int video_thread(void *param)
|
||||
void draw_hw_picture(render_t *render, AVPicture *picture);
|
||||
void draw_sw_picture(render_t *render, AVPicture *picture);
|
||||
|
||||
render_t *create_render(uint32_t width, uint32_t height,
|
||||
uint32_t ctx_format, uint32_t flags)
|
||||
render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags)
|
||||
{
|
||||
render_t *render;
|
||||
|
||||
uint32_t right, bottom, draw_w, draw_h;
|
||||
uint32_t s, sw, sh;
|
||||
uint8_t state;
|
||||
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
render = (render_t*)malloc(sizeof(render_t));
|
||||
memset(render, 0, sizeof(render_t));
|
||||
|
||||
render->ctx_width = width;
|
||||
render->ctx_height = height;
|
||||
render->ctx_format = ctx_format;
|
||||
render->win = win;
|
||||
|
||||
render->ctx_width = ctx->width;
|
||||
render->ctx_height = ctx->height;
|
||||
render->ctx_format = ctx->pix_fmt;
|
||||
|
||||
mutex_lock(&driver_lock);
|
||||
render->caps = init_pixlib(flags);
|
||||
mutex_unlock(&driver_lock);
|
||||
|
||||
right = win->w;
|
||||
bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
|
||||
|
||||
// printf("window width %d height %d\n",
|
||||
// right, bottom);
|
||||
|
||||
render->win_state = win->win_state;
|
||||
|
||||
draw_w = bottom*render->ctx_width/render->ctx_height;
|
||||
draw_h = right*render->ctx_height/render->ctx_width;
|
||||
|
||||
if(draw_w > right)
|
||||
{
|
||||
draw_w = right;
|
||||
draw_h = right*render->ctx_height/render->ctx_width;
|
||||
};
|
||||
|
||||
if(draw_h > bottom)
|
||||
{
|
||||
draw_h = bottom;
|
||||
draw_w = bottom*render->ctx_width/render->ctx_height;
|
||||
};
|
||||
|
||||
render->win_width = win->w;
|
||||
render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
|
||||
|
||||
render_set_size(render, draw_w, draw_h);
|
||||
|
||||
|
||||
if(render->caps==0)
|
||||
{
|
||||
printf("FPlay render engine: Hardware acceleration disabled\n");
|
||||
render->bitmap[0].width = draw_w;
|
||||
render->bitmap[0].height = draw_h;
|
||||
|
||||
if( create_bitmap(&render->bitmap[0]) != 0 )
|
||||
{
|
||||
free(render);
|
||||
return NULL;
|
||||
}
|
||||
render->draw = draw_sw_picture;
|
||||
}
|
||||
else
|
||||
{
|
||||
int width, height, flags;
|
||||
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 )
|
||||
{
|
||||
player_state = CLOSED;
|
||||
free(render);
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
|
||||
render->state = INIT;
|
||||
render->target = 0;
|
||||
render->draw = draw_hw_picture;
|
||||
};
|
||||
|
||||
render->state = EMPTY;
|
||||
|
||||
printf("FPlay %s render engine: context %dx%d picture %dx%d\n",
|
||||
render->caps==0 ? "software":"hardware",
|
||||
render->ctx_width, render->ctx_height,
|
||||
draw_w, draw_h);
|
||||
|
||||
return render;
|
||||
};
|
||||
|
||||
int render_set_size(render_t *render, int width, int height)
|
||||
void destroy_render(render_t *render)
|
||||
{
|
||||
|
||||
destroy_bitmap(&render->bitmap[0]);
|
||||
|
||||
if(render->caps & (HW_BIT_BLIT|HW_TEX_BLIT)) /* hw blitter */
|
||||
destroy_bitmap(&render->bitmap[1]);
|
||||
|
||||
done_pixlib();
|
||||
};
|
||||
|
||||
void render_set_size(render_t *render, int width, int height)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -607,49 +698,6 @@ int render_set_size(render_t *render, int width, int height)
|
||||
render->layout |= HAS_RIGHT;
|
||||
}
|
||||
};
|
||||
|
||||
if(render->state == EMPTY)
|
||||
{
|
||||
if(render->caps & HW_TEX_BLIT)
|
||||
{
|
||||
for( i=0; i < 4; i++)
|
||||
{
|
||||
render->bitmap[i].width = render->ctx_width;
|
||||
render->bitmap[i].height = render->ctx_height;
|
||||
render->bitmap[i].flags = HW_TEX_BLIT;
|
||||
|
||||
if( create_bitmap(&render->bitmap[i]) != 0 )
|
||||
{
|
||||
player_state = CLOSED;
|
||||
/*
|
||||
* Epic fail. Need exit_thread() here
|
||||
*
|
||||
*/
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
render->bitmap[0].width = width;
|
||||
render->bitmap[0].height = height;
|
||||
render->bitmap[0].flags = HW_BIT_BLIT;
|
||||
|
||||
if( create_bitmap(&render->bitmap[0]) != 0 )
|
||||
return 0;
|
||||
};
|
||||
render->state = INIT;
|
||||
return 0;
|
||||
};
|
||||
|
||||
if(render->caps & HW_TEX_BLIT) /* hw scaler */
|
||||
return 0;
|
||||
|
||||
render->bitmap[0].width = width;
|
||||
render->bitmap[0].height = height;
|
||||
resize_bitmap(&render->bitmap[0]);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
void render_adjust_size(render_t *render, window_t *win)
|
||||
@ -693,6 +741,21 @@ void render_adjust_size(render_t *render, window_t *win)
|
||||
render->win_width = win->w;
|
||||
render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
|
||||
render_set_size(render, new_w, new_h);
|
||||
|
||||
if(render->caps & HW_TEX_BLIT) /* hw scaler */
|
||||
return;
|
||||
|
||||
render->bitmap[0].width = new_w;
|
||||
render->bitmap[0].height = new_h;
|
||||
resize_bitmap(&render->bitmap[0]);
|
||||
|
||||
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]);
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
void draw_hw_picture(render_t *render, AVPicture *picture)
|
||||
@ -703,8 +766,8 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
|
||||
int linesize[4];
|
||||
int ret;
|
||||
|
||||
if(render->win_state == MINIMIZED ||
|
||||
render->win_state == ROLLED)
|
||||
if(render->win->win_state == MINIMIZED ||
|
||||
render->win->win_state == ROLLED)
|
||||
return;
|
||||
|
||||
if(render->caps & HW_TEX_BLIT)
|
||||
@ -760,8 +823,8 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
|
||||
// printf("blit_bitmap\n");
|
||||
|
||||
|
||||
// render->target++;
|
||||
// render->target&= 3;
|
||||
render->target++;
|
||||
render->target&= 1;
|
||||
}
|
||||
|
||||
void draw_sw_picture(render_t *render, AVPicture *picture)
|
||||
@ -769,8 +832,8 @@ void draw_sw_picture(render_t *render, AVPicture *picture)
|
||||
uint8_t *data[4];
|
||||
int linesize[4];
|
||||
|
||||
if(render->win_state == MINIMIZED ||
|
||||
render->win_state == ROLLED)
|
||||
if(render->win->win_state == MINIMIZED ||
|
||||
render->win->win_state == ROLLED)
|
||||
return;
|
||||
|
||||
cvt_ctx = sws_getCachedContext(cvt_ctx,
|
||||
@ -784,6 +847,8 @@ void draw_sw_picture(render_t *render, AVPicture *picture)
|
||||
return ;
|
||||
}
|
||||
|
||||
lock_bitmap(&render->bitmap[0]);
|
||||
|
||||
data[0] = render->bitmap[0].data;
|
||||
data[1] = render->bitmap[0].data+1;
|
||||
data[2] = render->bitmap[0].data+2;
|
||||
|
@ -160,7 +160,6 @@ void draw_caption(caption_t *cpt)
|
||||
rc.r = cpt->ctrl.w - 25 - 16 - 5 - 8;
|
||||
rc.b = 18;
|
||||
|
||||
printf(cpt->text);
|
||||
draw_text_ext(cpt->ctx.pixmap, win_font, cpt->text, &rc, 0xFFFFFFFF);
|
||||
|
||||
ctrl_t *child;
|
||||
@ -219,7 +218,6 @@ int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
||||
switch((short)arg1)
|
||||
{
|
||||
case ID_CLOSE:
|
||||
win = (window_t*)ctrl->parent;
|
||||
win->win_command = WIN_CLOSED;
|
||||
break;
|
||||
|
||||
@ -227,6 +225,8 @@ int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
||||
__asm__ __volatile__(
|
||||
"int $0x40"
|
||||
::"a"(18),"b"(10));
|
||||
win->win_state = MINIMIZED;
|
||||
send_message((ctrl_t*)win, MSG_SIZE, 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -52,31 +52,48 @@ void init_frame(window_t *win);
|
||||
window_t *create_window(char *caption, int style, int x, int y,
|
||||
int w, int h, handler_t handler)
|
||||
{
|
||||
char proc_info[1024];
|
||||
int stride;
|
||||
ctx_t *ctx = &Window.client_ctx;
|
||||
|
||||
// __asm__ __volatile__("int3");
|
||||
|
||||
|
||||
// ctx_t *ctx = &Window.client_ctx;
|
||||
|
||||
if(handler==0) return 0;
|
||||
|
||||
BeginDraw();
|
||||
DrawWindow(x, y, w-1, h-1,
|
||||
NULL,0,0x41);
|
||||
EndDraw();
|
||||
|
||||
get_proc_info(proc_info);
|
||||
|
||||
x = *(uint32_t*)(proc_info+34);
|
||||
y = *(uint32_t*)(proc_info+38);
|
||||
w = *(uint32_t*)(proc_info+42)+1;
|
||||
h = *(uint32_t*)(proc_info+46)+1;
|
||||
|
||||
Window.handler = handler;
|
||||
Window.ctx = ctx;
|
||||
// Window.ctx = ctx;
|
||||
|
||||
list_initialize(&Window.link);
|
||||
list_initialize(&Window.child);
|
||||
|
||||
|
||||
Window.bitmap.width = 1920;
|
||||
Window.bitmap.height = 1080;
|
||||
Window.bitmap.flags = 0;
|
||||
// Window.bitmap.width = 1920;
|
||||
// Window.bitmap.height = 1080;
|
||||
// Window.bitmap.flags = 0;
|
||||
|
||||
if( create_bitmap(&Window.bitmap) )
|
||||
{
|
||||
printf("not enough memory for window bitmap\n");
|
||||
return 0;
|
||||
}
|
||||
// if( create_bitmap(&Window.bitmap) )
|
||||
// {
|
||||
// printf("not enough memory for window bitmap\n");
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
ctx->pixmap = &Window.bitmap;
|
||||
ctx->offset_x = 0;
|
||||
ctx->offset_y = 0;
|
||||
// ctx->pixmap = &Window.bitmap;
|
||||
// ctx->offset_x = 0;
|
||||
// ctx->offset_y = 0;
|
||||
|
||||
Window.rc.l = x;
|
||||
Window.rc.t = y;
|
||||
@ -235,12 +252,12 @@ void window_update_layout(window_t *win)
|
||||
win->win_state = ROLLED;
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
if(state & 1)
|
||||
win->win_state = MAXIMIZED;
|
||||
else
|
||||
win->win_state = NORMAL;
|
||||
|
||||
|
||||
if( (winx != win->rc.l) || (winy != win->rc.t) )
|
||||
{
|
||||
win->rc.l = winx;
|
||||
@ -253,6 +270,7 @@ void window_update_layout(window_t *win)
|
||||
winh == win->h)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
int old_size;
|
||||
int new_size;
|
||||
int pitch;
|
||||
@ -271,6 +289,7 @@ void window_update_layout(window_t *win)
|
||||
|
||||
win->bitmap.width = win->w;
|
||||
win->bitmap.pitch = pitch;
|
||||
#endif
|
||||
|
||||
win->rc.r = winx + winw;
|
||||
win->rc.b = winy + winh;
|
||||
@ -553,10 +572,10 @@ void init_winlib(void)
|
||||
list_initialize(&timers);
|
||||
};
|
||||
|
||||
ctx_t *get_window_ctx()
|
||||
{
|
||||
return &Window.client_ctx;
|
||||
};
|
||||
//ctx_t *get_window_ctx()
|
||||
//{
|
||||
// return &Window.client_ctx;
|
||||
//};
|
||||
|
||||
void update_rect(ctrl_t *ctrl)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user