WebView 2.2: pages cache, fast DrawBufer.Fill()

git-svn-id: svn://kolibrios.org@7764 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-05 07:33:55 +00:00
parent a3acc97488
commit 6aa36595f5
6 changed files with 65 additions and 11 deletions

View File

@ -400,7 +400,15 @@ void TWebBrowser::SetStyle() {
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;} if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
//if (tag.is("dd")) { stolbec += 5; return; } //stolbec overflow! if (tag.is("dl")) {
if (tag.opened) NewLine();
return;
}
if (tag.is("dd")) {
//NewLine();
//if (tag.opened) stolbec += 5; //stolbec overflow!
return;
}
if (tag.is("blockquote")) { style.blq = tag.opened; return; } if (tag.is("blockquote")) { style.blq = tag.opened; return; }
if (tag.is("code")) { if (tag.is("code")) {
if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg; if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;

View File

@ -36,6 +36,7 @@ _history history;
bool debug_mode = false; bool debug_mode = false;
#include "..\TWB\TWB.c" //HTML Parser, a core component #include "..\TWB\TWB.c" //HTML Parser, a core component
#include "texts.h" #include "texts.h"
#include "cache.h"
TWebBrowser WB1; TWebBrowser WB1;
@ -117,7 +118,7 @@ void main()
int i, btn, redirect_count=0; int i, btn, redirect_count=0;
LoadLibraries(); LoadLibraries();
CreateDir("/tmp0/1/Downloads"); CreateDir("/tmp0/1/Downloads");
CreateDir("/tmp0/1/WebView_Cache"); //CreateDir("/tmp0/1/WebView_Cache");
Libimg_LoadImage(#skin, "/sys/toolbar.png"); Libimg_LoadImage(#skin, "/sys/toolbar.png");
HandleParam(); HandleParam();
skin.h = 26; skin.h = 26;
@ -231,6 +232,7 @@ void main()
// Loading the page is complete, free resources // Loading the page is complete, free resources
redirect_count = 0; redirect_count = 0;
http.free(); http.free();
pages_cache.add(history.current(), http.content_pointer, http.content_received);
LoadInternalPage(http.content_pointer, http.content_received); LoadInternalPage(http.content_pointer, http.content_received);
} }
} }
@ -450,15 +452,17 @@ void OpenPage(dword _open_URL)
history.add(#new_url); history.add(#new_url);
//if (pages_cache.have(#new_url)) { if (pages_cache.has(#new_url)) {
// LoadInternalPage(pages_cache.current_page_buf, pages_cache.pages_cache.current_page_size); //CACHED PAGE
//} else LoadInternalPage(pages_cache.current_page_buf, pages_cache.current_page_size);
if (!strncmp(#new_url,"WebView:",8)) {
} else if (!strncmp(#new_url,"WebView:",8)) {
//INTERNAL PAGE //INTERNAL PAGE
if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
else LoadInternalPage(#page_not_found, sizeof(page_not_found)); else LoadInternalPage(#page_not_found, sizeof(page_not_found));
} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
//WEB PAGE //WEB PAGE
if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {

View File

@ -0,0 +1,34 @@
struct PAGES_CACHE
{
dword current_page_buf;
dword current_page_size;
collection url;
collection data; //it has to be int
collection size; //it has to be int
void add();
bool has();
} pages_cache;
void PAGES_CACHE::add(dword _url, _data, _size)
{
dword data_pointer;
data_pointer = malloc(_size);
memmov(data_pointer, _data, _size);
data.add(itoa(data_pointer));
url.add(_url);
size.add(itoa(_size));
}
bool PAGES_CACHE::has(dword _link)
{
int pos;
pos = url.get_pos_by_name(_link);
if (pos != -1) {
current_page_buf = atoi(data.get(pos));
current_page_size = atoi(size.get(pos));
return true;
}
return false;
}

View File

@ -1,4 +1,4 @@
char version[]="WebView 2.15"; char version[]="WebView 2.2";
#ifdef LANG_RUS #ifdef LANG_RUS
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";

View File

@ -49,9 +49,8 @@ void DrawBufer::Fill(dword start_pointer, i_fill_color)
{ {
dword i; dword i;
dword max_i = bufw * bufh * 4 + buf_data + 8; dword max_i = bufw * bufh * 4 + buf_data + 8;
EDI = fill_color = i_fill_color; fill_color = i_fill_color;
for (ESI=buf_data+start_pointer+8; ESI<max_i; ESI+=4) ESDWORD[ESI] = EDI; MEMSETD(buf_data+start_pointer+8, max_i-buf_data-start_pointer-8/4, fill_color);
//for (i=buf_data+start_pointer+8; i<max_i; i+=4) ESDWORD[i] = fill_color;
} }
void DrawBufer::DrawBar(dword x, y, w, h, color) void DrawBufer::DrawBar(dword x, y, w, h, color)
@ -68,7 +67,7 @@ void DrawBufer::DrawBar(dword x, y, w, h, color)
void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset) void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset)
{ {
#define BUGFIX_32000 32000 #define BUGFIX_32000 32000
int ydiv=0; dword ydiv=0;
dword reserve_data_1, reserve_data_2; dword reserve_data_1, reserve_data_2;
dword new_buf_offset; dword new_buf_offset;
if (y + 30 >= bufh) IncreaseBufSize(); if (y + 30 >= bufh) IncreaseBufSize();

View File

@ -917,6 +917,15 @@ inline signed strcoll(dword text1,text2)
return 0; return 0;
} }
// void * memset( ptr, value, num );
// fills the memory with a dword
// example: memset(str,'-', sizeof(str));
inline void MEMSETD(EDI,ECX,EAX)
{
$REP
$STOSD
}
:replace_char(dword in_str, char from_char, to_char, int length) { :replace_char(dword in_str, char from_char, to_char, int length) {
int i; int i;
for (i=0; i<length; i++) { for (i=0; i<length; i++) {