Webext: default to hiding text in webext
Text in the real browser only needs to be displayed when parsing with the Text Builder in order to get the text's colour and z-index. Text parsing should be done in frequently as it likely doesn't change often. However graphics building of the current viewport is set to automatically parse ever 250ms and it doesn't need to know anything about text. So there's no point defaulting to having text on and hiding it for every graphics frame. This tweak has improved the perforance of the graphics parsing for small frames (the same size as the viewport) from around 100ms to around 4ms! There are still some curious and inexplicable CPU spikes when scrolling... TBC
This commit is contained in:
parent
fff7c2e413
commit
9dc0f0a08f
|
@ -70,7 +70,7 @@ func Keyboard(keys string) {
|
||||||
func waitForNextFrame() {
|
func waitForNextFrame() {
|
||||||
// Need to wait so long because the frame rate is currently so slow
|
// Need to wait so long because the frame rate is currently so slow
|
||||||
// TODO: Reduce the wait when the FPS is higher
|
// TODO: Reduce the wait when the FPS is higher
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForText waits for a particular string at particular position in the frame
|
// WaitForText waits for a particular string at particular position in the frame
|
||||||
|
|
|
@ -256,6 +256,6 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin, TabComm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.sendToCurrentTab('/request_frame');
|
this.sendToCurrentTab('/request_frame');
|
||||||
}, 500);
|
}, 250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
this.dimensions = dimensions;
|
this.dimensions = dimensions;
|
||||||
this._off_screen_canvas = document.createElement('canvas');
|
this._off_screen_canvas = document.createElement('canvas');
|
||||||
this._ctx = this._off_screen_canvas.getContext('2d');
|
this._ctx = this._off_screen_canvas.getContext('2d');
|
||||||
|
this._hideText();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFrame() {
|
sendFrame() {
|
||||||
|
@ -61,14 +62,14 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getScreenshotWithoutText() {
|
_getScreenshotWithoutText() {
|
||||||
this._hideText();
|
|
||||||
this.pixels_without_text = this._getScreenshot();
|
this.pixels_without_text = this._getScreenshot();
|
||||||
this._showText();
|
|
||||||
return this.pixels_without_text;
|
return this.pixels_without_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getScreenshotWithText() {
|
_getScreenshotWithText() {
|
||||||
|
this._showText();
|
||||||
this.pixels_with_text = this._getScreenshot();
|
this.pixels_with_text = this._getScreenshot();
|
||||||
|
this._hideText();
|
||||||
return this.pixels_with_text;
|
return this.pixels_with_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +146,6 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
_scaleCanvas() {
|
_scaleCanvas() {
|
||||||
this._is_scaled = true;
|
this._is_scaled = true;
|
||||||
// TODO: default to text hidden - show text only for big frames
|
// TODO: default to text hidden - show text only for big frames
|
||||||
this._hideText();
|
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
this._ctx.scale(
|
this._ctx.scale(
|
||||||
this.dimensions.scale_factor.width,
|
this.dimensions.scale_factor.width,
|
||||||
|
@ -155,7 +155,6 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
|
|
||||||
_unScaleCanvas() {
|
_unScaleCanvas() {
|
||||||
this._ctx.restore();
|
this._ctx.restore();
|
||||||
this._showText();
|
|
||||||
this._is_scaled = false;
|
this._is_scaled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue