Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 3248 → Rev 3068

/programs/media/Fplay/fplay.c
61,18 → 61,13
int main( int argc, char *argv[])
{
int i;
char *file_name, *dot;
 
if(argc < 2)
{
movie_file = get_moviefile();
if(movie_file == NULL)
{
if(argc < 2) {
printf("Please provide a movie file\n");
return -1;
}
}
else movie_file = argv[1];
 
movie_file = argv[1];
/* register all codecs, demux and protocols */
 
av_log_set_level(AV_LOG_FATAL);
81,9 → 76,9
avdevice_register_all();
av_register_all();
 
if( avformat_open_input(&pFormatCtx, movie_file, NULL, NULL) < 0)
if( avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) < 0)
{
printf("Cannot open file %s\n\r", movie_file);
printf("Cannot open file %s\n\r", argv[1]);
return -1; // Couldn't open file
};
 
96,17 → 91,6
return -1;
};
 
file_name = strrchr(movie_file,'/')+1;
dot = strrchr(file_name,'.');
if(dot)
{
movie_file = malloc(dot-file_name+1);
memcpy(movie_file, file_name, dot-file_name);
movie_file[dot-file_name] = 0;
}
else movie_file = file_name;
 
 
// __asm__ __volatile__("int3");
 
// dump_format(pFormatCtx, 0, argv[1], 0);
/programs/media/Fplay/fplay.h
1,6 → 1,4
 
#include "pixlib2.h"
 
#define BLACK_MAGIC_SOUND
#define BLACK_MAGIC_VIDEO
 
7,6 → 5,15
typedef unsigned int color_t;
typedef unsigned int count_t;
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
typedef struct render render_t;
 
#define HAS_LEFT (1<<0)
170,8 → 177,18
};
 
 
 
 
#define HW_BIT_BLIT (1<<0) /* BGRX blitter */
#define HW_TEX_BLIT (1<<1) /* stretch blit */
#define HW_VID_BLIT (1<<2) /* planar and packed video */
 
uint32_t InitPixlib(uint32_t flags);
 
int create_bitmap(bitmap_t *bitmap);
int lock_bitmap(bitmap_t *bitmap);
int resize_bitmap(bitmap_t *bitmap);
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
int w, int h);
 
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);
char *get_moviefile();
 
/programs/media/Fplay/pixlib2.c
1,9 → 1,23
 
#include <stdint.h>
//#include <libavcodec/avcodec.h>
//#include <libavformat/avformat.h>
//#include <libswscale/swscale.h>
#include <stdio.h>
#include <pixlib2.h>
//#include <fcntl.h>
#include "../winlib/winlib.h"
//#include "fplay.h"
#include "system.h"
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
 
#define DISPLAY_VERSION 0x0200 /* 2.00 */
 
#define SRV_GETVERSION 0
18,13 → 32,24
#define SRV_BLIT_TEXTURE 16
#define SRV_BLIT_VIDEO 17
 
 
#define BUFFER_SIZE(n) ((n)*sizeof(uint32_t))
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
 
 
#define HW_BIT_BLIT (1<<0) /* BGRX blitter */
#define HW_TEX_BLIT (1<<1) /* stretch blit */
#define HW_VID_BLIT (1<<2) /* planar and packed video */
 
uint32_t InitPixlib(uint32_t flags);
 
int create_bitmap(bitmap_t *bitmap);
int lock_bitmap(bitmap_t *bitmap);
int resize_bitmap(bitmap_t *bitmap);
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
int w, int h);
 
 
 
static uint32_t service;
static uint32_t blit_caps;
static uint32_t screen_width;
89,8 → 114,11
return retval;
};
 
#define BUFFER_SIZE(n) ((n)*sizeof(uint32_t))
 
uint32_t init_pixlib(uint32_t caps)
 
 
uint32_t InitPixlib(uint32_t caps)
{
uint32_t api_version;
uint32_t screensize;
159,7 → 187,7
{
// __asm__ __volatile__("int3");
 
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
if( blit_caps & HW_BIT_BLIT )
{
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */
{
204,6 → 232,7
// bitmap->handle, bitmap->pitch, bitmap->data);
return 0;
};
return err;
};
 
uint32_t size;
219,7 → 248,6
bitmap->handle = 0;
bitmap->pitch = pitch;
bitmap->data = buffer;
bitmap->flags = 0;
return 0;
};
 
233,7 → 261,7
// __asm__ __volatile__("int3");
int err = 0;
 
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
if( blit_caps & HW_BIT_BLIT )
{
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */
{
274,7 → 302,7
{
int err;
 
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
if( blit_caps & HW_BIT_BLIT )
{
 
/*
341,7 → 369,7
{
// __asm__ __volatile__("int3");
 
if( bitmap->flags && blit_caps & HW_BIT_BLIT )
if( blit_caps & HW_BIT_BLIT )
{
struct __attribute__((packed))
{
/programs/media/Fplay/system.h
186,7 → 186,7
}
 
static inline
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
void draw_text(const char *text, int x, int y, int len, color_t color)
{
__asm__ __volatile__(
"int $0x40"
/programs/media/Fplay/utils.c
97,21 → 97,3
 
return ret;
}
 
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 *src = raw;
int i, j;
 
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;
src+= pitch/4;
};
};
/programs/media/Fplay/video.c
538,7 → 538,7
render->ctx_format = ctx_format;
 
mutex_lock(&driver_lock);
render->caps = init_pixlib(flags);
render->caps = InitPixlib(flags);
mutex_unlock(&driver_lock);
 
if(render->caps==0)
616,7 → 616,6
{
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 )
{
633,7 → 632,6
{
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;
/programs/media/Fplay/winlib/Istok SIL OFL Font License 1.1.txt
File deleted
/programs/media/Fplay/winlib/resource.h
File deleted
/programs/media/Fplay/winlib/system.h
File deleted
/programs/media/Fplay/winlib/ISTOKWEB.TTF
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/logo.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/button.c
3,7 → 3,6
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "winlib.h"
 
extern int res_level[];
121,8 → 120,9
 
int draw_button_cairo(button_t *btn)
{
int *src;
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
 
ctx = btn->ctrl.ctx;
130,6 → 130,10
x = btn->ctrl.rc.l - ctx->offset_x;
y = btn->ctrl.rc.t - ctx->offset_y;
 
pixmap = ctx->pixmap;
 
pixmap+= y*ctx->stride/4 + x;
 
src = btn->img_default;
 
if(btn->state & bPressed)
137,7 → 141,13
else if(btn->state & bHighlight)
src = btn->img_hilite;
 
blit_raw(ctx, src, x, y, btn->ctrl.w, btn->ctrl.h, btn->ctrl.w*4);
for(i=0; i < btn->ctrl.h ;i++)
{
for(j = 0; j < btn->ctrl.w; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= btn->ctrl.w;
};
 
return 0;
};
252,7 → 262,6
ctx_t *ctx;
int i, j;
int x, y;
rect_t rc = prg->ctrl.rc;
 
int len = prg->ctrl.w;
 
265,8 → 274,8
{
src = res_progress_bar;
 
pixmap = (int*)ctx->pixmap->data;
pixmap+= y * ctx->pixmap->pitch/4 + x;
pixmap = ctx->pixmap;
pixmap+= y * ctx->stride/4 + x;
 
for(i=0; i < 10; i++)
{
273,7 → 282,7
for(j = 0; j < len; j++)
pixmap[j] = *src;
 
pixmap+= ctx->pixmap->pitch/4;
pixmap+= ctx->stride/4;
src++;
};
};
283,14 → 292,14
 
src = res_prg_level;
 
pixmap = (int*)ctx->pixmap->data;
pixmap+= y*ctx->pixmap->pitch/4 + x;
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/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->stride/4;
src++;
};
 
350,7 → 359,7
 
int draw_level(level_t *lvl)
{
int *pixmap;
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
372,19 → 381,37
if(len > 96)
len = 96;
 
pixmap = (int*)ctx->pixmap->data;
pixmap = ctx->pixmap;
 
pixmap+= y*ctx->pixmap->pitch/4 + x;
pixmap+= y*ctx->stride/4 + x;
 
// for(i=0; i < prg->ctrl.h ;i++)
// {
// for(j=0; j < len; j++)
// pixmap[j] = src;
// pixmap+= ctx->stride/4;
// };
 
src = lvl->img_level;
 
for(i=0; i < 10; i++)
{
for(j = 0; j < 96; j++)
pixmap[j] = 0xFF1C1C1C;
pixmap+= ctx->pixmap->pitch/4;
pixmap+= ctx->stride/4;
};
 
blit_raw(ctx, lvl->img_level, x, y, len, 10, 96*4);
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x;
 
for(i=0; i < 10; i++)
{
for(j = 0; j < len; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 96;
};
 
return 0;
};
 
439,7 → 466,7
 
int draw_slider(slider_t *sld)
{
int *pixmap;
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
452,22 → 479,45
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 = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x;
 
for(i=0; i < 11; i++)
{
for(j = 0; j < len; j++)
pixmap[j] = 0xFF1C1C1C;
pixmap+= ctx->pixmap->pitch/4;
pixmap+= ctx->stride/4;
};
 
blit_raw(ctx, sld->img_vol_slider, x+6, y+4, 96, 4, 96*4);
pixmap = ctx->pixmap;
pixmap+= (y+4)*ctx->stride/4 + x + 6;
 
blit_raw(ctx, res_slider, x+sld->pos, y, 12, 11, 12*4);
src = sld->img_vol_slider;
 
for(i = 0; i < 4; i++)
{
for(j = 0; j < 96; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 96;
};
 
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x + sld->pos;
 
src = res_slider;
 
for(i = 0; i < 11; i++)
{
for(j = 0; j < 12; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 12;
};
 
return 0;
};
 
/programs/media/Fplay/winlib/caption.c
41,19 → 41,16
 
cpt->text = win->caption_txt;
 
cpt->bitmap.width = 1920;
cpt->bitmap.height = CAPTION_HEIGHT;
cpt->bitmap.flags = 0;
 
if( create_bitmap(&cpt->bitmap) )
ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4);
if(!ctx->pixmap)
{
printf("not enough memory for caption bitmap\n");
return 0;
}
};
 
// printf("win_w %d win_h %d\n", win->w, win->h);
 
// printf("win_w %d win_h %d\n", win->w, win->h);
ctx->pixmap = &cpt->bitmap;
ctx->stride = win->w*4;
ctx->offset_x = 0;
ctx->offset_y = 0;
 
82,25 → 79,23
void update_caption_size(window_t *win)
{
caption_t *cpt = &win->caption;
bitmap_t *bitmap = cpt->ctx.pixmap;
 
int old_size;
int new_size;
int pitch;
int stride;
 
old_size = bitmap->pitch * bitmap->height;
old_size = cpt->ctx.stride * CAPTION_HEIGHT;
old_size = (old_size+4095) & ~4095;
 
pitch = ALIGN(win->w*4, 16);
stride = win->w*4;
 
new_size = pitch * CAPTION_HEIGHT;
new_size = stride * CAPTION_HEIGHT;
new_size = (new_size+4095) & ~4095;
 
if( new_size < old_size)
user_unmap(bitmap->data, new_size, old_size-new_size);
user_unmap(cpt->ctx.pixmap, new_size, old_size-new_size);
 
bitmap->width = win->w;
bitmap->pitch = pitch;
cpt->ctx.stride = stride;
 
cpt->ctrl.rc.l = 0;
cpt->ctrl.rc.t = 0;
120,6 → 115,14
 
};
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
extern int win_font;
 
126,16 → 129,23
void draw_caption(caption_t *cpt)
{
int *pixmap, *src;
rect_t rc;
int i, j, w;
 
blit_raw(&cpt->ctx, res_caption_left, 0, 0,
CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4);
pixmap = cpt->ctx.pixmap;
src = res_caption_left;
 
for(i=0; i < CAPTION_HEIGHT; i++)
{
for(j=0; j < CAPTION_CORNER_W; j++)
pixmap[j] = src[j];
pixmap+= cpt->ctx.stride/4;
src+= CAPTION_CORNER_W;
};
 
w = cpt->ctrl.w - (2*CAPTION_CORNER_W);
if( w > 0)
{
pixmap = (int*)cpt->ctx.pixmap->data;
pixmap = cpt->ctx.pixmap;
pixmap+= CAPTION_CORNER_W;
src = res_caption_body;
 
143,26 → 153,30
{
for(j = 0; j < w; j++)
pixmap[j] = src[i];
pixmap+= cpt->ctx.pixmap->pitch/4;
pixmap+= cpt->ctx.stride/4;
}
};
 
// blit_raw(&cpt->ctx,res_caption_body, CAPTION_CORNER_W, 0,
// w, CAPTION_HEIGHT, 0);
pixmap = cpt->ctx.pixmap;
pixmap+= cpt->ctrl.w - CAPTION_CORNER_W;
 
src = res_caption_right;
 
for(i = 0; i < CAPTION_HEIGHT; i++)
{
for(j = 0; j < CAPTION_CORNER_W; j++)
pixmap[j] = src[j];
pixmap+= cpt->ctx.stride/4;
src+= CAPTION_CORNER_W;
};
 
bitmap_t bitmap;
 
blit_raw(&cpt->ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0,
CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4);
bitmap.data = cpt->ctx.pixmap;
bitmap.pitch = cpt->ctx.stride;
 
rc.l = 8;
rc.t = 0;
rc.r = cpt->ctrl.w - 25 - 16 - 5 - 8;
rc.b = 18;
draw_text(&bitmap, win_font, cpt->text, 8, 18, 0xFFFFFFFF);
printf(cpt->text);
draw_text_ext(cpt->ctx.pixmap, win_font, cpt->text, &rc, 0xFFFFFFFF);
 
ctrl_t *child;
child = (ctrl_t*)cpt->ctrl.child.next;
 
247,7 → 261,7
// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
 
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, 0, 0, 0, 0, cpt->ctrl.w, cpt->ctrl.h,
cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
};
 
/programs/media/Fplay/winlib/control.h
1,7 → 1,6
#ifndef __CONTROL_H__
#define __CONTROL_H_
 
#include <pixlib2.h>
#include "link.h"
 
typedef struct
14,7 → 13,8
 
typedef struct ctx
{
bitmap_t *pixmap;
void *pixmap;
int stride;
int offset_x;
int offset_y;
}ctx_t;
201,10 → 201,4
 
ctrl_t *capture_mouse(ctrl_t *newm);
 
void blit_raw(ctx_t *ctx, void *raw, int x, int y, int w, int h, int pitch);
 
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
 
 
#endif
/programs/media/Fplay/winlib/fontlib.c
4,25 → 4,22
#include <stdlib.h>
#include <math.h>
#include <memory.h>
//#include "font_droid.h"
#include "font_droid.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <pixlib2.h>
 
extern char res_def_font[];
typedef unsigned int color_t;
 
typedef struct
{
int l;
int t;
int r;
int b;
}rect_t;
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
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)
{
uint8_t *dst;
68,12 → 65,12
};
 
 
int draw_text_ext(bitmap_t *winbitmap, FT_Face face, char *text, rect_t *rc, int color)
int draw_text(bitmap_t * winbitmap, FT_Face face, char *text, int x, int y, int color)
{
FT_UInt glyph_index;
FT_Bool use_kerning = 0;
FT_UInt previous;
int x, y, w;
 
char ch;
int err = 0;
 
80,14 → 77,11
use_kerning = FT_HAS_KERNING( face );
previous = 0;
 
x = rc->l << 6;
y = rc->b;
x <<= 6;
 
w = (rc->r - rc->l) << 6;
 
while( ch = *text++ )
{
glyph_index = FT_Get_Char_Index( face, ansi2utf32(ch) );
glyph_index = FT_Get_Char_Index( face, ch );
 
if ( use_kerning && previous && glyph_index )
{
96,9 → 90,6
x += delta.x ;
}
 
if( x + face->glyph->advance.x > w)
break;
 
err = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
if ( err )
continue;
117,7 → 108,6
return err;
};
 
 
int init_fontlib()
{
int err;
132,9 → 122,9
goto done;
}
 
// err = FT_New_Face( library, "/hd0/1/IstokWeb.ttf", 0, &face );
err = FT_New_Face( library, "/hd0/1/istokweb.ttf", 0, &face );
 
err = FT_New_Memory_Face( library, res_def_font, 277996, 0, &face );
// err = FT_New_Memory_Face( library, pdf_font_DroidSans, 139280, 0, &face );
if ( err == FT_Err_Unknown_File_Format )
{
printf("font format is unsupported\n");
148,7 → 138,7
 
}
 
err = FT_Set_Char_Size( face, 0, 11*64, 96, 96 );
err = FT_Set_Char_Size( face, 0, 12*64, 96, 96 );
// err = FT_Set_Pixel_Sizes( face, 0, 100 );
 
done:
158,26 → 148,3
 
// draw_text(face,"/hd0/1/demo", 10, 80, 0x00000000);
 
 
unsigned int ansi2utf32(unsigned char ch)
{
if(ch < 0x80)
return ch;
 
if(ch < 0xB0)
return 0x410-0x80 + ch;
 
if(ch < 0xE0)
return 0;
 
if(ch < 0xF0)
return 0x440-0xE0 + ch;
 
if(ch == 0xF0)
return 0x401;
else if(ch==0xF1)
return 0x451;
else return 0;
}
 
 
/programs/media/Fplay/winlib/frame.c
77,7 → 77,8
 
frame_t *fr = &win->frame;
 
pixmap = (int*)win->ctx->pixmap->data;
 
pixmap = win->ctx->pixmap;
pixmap+= CAPTION_HEIGHT*win->w;
src = res_border_left;
 
86,11 → 87,11
for(j = 0; j < FRAME_WIDTH; j++)
pixmap[j] = src[j];
 
pixmap+= win->ctx->pixmap->pitch/4;
pixmap+= win->ctx->stride/4;
};
 
 
pixmap = (int*)win->ctx->pixmap->data;
pixmap = win->ctx->pixmap;
pixmap+= (CAPTION_HEIGHT+1)*win->w - FRAME_WIDTH;
src = res_border_right;
 
99,10 → 100,10
for(j = 0; j < FRAME_WIDTH; j++)
pixmap[j] = src[j];
 
pixmap+= win->ctx->pixmap->pitch/4;
pixmap+= win->ctx->stride/4;
};
 
pixmap = (int*)win->ctx->pixmap->data;
pixmap = win->ctx->pixmap;
 
pixmap+= fr->bottom.t * win->w;
 
111,7 → 112,7
for(j = 0; j < win->w; j++)
pixmap[j] = 0x808080;
 
pixmap+= win->ctx->pixmap->pitch/4;
pixmap+= win->ctx->stride/4;
};
 
ctrl_t *child;
/programs/media/Fplay/winlib/panel.c
54,20 → 54,16
 
panel->layout = 0;
panel->bitmap.width = 1920;
panel->bitmap.height = PANEL_HEIGHT;
panel->bitmap.flags = 0;
 
if( create_bitmap(&panel->bitmap) )
ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4);
if(!ctx->pixmap)
{
printf("not enough memory for panel bitmap\n");
printf("not enough memory for caption bitmap\n");
return 0;
}
};
 
ctx->pixmap = &panel->bitmap;
ctx->offset_x = 0;
ctx->offset_y = 0;
// printf("win_w %d win_h %d\n", win->w, win->h);
 
ctx->stride = win->w*4;
panel->ctrl.ctx = ctx;
 
btn = create_button(NULL, ID_PLAY,0,19,32,32,&panel->ctrl);
158,26 → 154,23
void update_panel_size(window_t *win)
{
panel_t *panel = &win->panel;
bitmap_t *bitmap = panel->ctx.pixmap;
 
int old_size;
int new_size;
int pitch;
int stride;
 
old_size = bitmap->pitch * bitmap->height;
old_size = panel->ctx.stride * PANEL_HEIGHT;
old_size = (old_size+4095) & ~4095;
 
pitch = ALIGN(win->w*4, 16);
stride = win->w*4;
 
new_size = pitch * PANEL_HEIGHT;
new_size = stride * PANEL_HEIGHT;
new_size = (new_size+4095) & ~4095;
 
if( new_size < old_size)
user_unmap(bitmap->data, new_size, old_size-new_size);
user_unmap(panel->ctx.pixmap, new_size, old_size-new_size);
 
bitmap->width = win->w;
bitmap->pitch = pitch;
 
panel->ctx.stride = stride;
panel->ctx.offset_x = 0;
panel->ctx.offset_y = win->h-PANEL_HEIGHT;
 
219,14 → 212,21
int *pixmap, *src;
int i, j, w;
 
blit_raw(&panel->ctx, res_panel_left, 0, 0,
PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4);
pixmap = panel->ctx.pixmap;
src = res_panel_left;
 
for(i=0; i < PANEL_HEIGHT; i++)
{
for(j=0; j < PANEL_CORNER_W; j++)
pixmap[j] = src[j];
pixmap+= panel->ctx.stride/4;
src+= PANEL_CORNER_W;
};
 
w = panel->ctrl.w - (2*PANEL_CORNER_W);
if( w > 0)
{
pixmap = (int*)panel->ctx.pixmap->data;
pixmap = panel->ctx.pixmap;
pixmap+= PANEL_CORNER_W;
src = res_panel_body;
 
234,20 → 234,29
{
for(j = 0; j < w; j++)
pixmap[j] = src[i];
pixmap+= panel->ctx.pixmap->pitch/4;
pixmap+= panel->ctx.stride/4;
}
};
 
blit_raw(&panel->ctx, res_panel_right, panel->ctrl.w - PANEL_CORNER_W, 0,
PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4);
pixmap = panel->ctx.pixmap;
pixmap+= panel->ctrl.w - PANEL_CORNER_W;
 
src = res_panel_right;
 
for(i = 0; i < PANEL_HEIGHT; i++)
{
for(j = 0; j < PANEL_CORNER_W; j++)
pixmap[j] = src[j];
pixmap+= panel->ctx.stride/4;
src+= PANEL_CORNER_W;
};
 
ctrl_t *child;
child = (ctrl_t*)panel->ctrl.child.next;
 
while( &child->link != &panel->ctrl.child)
{
send_message(child, MSG_PAINT, 0, 0);
send_message(child, 1, 0, 0);
child = (ctrl_t*)child->link.next;
};
};
319,8 → 328,8
// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__,
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride);
 
Blit(panel->ctx.pixmap->data, panel->draw.l, panel->draw.t,
Blit(panel->ctx.pixmap, 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, panel->ctx.stride);
};
 
/programs/media/Fplay/winlib/res2.asm
43,7 → 43,6
public _res_progress_bar
public _res_prg_level
 
public _res_def_font
 
section '.rdata' data readable align 16
 
88,5 → 87,3
 
_res_progress_bar: file 'pbar.raw'
_res_prg_level: file 'prg_level.raw'
 
_res_def_font: file 'IstokWeb.ttf'
/programs/media/Fplay/winlib/window.c
63,20 → 63,15
list_initialize(&Window.link);
list_initialize(&Window.child);
 
 
Window.bitmap.width = 1920;
Window.bitmap.height = 1080;
Window.bitmap.flags = 0;
 
if( create_bitmap(&Window.bitmap) )
ctx->pixmap = user_alloc(1280*1024*4);
if(!ctx->pixmap)
{
printf("not enough memory for window bitmap\n");
return 0;
}
printf("not enough memory for context bitmap\n");
return NULL;
};
 
ctx->pixmap = &Window.bitmap;
ctx->offset_x = 0;
ctx->offset_y = 0;
stride = w*4;
ctx->stride = stride;
 
Window.rc.l = x;
Window.rc.t = y;
184,8 → 179,8
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(win->ctx->pixmap, win->client.l, win->client.t,
0, 0, w, h, w, h,win->ctx->stride);
};
 
 
255,23 → 250,22
 
int old_size;
int new_size;
int pitch;
int stride;
 
 
old_size = win->bitmap.pitch * win->bitmap.height;
old_size = win->ctx->stride * win->h;
old_size = (old_size+4095) & ~4095;
 
pitch = ALIGN(win->w*4, 16);
 
new_size = pitch * win->h;
new_size = winw*winh*4;
new_size = (new_size+4095) & ~4095;
 
stride = winw*4;
 
// printf("update win size %d %d\n", winw, winh);
 
if( new_size < old_size)
user_unmap(win->bitmap.data, new_size, old_size-new_size);
user_unmap(win->ctx->pixmap, new_size, old_size-new_size);
win->ctx->stride = stride;
 
win->bitmap.width = win->w;
win->bitmap.pitch = pitch;
 
win->rc.r = winx + winw;
win->rc.b = winy + winh;
win->w = winw;
569,8 → 563,8
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(ctrl->ctx->pixmap, ctrl->rc.l, ctrl->rc.t, src_x, src_y,
ctrl->w, ctrl->h, ctx_w, ctx_h, ctrl->ctx->stride);
 
// need_update++;
};
/programs/media/Fplay/winlib/winlib.h
34,7 → 34,6
{
ctrl_t ctrl;
ctx_t ctx;
bitmap_t bitmap;
char *text;
ctrl_t *child_over;
button_t *close_btn;
46,7 → 45,6
{
ctrl_t ctrl;
ctx_t ctx;
bitmap_t bitmap;
rect_t draw;
ctrl_t *child_over;
int layout;
76,7 → 74,6
rect_t client;
 
ctx_t client_ctx;
bitmap_t bitmap;
 
char *caption_txt;
ctrl_t *child_over;
126,10 → 123,7
int w, int h, ctrl_t *parent);
scroller_t *create_scroller(uint32_t style, int id, int x, int y,
int w, int h, ctrl_t *parent);
slider_t *create_slider(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent);
 
 
//static uint32_t update_timers(uint32_t realtime);
 
int set_timer(ctrl_t *ctrl, ostimer_t *timer, uint32_t delay);