mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 10:42:36 +03:00
use monotonic clock call for html reflow timing
This commit is contained in:
parent
31de1c251b
commit
a6dd92c571
@ -130,9 +130,9 @@ struct content {
|
|||||||
if LOADING or READY,
|
if LOADING or READY,
|
||||||
otherwise total time. */
|
otherwise total time. */
|
||||||
|
|
||||||
unsigned int reformat_time; /**< Earliest time to attempt a
|
uint64_t reformat_time; /**< Earliest time to attempt a period
|
||||||
period reflow while fetching a
|
* reflow while fetching a page's objects.
|
||||||
page's objects. */
|
*/
|
||||||
|
|
||||||
unsigned int size; /**< Estimated size of all data
|
unsigned int size; /**< Estimated size of all data
|
||||||
associated with this content */
|
associated with this content */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <nsutils/time.h>
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "utils/corestrings.h"
|
#include "utils/corestrings.h"
|
||||||
@ -1373,9 +1374,11 @@ static void html_reformat(struct content *c, int width, int height)
|
|||||||
{
|
{
|
||||||
html_content *htmlc = (html_content *) c;
|
html_content *htmlc = (html_content *) c;
|
||||||
struct box *layout;
|
struct box *layout;
|
||||||
unsigned int time_before, time_taken;
|
uint64_t ms_before;
|
||||||
|
uint64_t ms_after;
|
||||||
|
uint64_t ms_next;
|
||||||
|
|
||||||
time_before = wallclock();
|
nsu_getmonotonic_ms(&ms_before);
|
||||||
|
|
||||||
htmlc->reflowing = true;
|
htmlc->reflowing = true;
|
||||||
|
|
||||||
@ -1400,10 +1403,14 @@ static void html_reformat(struct content *c, int width, int height)
|
|||||||
|
|
||||||
htmlc->reflowing = false;
|
htmlc->reflowing = false;
|
||||||
|
|
||||||
time_taken = wallclock() - time_before;
|
/* calculate next reflow time at three times what it took to reflow */
|
||||||
c->reformat_time = wallclock() +
|
nsu_getmonotonic_ms(&ms_after);
|
||||||
((time_taken * 3 < nsoption_uint(min_reflow_period) ?
|
|
||||||
nsoption_uint(min_reflow_period) : time_taken * 3));
|
ms_next = (ms_before - ms_after) * 3;
|
||||||
|
if (ms_next < (nsoption_uint(min_reflow_period) * 10)) {
|
||||||
|
ms_next = nsoption_uint(min_reflow_period) * 10;
|
||||||
|
}
|
||||||
|
c->reformat_time = ms_after + ms_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <nsutils/time.h>
|
||||||
|
|
||||||
#include "utils/utils.h"
|
|
||||||
#include "utils/corestrings.h"
|
#include "utils/corestrings.h"
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
@ -434,7 +434,8 @@ html_object_callback(hlcache_handle *object,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->base.status == CONTENT_STATUS_READY && c->base.active == 0 &&
|
if (c->base.status == CONTENT_STATUS_READY &&
|
||||||
|
c->base.active == 0 &&
|
||||||
(event->type == CONTENT_MSG_LOADING ||
|
(event->type == CONTENT_MSG_LOADING ||
|
||||||
event->type == CONTENT_MSG_DONE ||
|
event->type == CONTENT_MSG_DONE ||
|
||||||
event->type == CONTENT_MSG_ERROR)) {
|
event->type == CONTENT_MSG_ERROR)) {
|
||||||
@ -442,25 +443,32 @@ html_object_callback(hlcache_handle *object,
|
|||||||
content__reformat(&c->base, false, c->base.available_width,
|
content__reformat(&c->base, false, c->base.available_width,
|
||||||
c->base.height);
|
c->base.height);
|
||||||
content_set_done(&c->base);
|
content_set_done(&c->base);
|
||||||
}
|
} else if (nsoption_bool(incremental_reflow) &&
|
||||||
|
event->type == CONTENT_MSG_DONE &&
|
||||||
/* If 1) the configuration option to reflow pages while objects are
|
box != NULL &&
|
||||||
* fetched is set
|
!(box->flags & REPLACE_DIM) &&
|
||||||
|
(c->base.status == CONTENT_STATUS_READY ||
|
||||||
|
c->base.status == CONTENT_STATUS_DONE)) {
|
||||||
|
/* 1) the configuration option to reflow pages while
|
||||||
|
* objects are fetched is set
|
||||||
* 2) an object is newly fetched & converted,
|
* 2) an object is newly fetched & converted,
|
||||||
* 3) the box's dimensions need to change due to being replaced
|
* 3) the box's dimensions need to change due to being replaced
|
||||||
* 4) the object's parent HTML is ready for reformat,
|
* 4) the object's parent HTML is ready for reformat,
|
||||||
* 5) the time since the previous reformat is more than the
|
*/
|
||||||
* configured minimum time between reformats
|
uint64_t ms_now;
|
||||||
* then reformat the page to display newly fetched objects */
|
nsu_getmonotonic_ms(&ms_now);
|
||||||
else if (nsoption_bool(incremental_reflow) &&
|
if (ms_now > c->base.reformat_time) {
|
||||||
event->type == CONTENT_MSG_DONE &&
|
/* The time since the previous reformat is
|
||||||
box != NULL && !(box->flags & REPLACE_DIM) &&
|
* more than the configured minimum time
|
||||||
(c->base.status == CONTENT_STATUS_READY ||
|
* between reformats so reformat the page to
|
||||||
c->base.status == CONTENT_STATUS_DONE) &&
|
* display newly fetched objects
|
||||||
(wallclock() > c->base.reformat_time)) {
|
*/
|
||||||
content__reformat(&c->base, false, c->base.available_width,
|
content__reformat(&c->base,
|
||||||
|
false,
|
||||||
|
c->base.available_width,
|
||||||
c->base.height);
|
c->base.height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NSERROR_OK;
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user