cmm: font.h increase performance on 15-20%

git-svn-id: svn://kolibrios.org@6021 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-01-01 16:51:53 +00:00
parent 034b012586
commit 94617c0888
11 changed files with 136 additions and 108 deletions

View File

@ -90,7 +90,7 @@ void TWebBrowser::DrawStyle()
{ {
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x; start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x;
start_y = stroka * list.item_h + body_magrin; start_y = stroka * list.item_h + body_magrin;
stolbec_len = utf8_strlen(#line) * DrawBuf.zoom; stolbec_len = strlen(#line) * DrawBuf.zoom;
line_length = stolbec_len * list.font_w; line_length = stolbec_len * list.font_w;
if (style.h) stroka++; if (style.h) stroka++;
@ -212,7 +212,7 @@ void TWebBrowser::Prepare(){
default: default:
DEFAULT_MARK: DEFAULT_MARK:
if (bukva<=15) bukva=' '; if (bukva<=15) bukva=' ';
line_len = utf8_strlen(#line); line_len = strlen(#line);
if (!style.pre) && (bukva == ' ') if (!style.pre) && (bukva == ' ')
{ {
if (line[line_len-1]==' ') break; //no double spaces if (line[line_len-1]==' ') break; //no double spaces
@ -238,9 +238,9 @@ void TWebBrowser::Perenos()
{ {
int perenos_num; int perenos_num;
char new_line_text[4096]; char new_line_text[4096];
if (utf8_strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return; if (strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return;
perenos_num = strrchr(#line, ' '); perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (utf8_strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom; if (!perenos_num) && (strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom;
strcpy(#new_line_text, #line + perenos_num); strcpy(#new_line_text, #line + perenos_num);
line[perenos_num] = 0x00; line[perenos_num] = 0x00;
DrawStyle(); DrawStyle();

View File

@ -34,11 +34,11 @@ void GetAbsoluteURL(dword in_URL)
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2; IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
if (!http_transfer) if (!http_transfer)
{ {
strcpy(#newurl, History.current()); strcpy(#newurl, history.current());
} }
else else
{ {
strcpy(#newurl, History.items.get(History.active-2)); strcpy(#newurl, history.items.get(history.active-2));
} }
if (ESBYTE[in_URL] == '/') //remove everything after site domain name if (ESBYTE[in_URL] == '/') //remove everything after site domain name

View File

@ -218,14 +218,14 @@ void main()
http_free stdcall (http_transfer); http_free stdcall (http_transfer);
http_transfer=0; http_transfer=0;
GetAbsoluteURL(#URL); GetAbsoluteURL(#URL);
History.back(); history.back();
strcpy(#editURL, #URL); strcpy(#editURL, #URL);
DrawEditBox(); DrawEditBox();
OpenPage(); OpenPage();
} }
else else
{ {
History.add(#URL); history.add(#URL);
ESI = http_transfer; ESI = http_transfer;
bufpointer = ESI.http_msg.content_ptr; bufpointer = ESI.http_msg.content_ptr;
bufsize = ESI.http_msg.content_received; bufsize = ESI.http_msg.content_received;
@ -295,14 +295,14 @@ void Scan(dword id__)
{ {
case SCAN_CODE_BS: case SCAN_CODE_BS:
case BACK_BUTTON: case BACK_BUTTON:
if (History.back()) { if (history.back()) {
strcpy(#URL, History.current()); strcpy(#URL, history.current());
OpenPage(); OpenPage();
} }
return; return;
case FORWARD_BUTTON: case FORWARD_BUTTON:
if (History.forward()) { if (history.forward()) {
strcpy(#URL, History.current()); strcpy(#URL, history.current());
OpenPage(); OpenPage();
} }
return; return;
@ -400,7 +400,7 @@ void OpenPage()
StopLoading(); StopLoading();
souce_mode = false; souce_mode = false;
strcpy(#editURL, #URL); strcpy(#editURL, #URL);
History.add(#URL); history.add(#URL);
if (!strncmp(#URL,"WebView:",8)) if (!strncmp(#URL,"WebView:",8))
{ {
SetPageDefaults(); SetPageDefaults();
@ -498,7 +498,7 @@ void ClickLink()
if (http_transfer > 0) if (http_transfer > 0)
{ {
StopLoading(); StopLoading();
History.back(); history.back();
} }
strcpy(#URL, PageLinks.GetURL(PageLinks.active)); strcpy(#URL, PageLinks.GetURL(PageLinks.active));
@ -506,7 +506,7 @@ void ClickLink()
if (URL[0] == '#') if (URL[0] == '#')
{ {
strcpy(#anchor, #URL+strrchr(#URL, '#')); strcpy(#anchor, #URL+strrchr(#URL, '#'));
strcpy(#URL, History.current()); strcpy(#URL, history.current());
WB1.list.first=WB1.list.count-WB1.list.visible; WB1.list.first=WB1.list.count-WB1.list.visible;
ShowPage(); ShowPage();
return; return;
@ -530,15 +530,15 @@ void ClickLink()
CreateThread(#Downloader,#downloader_stak+4092); CreateThread(#Downloader,#downloader_stak+4092);
} }
else RunProgram("@open", #URL); else RunProgram("@open", #URL);
strcpy(#editURL, History.current()); strcpy(#editURL, history.current());
strcpy(#URL, History.current()); strcpy(#URL, history.current());
return; return;
} }
if (!strncmp(#URL,"mailto:", 7)) if (!strncmp(#URL,"mailto:", 7))
{ {
notify(#URL); notify(#URL);
strcpy(#editURL, History.current()); strcpy(#editURL, history.current());
strcpy(#URL, History.current()); strcpy(#URL, history.current());
return; return;
} }
OpenPage(); OpenPage();

View File

@ -5,15 +5,15 @@ ShowHistory()
int t; int t;
free(history_pointer); free(history_pointer);
history_pointer = malloc(History.items.data_size+256); history_pointer = malloc(history.items.data_size+256);
strcat(history_pointer, "<html><head><title>History</title></head><body><h1>History</h1>"); strcat(history_pointer, "<html><head><title>History</title></head><body><h1>History</h1>");
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>"); strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
for (i=1; i<History.items.count; i++) for (i=1; i<history.items.count; i++)
{ {
strcat(history_pointer, " <a href='"); strcat(history_pointer, " <a href='");
strcat(history_pointer, History.items.get(i)); strcat(history_pointer, history.items.get(i));
strcat(history_pointer, "'>"); strcat(history_pointer, "'>");
strcat(history_pointer, History.items.get(i)); strcat(history_pointer, history.items.get(i));
strcat(history_pointer, "</a><br>"); strcat(history_pointer, "</a><br>");
} }
strcat(history_pointer, "</blockquote><h2>Cached images</h2>"); strcat(history_pointer, "</blockquote><h2>Cached images</h2>");

View File

@ -170,9 +170,9 @@ void main()
{ {
if (dif_x > 150) if (dif_x > 150)
{ {
if (History.forward()) if (history.forward())
{ {
strcpy(#path, History.current()); strcpy(#path, history.current());
files.KeyHome(); files.KeyHome();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
} }
@ -324,9 +324,9 @@ void main()
GoBack(); GoBack();
break; break;
case 22: //Forward case 22: //Forward
if (History.forward()) if (history.forward())
{ {
strcpy(#path, History.current()); strcpy(#path, history.current());
files.KeyHome(); files.KeyHome();
Open_Dir(#path,WITH_REDRAW); Open_Dir(#path,WITH_REDRAW);
} }
@ -743,7 +743,7 @@ void Open_Dir(dword dir_path, redraw){
if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/'); if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
if (errornum) if (errornum)
{ {
History.add(#path); history.add(#path);
GoBack(); GoBack();
Write_Error(errornum); Write_Error(errornum);
return; return;
@ -761,7 +761,7 @@ void Open_Dir(dword dir_path, redraw){
PathShow_prepare stdcall(#PathShow); PathShow_prepare stdcall(#PathShow);
PathShow_draw stdcall(#PathShow); PathShow_draw stdcall(#PathShow);
} }
History.add(#path); history.add(#path);
files.visible = files.h / files.item_h; files.visible = files.h / files.item_h;
if (files.count < files.visible) files.visible = files.count; if (files.count < files.visible) files.visible = files.count;
if (redraw!=ONLY_SHOW) Sorting(); if (redraw!=ONLY_SHOW) Sorting();
@ -999,8 +999,8 @@ inline fastcall void GoBack()
char cur_folder[4096]; char cur_folder[4096];
strcpy(#cur_folder, #path); strcpy(#cur_folder, #path);
cur_folder[strlen(#cur_folder)-1]=0x00; //delete last '/' cur_folder[strlen(#cur_folder)-1]=0x00; //delete last '/'
if (History.back()) { if (history.back()) {
strcpy(#path, History.current()); strcpy(#path, history.current());
SelectFileByName(#cur_folder+strrchr(#cur_folder,'/')); SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
} }
} }

View File

@ -9,6 +9,9 @@
#include "../lib/obj/fs.h" #include "../lib/obj/fs.h"
#endif #endif
#include "../lib/patterns/rgb.h"
#define DEFAULT_FONT "/sys/fonts/Tahoma.kf" #define DEFAULT_FONT "/sys/fonts/Tahoma.kf"
:struct __SIZE :struct __SIZE
@ -211,20 +214,40 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
:void LABEL::apply_smooth() :void LABEL::apply_smooth()
{ {
dword i,line_w,to; dword i,line_w,to;
rgb.DwordToRgb(ShadowPixel(background,2)); //get shadowed pixel
line_w = size.width * 3; line_w = size.width * 3;
to = size.height - 1 * line_w + raw - 3; to = size.height - 1 * line_w + raw - 3;
for(i=raw; i < to; i+=3) for(i=raw; i < to; i+=3)
{ {
if(i-raw%line_w +3 == line_w) continue; if(i-raw%line_w +3 == line_w) continue;
// pixels position, where b - black, w - write
// bw
// wb
if(b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000) if(b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000)
{ {
ShadowImage(i+3, 1, 1, 2); ESBYTE[i+3] = rgb.b;
ShadowImage(i+line_w, 1, 1, 2); ESBYTE[i+4] = rgb.g;
ESBYTE[i+5] = rgb.r;
ESBYTE[i+line_w ] = rgb.b;
ESBYTE[i+line_w+1] = rgb.g;
ESBYTE[i+line_w+2] = rgb.r;
// // I don't know why but underneath code works slower then beneath
// DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
// DSDWORD[i+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
} }
// wb
// bw
else if(b24(i)!=0x000000) && (b24(i+3)==0x000000) && (b24(i+line_w)==0x000000) && (b24(i+3+line_w)!=0x000000) else if(b24(i)!=0x000000) && (b24(i+3)==0x000000) && (b24(i+line_w)==0x000000) && (b24(i+3+line_w)!=0x000000)
{ {
ShadowImage(i, 1, 1, 2); ESBYTE[i ] = rgb.b;
ShadowImage(i+3+line_w, 1, 1, 2); ESBYTE[i+1] = rgb.g;
ESBYTE[i+2] = rgb.r;
ESBYTE[i+line_w+3] = rgb.b;
ESBYTE[i+line_w+4] = rgb.g;
ESBYTE[i+line_w+5] = rgb.r;
// // I don't know why but underneath code works slower then beneath
// DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
// DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
} }
} }
} }
@ -281,9 +304,11 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
IF(!text1)return; IF(!text1)return;
IF(size.pt)IF(!changeSIZE())return; IF(size.pt)IF(!changeSIZE())return;
if (size.pt != fontSizePoints) {
size.pt = fontSizePoints; size.pt = fontSizePoints;
getsize(text1); getsize(text1);
y -= size.offset_y; y -= size.offset_y;
}
color = _color; color = _color;
background = _background; background = _background;

View File

@ -5,7 +5,7 @@
io.count(path) - количество файлов в дирректории path io.count(path) - количество файлов в дирректории path
io.size(path) - размер (файла/папки) path io.size(path) - размер (файла/папки) path
io.run(path,param) - запустить файл path с параметром param io.run(path,param) - запустить файл path с параметром param
io.write(path,data) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path io.write(size,data,path) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path
io.read(path) - прочитать файл path и возвратить указатель на данные io.read(path) - прочитать файл path и возвратить указатель на данные
io.move(path1,path2) - переместить (файл/папку) из path1 в path2 io.move(path1,path2) - переместить (файл/папку) из path1 в path2
io.copy(path1,path2) - копировать (файл/папку) из path1 в path2 io.copy(path1,path2) - копировать (файл/папку) из path1 в path2

View File

@ -1,4 +1,5 @@
//CODED by Veliant, Leency, Nable. GNU GPL licence. //CODED by Veliant, Leency, Nable, Pavelyakov. GNU GPL licence.
#ifndef INCLUDE_KOLIBRI_H #ifndef INCLUDE_KOLIBRI_H
#define INCLUDE_KOLIBRI_H #define INCLUDE_KOLIBRI_H
#print "[include <kolibri.h>]\n" #print "[include <kolibri.h>]\n"
@ -805,15 +806,14 @@ void ______INIT______()
DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay(); DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay();
__generator = GetStartTime(); __generator = GetStartTime();
$push ebx mem_init();
$mov eax, 68
$mov ebx, 11
$int 0x40
$pop ebx
main(); main();
ExitProcess(); ExitProcess();
} }
______STOP______: ______STOP______:
#endif #endif
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif

View File

@ -21,6 +21,7 @@ dword malloc(dword size)
{ {
$push ebx $push ebx
$push ecx $push ecx
$mov eax, 68 $mov eax, 68
$mov ebx, 12 $mov ebx, 12
$mov ecx, size $mov ecx, size
@ -36,6 +37,7 @@ stdcall dword realloc(dword mptr, size)
$push ebx $push ebx
$push ecx $push ecx
$push edx $push edx
$mov eax, 68 $mov eax, 68
$mov ebx, 20 $mov ebx, 20
$mov ecx, size $mov ecx, size
@ -53,6 +55,7 @@ dword free(dword mptr)
$push eax $push eax
$push ebx $push ebx
$push ecx $push ecx
$mov eax, 68 $mov eax, 68
$mov ebx, 13 $mov ebx, 13
$mov ecx, mptr $mov ecx, mptr

View File

@ -1,15 +1,15 @@
#include "..\lib\collection.h" #include "..\lib\collection.h"
struct _History { struct _history {
collection items; collection items;
int active; int active;
int add(); int add();
int back(); int back();
int forward(); int forward();
dword current(); dword current();
} History; } history;
int _History::add(dword in) int _history::add(dword in)
{ {
if (!strcmp(in, items.get(active-1))) return 0; if (!strcmp(in, items.get(active-1))) return 0;
items.count = active; items.count = active;
@ -18,21 +18,21 @@ int _History::add(dword in)
return 1; return 1;
} }
int _History::back() int _history::back()
{ {
if (active==1) return 0; if (active==1) return 0;
active--; active--;
return 1; return 1;
} }
int _History::forward() int _history::forward()
{ {
if (active==items.count) return 0; if (active==items.count) return 0;
active++; active++;
return 1; return 1;
} }
dword _History::current() dword _history::current()
{ {
return items.get(active-1); return items.get(active-1);
} }

View File

@ -506,7 +506,7 @@ inline dword strstri(dword searchin, usestr_s)
searchin++; searchin++;
if (DSBYTE[usestr_e]=='\0') return searchin; if (DSBYTE[usestr_e]=='\0') return searchin;
} }
return 0; return -1;
} }