/programs/media/Fplay/fplay.c |
---|
61,13 → 61,18 |
int main( int argc, char *argv[]) |
{ |
int i; |
char *file_name, *dot; |
if(argc < 2) { |
if(argc < 2) |
{ |
movie_file = get_moviefile(); |
if(movie_file == NULL) |
{ |
printf("Please provide a movie file\n"); |
return -1; |
} |
movie_file = argv[1]; |
} |
else movie_file = argv[1]; |
/* register all codecs, demux and protocols */ |
av_log_set_level(AV_LOG_FATAL); |
76,9 → 81,9 |
avdevice_register_all(); |
av_register_all(); |
if( avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) < 0) |
if( avformat_open_input(&pFormatCtx, movie_file, NULL, NULL) < 0) |
{ |
printf("Cannot open file %s\n\r", argv[1]); |
printf("Cannot open file %s\n\r", movie_file); |
return -1; // Couldn't open file |
}; |
91,6 → 96,17 |
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,4 → 1,6 |
#include "pixlib2.h" |
#define BLACK_MAGIC_SOUND |
#define BLACK_MAGIC_VIDEO |
5,15 → 7,6 |
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) |
177,18 → 170,8 |
}; |
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(); |
#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(); |
/programs/media/Fplay/pixlib2.c |
---|
1,23 → 1,9 |
#include <stdint.h> |
//#include <libavcodec/avcodec.h> |
//#include <libavformat/avformat.h> |
//#include <libswscale/swscale.h> |
#include <stdio.h> |
//#include <fcntl.h> |
#include "../winlib/winlib.h" |
//#include "fplay.h" |
#include <pixlib2.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 |
32,24 → 18,13 |
#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; |
114,11 → 89,8 |
return retval; |
}; |
#define BUFFER_SIZE(n) ((n)*sizeof(uint32_t)) |
uint32_t InitPixlib(uint32_t caps) |
uint32_t init_pixlib(uint32_t caps) |
{ |
uint32_t api_version; |
uint32_t screensize; |
187,7 → 159,7 |
{ |
// __asm__ __volatile__("int3"); |
if( blit_caps & HW_BIT_BLIT ) |
if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
{ |
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ |
{ |
232,7 → 204,6 |
// bitmap->handle, bitmap->pitch, bitmap->data); |
return 0; |
}; |
return err; |
}; |
uint32_t size; |
248,6 → 219,7 |
bitmap->handle = 0; |
bitmap->pitch = pitch; |
bitmap->data = buffer; |
bitmap->flags = 0; |
return 0; |
}; |
261,7 → 233,7 |
// __asm__ __volatile__("int3"); |
int err = 0; |
if( blit_caps & HW_BIT_BLIT ) |
if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
{ |
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ |
{ |
302,7 → 274,7 |
{ |
int err; |
if( blit_caps & HW_BIT_BLIT ) |
if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
{ |
/* |
369,7 → 341,7 |
{ |
// __asm__ __volatile__("int3"); |
if( blit_caps & HW_BIT_BLIT ) |
if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
{ |
struct __attribute__((packed)) |
{ |
/programs/media/Fplay/system.h |
---|
186,7 → 186,7 |
} |
static inline |
void draw_text(const char *text, int x, int y, int len, color_t color) |
void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
/programs/media/Fplay/utils.c |
---|
97,3 → 97,21 |
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 = InitPixlib(flags); |
render->caps = init_pixlib(flags); |
mutex_unlock(&driver_lock); |
if(render->caps==0) |
616,6 → 616,7 |
{ |
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 ) |
{ |
632,6 → 633,7 |
{ |
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/ISTOKWEB.TTF |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/media/Fplay/winlib/Istok SIL OFL Font License 1.1.txt |
---|
0,0 → 1,94 |
Copyright (c) 2008-2011, Andrey V. Panov (panov@canopus.iacp.dvo.ru), |
with Reserved Font Name "Istok". |
This Font Software is licensed under the SIL Open Font License, Version 1.1. |
This license is copied below, and is also available with a FAQ at: |
http://scripts.sil.org/OFL |
----------------------------------------------------------- |
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 |
----------------------------------------------------------- |
PREAMBLE |
The goals of the Open Font License (OFL) are to stimulate worldwide |
development of collaborative font projects, to support the font creation |
efforts of academic and linguistic communities, and to provide a free and |
open framework in which fonts may be shared and improved in partnership |
with others. |
The OFL allows the licensed fonts to be used, studied, modified and |
redistributed freely as long as they are not sold by themselves. The |
fonts, including any derivative works, can be bundled, embedded, |
redistributed and/or sold with any software provided that any reserved |
names are not used by derivative works. The fonts and derivatives, |
however, cannot be released under any other type of license. The |
requirement for fonts to remain under this license does not apply |
to any document created using the fonts or their derivatives. |
DEFINITIONS |
"Font Software" refers to the set of files released by the Copyright |
Holder(s) under this license and clearly marked as such. This may |
include source files, build scripts and documentation. |
"Reserved Font Name" refers to any names specified as such after the |
copyright statement(s). |
"Original Version" refers to the collection of Font Software components as |
distributed by the Copyright Holder(s). |
"Modified Version" refers to any derivative made by adding to, deleting, |
or substituting -- in part or in whole -- any of the components of the |
Original Version, by changing formats or by porting the Font Software to a |
new environment. |
"Author" refers to any designer, engineer, programmer, technical |
writer or other person who contributed to the Font Software. |
PERMISSION & CONDITIONS |
Permission is hereby granted, free of charge, to any person obtaining |
a copy of the Font Software, to use, study, copy, merge, embed, modify, |
redistribute, and sell modified and unmodified copies of the Font |
Software, subject to the following conditions: |
1) Neither the Font Software nor any of its individual components, |
in Original or Modified Versions, may be sold by itself. |
2) Original or Modified Versions of the Font Software may be bundled, |
redistributed and/or sold with any software, provided that each copy |
contains the above copyright notice and this license. These can be |
included either as stand-alone text files, human-readable headers or |
in the appropriate machine-readable metadata fields within text or |
binary files as long as those fields can be easily viewed by the user. |
3) No Modified Version of the Font Software may use the Reserved Font |
Name(s) unless explicit written permission is granted by the corresponding |
Copyright Holder. This restriction only applies to the primary font name as |
presented to the users. |
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font |
Software shall not be used to promote, endorse or advertise any |
Modified Version, except to acknowledge the contribution(s) of the |
Copyright Holder(s) and the Author(s) or with their explicit written |
permission. |
5) The Font Software, modified or unmodified, in part or in whole, |
must be distributed entirely under this license, and must not be |
distributed under any other license. The requirement for fonts to |
remain under this license does not apply to any document created |
using the Font Software. |
TERMINATION |
This license becomes null and void if any of the above conditions are |
not met. |
DISCLAIMER |
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE |
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL |
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM |
OTHER DEALINGS IN THE FONT SOFTWARE. |
/programs/media/Fplay/winlib/button.c |
---|
3,6 → 3,7 |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include <stdio.h> |
#include "winlib.h" |
extern int res_level[]; |
120,9 → 121,8 |
int draw_button_cairo(button_t *btn) |
{ |
int *pixmap, *src; |
int *src; |
ctx_t *ctx; |
int i, j; |
int x, y; |
ctx = btn->ctrl.ctx; |
130,10 → 130,6 |
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) |
141,13 → 137,7 |
else if(btn->state & bHighlight) |
src = btn->img_hilite; |
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; |
}; |
blit_raw(ctx, src, x, y, btn->ctrl.w, btn->ctrl.h, btn->ctrl.w*4); |
return 0; |
}; |
262,6 → 252,7 |
ctx_t *ctx; |
int i, j; |
int x, y; |
rect_t rc = prg->ctrl.rc; |
int len = prg->ctrl.w; |
274,8 → 265,8 |
{ |
src = res_progress_bar; |
pixmap = ctx->pixmap; |
pixmap+= y * ctx->stride/4 + x; |
pixmap = (int*)ctx->pixmap->data; |
pixmap+= y * ctx->pixmap->pitch/4 + x; |
for(i=0; i < 10; i++) |
{ |
282,7 → 273,7 |
for(j = 0; j < len; j++) |
pixmap[j] = *src; |
pixmap+= ctx->stride/4; |
pixmap+= ctx->pixmap->pitch/4; |
src++; |
}; |
}; |
292,14 → 283,14 |
src = res_prg_level; |
pixmap = ctx->pixmap; |
pixmap+= y*ctx->stride/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->stride/4; |
pixmap+= ctx->pixmap->pitch/4; |
src++; |
}; |
359,7 → 350,7 |
int draw_level(level_t *lvl) |
{ |
int *pixmap, *src; |
int *pixmap; |
ctx_t *ctx; |
int i, j; |
int x, y; |
381,37 → 372,19 |
if(len > 96) |
len = 96; |
pixmap = ctx->pixmap; |
pixmap = (int*)ctx->pixmap->data; |
pixmap+= y*ctx->stride/4 + x; |
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->stride/4; |
// }; |
src = lvl->img_level; |
for(i=0; i < 10; i++) |
{ |
for(j = 0; j < 96; j++) |
pixmap[j] = 0xFF1C1C1C; |
pixmap+= ctx->stride/4; |
pixmap+= ctx->pixmap->pitch/4; |
}; |
pixmap = ctx->pixmap; |
pixmap+= y*ctx->stride/4 + x; |
blit_raw(ctx, lvl->img_level, x, y, len, 10, 96*4); |
for(i=0; i < 10; i++) |
{ |
for(j = 0; j < len; j++) |
pixmap[j] = src[j]; |
pixmap+= ctx->stride/4; |
src+= 96; |
}; |
return 0; |
}; |
466,7 → 439,7 |
int draw_slider(slider_t *sld) |
{ |
int *pixmap, *src; |
int *pixmap; |
ctx_t *ctx; |
int i, j; |
int x, y; |
479,45 → 452,22 |
x = sld->ctrl.rc.l - ctx->offset_x; |
y = sld->ctrl.rc.t - ctx->offset_y; |
len = 96 + 12; |
pixmap = ctx->pixmap; |
pixmap+= y*ctx->stride/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->stride/4; |
pixmap+= ctx->pixmap->pitch/4; |
}; |
pixmap = ctx->pixmap; |
pixmap+= (y+4)*ctx->stride/4 + x + 6; |
blit_raw(ctx, sld->img_vol_slider, x+6, y+4, 96, 4, 96*4); |
src = sld->img_vol_slider; |
blit_raw(ctx, res_slider, x+sld->pos, y, 12, 11, 12*4); |
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,16 → 41,19 |
cpt->text = win->caption_txt; |
ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4); |
if(!ctx->pixmap) |
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->stride = win->w*4; |
ctx->pixmap = &cpt->bitmap; |
ctx->offset_x = 0; |
ctx->offset_y = 0; |
79,23 → 82,25 |
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 stride; |
int pitch; |
old_size = cpt->ctx.stride * CAPTION_HEIGHT; |
old_size = bitmap->pitch * bitmap->height; |
old_size = (old_size+4095) & ~4095; |
stride = win->w*4; |
pitch = ALIGN(win->w*4, 16); |
new_size = stride * CAPTION_HEIGHT; |
new_size = pitch * CAPTION_HEIGHT; |
new_size = (new_size+4095) & ~4095; |
if( new_size < old_size) |
user_unmap(cpt->ctx.pixmap, new_size, old_size-new_size); |
user_unmap(bitmap->data, new_size, old_size-new_size); |
cpt->ctx.stride = stride; |
bitmap->width = win->w; |
bitmap->pitch = pitch; |
cpt->ctrl.rc.l = 0; |
cpt->ctrl.rc.t = 0; |
115,14 → 120,6 |
}; |
typedef struct |
{ |
uint32_t width; |
uint32_t height; |
uint32_t pitch; |
uint32_t handle; |
uint8_t *data; |
}bitmap_t; |
extern int win_font; |
129,23 → 126,16 |
void draw_caption(caption_t *cpt) |
{ |
int *pixmap, *src; |
rect_t rc; |
int i, j, w; |
pixmap = cpt->ctx.pixmap; |
src = res_caption_left; |
blit_raw(&cpt->ctx, res_caption_left, 0, 0, |
CAPTION_CORNER_W, CAPTION_HEIGHT, CAPTION_CORNER_W*4); |
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 = cpt->ctx.pixmap; |
pixmap = (int*)cpt->ctx.pixmap->data; |
pixmap+= CAPTION_CORNER_W; |
src = res_caption_body; |
153,30 → 143,26 |
{ |
for(j = 0; j < w; j++) |
pixmap[j] = src[i]; |
pixmap+= cpt->ctx.stride/4; |
pixmap+= cpt->ctx.pixmap->pitch/4; |
} |
}; |
pixmap = cpt->ctx.pixmap; |
pixmap+= cpt->ctrl.w - CAPTION_CORNER_W; |
// blit_raw(&cpt->ctx,res_caption_body, CAPTION_CORNER_W, 0, |
// w, CAPTION_HEIGHT, 0); |
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; |
bitmap.data = cpt->ctx.pixmap; |
bitmap.pitch = cpt->ctx.stride; |
blit_raw(&cpt->ctx,res_caption_right, cpt->ctrl.w - CAPTION_CORNER_W, 0, |
CAPTION_CORNER_W, CAPTION_HEIGHT,CAPTION_CORNER_W*4); |
draw_text(&bitmap, win_font, cpt->text, 8, 18, 0xFFFFFFFF); |
rc.l = 8; |
rc.t = 0; |
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; |
child = (ctrl_t*)cpt->ctrl.child.next; |
261,7 → 247,7 |
// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, |
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); |
Blit(cpt->ctx.pixmap, 0, 0, 0, 0, cpt->ctrl.w, cpt->ctrl.h, |
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); |
}; |
/programs/media/Fplay/winlib/control.h |
---|
1,6 → 1,7 |
#ifndef __CONTROL_H__ |
#define __CONTROL_H_ |
#include <pixlib2.h> |
#include "link.h" |
typedef struct |
13,8 → 14,7 |
typedef struct ctx |
{ |
void *pixmap; |
int stride; |
bitmap_t *pixmap; |
int offset_x; |
int offset_y; |
}ctx_t; |
201,4 → 201,10 |
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,22 → 4,25 |
#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> |
typedef unsigned int color_t; |
extern char res_def_font[]; |
typedef struct |
{ |
uint32_t width; |
uint32_t height; |
uint32_t pitch; |
uint32_t handle; |
uint8_t *data; |
}bitmap_t; |
int l; |
int t; |
int r; |
int b; |
}rect_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; |
65,12 → 68,12 |
}; |
int draw_text(bitmap_t * winbitmap, FT_Face face, char *text, int x, int y, int color) |
int draw_text_ext(bitmap_t *winbitmap, FT_Face face, char *text, rect_t *rc, int color) |
{ |
FT_UInt glyph_index; |
FT_Bool use_kerning = 0; |
FT_UInt previous; |
int x, y, w; |
char ch; |
int err = 0; |
77,11 → 80,14 |
use_kerning = FT_HAS_KERNING( face ); |
previous = 0; |
x <<= 6; |
x = rc->l << 6; |
y = rc->b; |
w = (rc->r - rc->l) << 6; |
while( ch = *text++ ) |
{ |
glyph_index = FT_Get_Char_Index( face, ch ); |
glyph_index = FT_Get_Char_Index( face, ansi2utf32(ch) ); |
if ( use_kerning && previous && glyph_index ) |
{ |
90,6 → 96,9 |
x += delta.x ; |
} |
if( x + face->glyph->advance.x > w) |
break; |
err = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT ); |
if ( err ) |
continue; |
108,6 → 117,7 |
return err; |
}; |
int init_fontlib() |
{ |
int err; |
122,9 → 132,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, pdf_font_DroidSans, 139280, 0, &face ); |
err = FT_New_Memory_Face( library, res_def_font, 277996, 0, &face ); |
if ( err == FT_Err_Unknown_File_Format ) |
{ |
printf("font format is unsupported\n"); |
138,7 → 148,7 |
} |
err = FT_Set_Char_Size( face, 0, 12*64, 96, 96 ); |
err = FT_Set_Char_Size( face, 0, 11*64, 96, 96 ); |
// err = FT_Set_Pixel_Sizes( face, 0, 100 ); |
done: |
148,3 → 158,26 |
// 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,8 → 77,7 |
frame_t *fr = &win->frame; |
pixmap = win->ctx->pixmap; |
pixmap = (int*)win->ctx->pixmap->data; |
pixmap+= CAPTION_HEIGHT*win->w; |
src = res_border_left; |
87,11 → 86,11 |
for(j = 0; j < FRAME_WIDTH; j++) |
pixmap[j] = src[j]; |
pixmap+= win->ctx->stride/4; |
pixmap+= win->ctx->pixmap->pitch/4; |
}; |
pixmap = win->ctx->pixmap; |
pixmap = (int*)win->ctx->pixmap->data; |
pixmap+= (CAPTION_HEIGHT+1)*win->w - FRAME_WIDTH; |
src = res_border_right; |
100,10 → 99,10 |
for(j = 0; j < FRAME_WIDTH; j++) |
pixmap[j] = src[j]; |
pixmap+= win->ctx->stride/4; |
pixmap+= win->ctx->pixmap->pitch/4; |
}; |
pixmap = win->ctx->pixmap; |
pixmap = (int*)win->ctx->pixmap->data; |
pixmap+= fr->bottom.t * win->w; |
112,7 → 111,7 |
for(j = 0; j < win->w; j++) |
pixmap[j] = 0x808080; |
pixmap+= win->ctx->stride/4; |
pixmap+= win->ctx->pixmap->pitch/4; |
}; |
ctrl_t *child; |
/programs/media/Fplay/winlib/logo.raw |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/media/Fplay/winlib/panel.c |
---|
54,16 → 54,20 |
panel->layout = 0; |
ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4); |
if(!ctx->pixmap) |
panel->bitmap.width = 1920; |
panel->bitmap.height = PANEL_HEIGHT; |
panel->bitmap.flags = 0; |
if( create_bitmap(&panel->bitmap) ) |
{ |
printf("not enough memory for caption bitmap\n"); |
printf("not enough memory for panel bitmap\n"); |
return 0; |
}; |
} |
// printf("win_w %d win_h %d\n", win->w, win->h); |
ctx->pixmap = &panel->bitmap; |
ctx->offset_x = 0; |
ctx->offset_y = 0; |
ctx->stride = win->w*4; |
panel->ctrl.ctx = ctx; |
btn = create_button(NULL, ID_PLAY,0,19,32,32,&panel->ctrl); |
154,23 → 158,26 |
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 stride; |
int pitch; |
old_size = panel->ctx.stride * PANEL_HEIGHT; |
old_size = bitmap->pitch * bitmap->height; |
old_size = (old_size+4095) & ~4095; |
stride = win->w*4; |
pitch = ALIGN(win->w*4, 16); |
new_size = stride * PANEL_HEIGHT; |
new_size = pitch * PANEL_HEIGHT; |
new_size = (new_size+4095) & ~4095; |
if( new_size < old_size) |
user_unmap(panel->ctx.pixmap, new_size, old_size-new_size); |
user_unmap(bitmap->data, new_size, old_size-new_size); |
panel->ctx.stride = stride; |
bitmap->width = win->w; |
bitmap->pitch = pitch; |
panel->ctx.offset_x = 0; |
panel->ctx.offset_y = win->h-PANEL_HEIGHT; |
212,21 → 219,14 |
int *pixmap, *src; |
int i, j, w; |
pixmap = panel->ctx.pixmap; |
src = res_panel_left; |
blit_raw(&panel->ctx, res_panel_left, 0, 0, |
PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4); |
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 = panel->ctx.pixmap; |
pixmap = (int*)panel->ctx.pixmap->data; |
pixmap+= PANEL_CORNER_W; |
src = res_panel_body; |
234,29 → 234,20 |
{ |
for(j = 0; j < w; j++) |
pixmap[j] = src[i]; |
pixmap+= panel->ctx.stride/4; |
pixmap+= panel->ctx.pixmap->pitch/4; |
} |
}; |
pixmap = panel->ctx.pixmap; |
pixmap+= panel->ctrl.w - PANEL_CORNER_W; |
blit_raw(&panel->ctx, res_panel_right, panel->ctrl.w - PANEL_CORNER_W, 0, |
PANEL_CORNER_W, PANEL_HEIGHT, PANEL_CORNER_W*4); |
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, 1, 0, 0); |
send_message(child, MSG_PAINT, 0, 0); |
child = (ctrl_t*)child->link.next; |
}; |
}; |
328,8 → 319,8 |
// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, |
// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); |
Blit(panel->ctx.pixmap, 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, |
panel->ctrl.w, panel->ctrl.h, panel->ctx.stride); |
panel->ctrl.w, panel->ctrl.h, panel->ctx.pixmap->pitch); |
}; |
/programs/media/Fplay/winlib/res2.asm |
---|
43,6 → 43,7 |
public _res_progress_bar |
public _res_prg_level |
public _res_def_font |
section '.rdata' data readable align 16 |
87,3 → 88,5 |
_res_progress_bar: file 'pbar.raw' |
_res_prg_level: file 'prg_level.raw' |
_res_def_font: file 'IstokWeb.ttf' |
/programs/media/Fplay/winlib/resource.h |
---|
0,0 → 1,10 |
#ifndef IDC_STATIC |
#define IDC_STATIC (-1) |
#endif |
#define IDI_CURSOR1 100 |
#define IDR_MENU1 101 |
#define IDD_DIALOG1 102 |
#define IDD_DIALOG2 103 |
#define IDOK 1000 |
#define IDCANCEL 1001 |
/programs/media/Fplay/winlib/system.h |
---|
0,0 → 1,326 |
#include <newlib.h> |
#include <stdint.h> |
#include <stddef.h> |
#ifdef CONFIG_DEBUF |
#define DBG(format,...) printf(format,##__VA_ARGS__) |
#else |
#define DBG(format,...) |
#endif |
typedef unsigned int color_t; |
typedef union __attribute__((packed)) |
{ |
uint32_t val; |
struct |
{ |
short x; |
short y; |
}; |
}pos_t; |
typedef union __attribute__((packed)) |
{ |
uint32_t val; |
struct |
{ |
uint8_t state; |
uint8_t code; |
uint16_t ctrl_key; |
}; |
}oskey_t; |
static inline |
void BeginDraw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(1)); |
}; |
static inline |
void EndDraw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(2)); |
}; |
static inline void DrawWindow(int x, int y, int w, int h, char *name, |
color_t workcolor, uint32_t style) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(0), |
"b"((x << 16) | (w & 0xFFFF)), |
"c"((y << 16) | (h & 0xFFFF)), |
"d"((style << 24) | (workcolor & 0xFFFFFF)), |
"D"(name)); |
}; |
static inline |
pos_t get_mouse_pos(void) |
{ |
pos_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(1)); |
return val; |
} |
static inline |
pos_t get_cursor_pos(void) |
{ |
pos_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(0)); |
return val; |
} |
static inline |
uint32_t get_mouse_buttons(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(2)); |
return val; |
}; |
static inline |
uint32_t get_mouse_wheels(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(7)); |
return val; |
}; |
static inline |
uint32_t wait_for_event(uint32_t time) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(23), "b"(time)); |
return val; |
}; |
static inline uint32_t check_os_event() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(11)); |
return val; |
}; |
static inline |
uint32_t get_tick_count(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(26),"b"(9)); |
return val; |
}; |
static inline |
oskey_t get_key(void) |
{ |
oskey_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(2)); |
return val; |
} |
static inline |
void draw_line(int xs, int ys, int xe, int ye, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(38), "d"(color), |
"b"((xs << 16) | xe), |
"c"((ys << 16) | ye)); |
} |
static inline |
void draw_bar(int x, int y, int w, int h, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(13), "d"(color), |
"b"((x << 16) | w), |
"c"((y << 16) | h)); |
} |
static inline |
void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(7), "b"(bitmap), |
"c"((w << 16) | h), |
"d"((x << 16) | y)); |
} |
#if 0 |
static inline |
void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(4),"d"(text), |
"b"((x << 16) | y), |
"S"(len),"c"(color)); |
} |
#endif |
static inline |
void *user_alloc(size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(mem)); |
return val; |
} |
static inline |
int *user_unmap(void *base, size_t offset, size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
return val; |
} |
/* |
extern inline |
void exit(int status) __attribute__((noreturn)) ; |
extern inline |
void exit(int status) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(-1)); |
for(;;); |
} |
*/ |
static inline |
uint32_t load_cursor(void *path, uint32_t flags) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37), "b"(4), "c"(path), "d"(flags)); |
return val; |
} |
static inline |
uint32_t set_cursor(uint32_t cursor) |
{ |
uint32_t old; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(old) |
:"a"(37), "b"(5), "c"(cursor)); |
return old; |
} |
static inline |
int destroy_cursor(uint32_t cursor) |
{ |
int ret; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(ret) |
:"a"(37), "b"(6), "c"(cursor) |
:"memory"); |
return ret; |
}; |
static inline void get_proc_info(char *info) |
{ |
__asm__ __volatile__( |
"int $0x40" |
: |
:"a"(9), "b"(info), "c"(-1)); |
} |
static inline |
void* user_realloc(void *mem, size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size),"d"(mem) |
:"memory"); |
return val; |
} |
void *load_file(const char *path, size_t *len); |
void *get_resource(void *data, uint32_t id); |
struct blit_call |
{ |
int dstx; |
int dsty; |
int w; |
int h; |
int srcx; |
int srcy; |
int srcw; |
int srch; |
unsigned char *bitmap; |
int stride; |
}; |
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); |
/programs/media/Fplay/winlib/window.c |
---|
63,15 → 63,20 |
list_initialize(&Window.link); |
list_initialize(&Window.child); |
ctx->pixmap = user_alloc(1280*1024*4); |
if(!ctx->pixmap) |
Window.bitmap.width = 1920; |
Window.bitmap.height = 1080; |
Window.bitmap.flags = 0; |
if( create_bitmap(&Window.bitmap) ) |
{ |
printf("not enough memory for context bitmap\n"); |
return NULL; |
}; |
printf("not enough memory for window bitmap\n"); |
return 0; |
} |
stride = w*4; |
ctx->stride = stride; |
ctx->pixmap = &Window.bitmap; |
ctx->offset_x = 0; |
ctx->offset_y = 0; |
Window.rc.l = x; |
Window.rc.t = y; |
179,8 → 184,8 |
w = win->client.r - win->client.l; |
h = win->client.b - win->client.t; |
Blit(win->ctx->pixmap, win->client.l, win->client.t, |
0, 0, w, h, w, h,win->ctx->stride); |
Blit(win->ctx->pixmap->data, win->client.l, win->client.t, |
0, 0, w, h, w, h,win->ctx->pixmap->pitch); |
}; |
250,22 → 255,23 |
int old_size; |
int new_size; |
int stride; |
int pitch; |
old_size = win->ctx->stride * win->h; |
old_size = win->bitmap.pitch * win->bitmap.height; |
old_size = (old_size+4095) & ~4095; |
new_size = winw*winh*4; |
pitch = ALIGN(win->w*4, 16); |
new_size = pitch * win->h; |
new_size = (new_size+4095) & ~4095; |
stride = winw*4; |
if( new_size < old_size) |
user_unmap(win->bitmap.data, new_size, old_size-new_size); |
// printf("update win size %d %d\n", winw, winh); |
win->bitmap.width = win->w; |
win->bitmap.pitch = pitch; |
if( new_size < old_size) |
user_unmap(win->ctx->pixmap, new_size, old_size-new_size); |
win->ctx->stride = stride; |
win->rc.r = winx + winw; |
win->rc.b = winy + winh; |
win->w = winw; |
563,8 → 569,8 |
ctx_w = ctrl->parent->w; |
ctx_h = ctrl->parent->h; |
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); |
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); |
// need_update++; |
}; |
/programs/media/Fplay/winlib/winlib.h |
---|
34,6 → 34,7 |
{ |
ctrl_t ctrl; |
ctx_t ctx; |
bitmap_t bitmap; |
char *text; |
ctrl_t *child_over; |
button_t *close_btn; |
45,6 → 46,7 |
{ |
ctrl_t ctrl; |
ctx_t ctx; |
bitmap_t bitmap; |
rect_t draw; |
ctrl_t *child_over; |
int layout; |
74,6 → 76,7 |
rect_t client; |
ctx_t client_ctx; |
bitmap_t bitmap; |
char *caption_txt; |
ctrl_t *child_over; |
123,7 → 126,10 |
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); |