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_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;
if (style.h) stroka++;
@ -212,7 +212,7 @@ void TWebBrowser::Prepare(){
default:
DEFAULT_MARK:
if (bukva<=15) bukva=' ';
line_len = utf8_strlen(#line);
line_len = strlen(#line);
if (!style.pre) && (bukva == ' ')
{
if (line[line_len-1]==' ') break; //no double spaces
@ -238,9 +238,9 @@ void TWebBrowser::Perenos()
{
int perenos_num;
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, ' ');
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);
line[perenos_num] = 0x00;
DrawStyle();

View File

@ -34,11 +34,11 @@ void GetAbsoluteURL(dword in_URL)
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
if (!http_transfer)
{
strcpy(#newurl, History.current());
strcpy(#newurl, history.current());
}
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

View File

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

View File

@ -5,15 +5,15 @@ ShowHistory()
int t;
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, "<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, History.items.get(i));
strcat(history_pointer, history.items.get(i));
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, "</blockquote><h2>Cached images</h2>");

View File

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

View File

@ -9,6 +9,9 @@
#include "../lib/obj/fs.h"
#endif
#include "../lib/patterns/rgb.h"
#define DEFAULT_FONT "/sys/fonts/Tahoma.kf"
:struct __SIZE
@ -211,20 +214,40 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
:void LABEL::apply_smooth()
{
dword i,line_w,to;
rgb.DwordToRgb(ShadowPixel(background,2)); //get shadowed pixel
line_w = size.width * 3;
to = size.height - 1 * line_w + raw - 3;
for(i=raw; i < to; i+=3)
{
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)
{
ShadowImage(i+3, 1, 1, 2);
ShadowImage(i+line_w, 1, 1, 2);
ESBYTE[i+3] = rgb.b;
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)
{
ShadowImage(i, 1, 1, 2);
ShadowImage(i+3+line_w, 1, 1, 2);
ESBYTE[i ] = rgb.b;
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(size.pt)IF(!changeSIZE())return;
if (size.pt != fontSizePoints) {
size.pt = fontSizePoints;
getsize(text1);
y -= size.offset_y;
}
color = _color;
background = _background;

View File

@ -5,7 +5,7 @@
io.count(path) - количество файлов в дирректории path
io.size(path) - размер (файла/папки) path
io.run(path,param) - запустить файл path с параметром param
io.write(path,data) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path
io.write(size,data,path) - çàïèñàòü ôàéë ñ äàííûìè data â äèððåêòîðèþ path
io.read(path) - прочитать файл path и возвратить указатель на данные
io.move(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
#define INCLUDE_KOLIBRI_H
#print "[include <kolibri.h>]\n"
@ -805,15 +806,14 @@ void ______INIT______()
DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay();
__generator = GetStartTime();
$push ebx
$mov eax, 68
$mov ebx, 11
$int 0x40
$pop ebx
mem_init();
main();
ExitProcess();
}
______STOP______:
#endif
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif

View File

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

View File

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

View File

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