Update how we force a repaint, try to more consistently hit the ideal refresh rate of the glasses
This commit is contained in:
parent
53eee5cf7a
commit
f6f5bbf6cc
|
|
@ -20,15 +20,14 @@ export class CursorManager {
|
||||||
this._cursorTrackerSetPointerVisibleBound = null;
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
this._cursorSprite = null;
|
this._cursorSprite = null;
|
||||||
this._cursorActor = null;
|
this._cursorActor = null;
|
||||||
this._cursorWatcher = null;
|
|
||||||
this._cursorSeat = null;
|
this._cursorSeat = null;
|
||||||
this._cursorUnfocusInhibited = false;
|
this._cursorUnfocusInhibited = false;
|
||||||
|
|
||||||
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
||||||
this._cursorWatch = null;
|
|
||||||
this._cursorChangedConnection = null;
|
this._cursorChangedConnection = null;
|
||||||
this._cursorVisibilityChangedConnection = null;
|
this._cursorVisibilityChangedConnection = null;
|
||||||
this._moveToTopTimeout = null;
|
this._moveToTopTimeout = null;
|
||||||
|
this._redraw_timeline = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
|
|
@ -78,7 +77,6 @@ export class CursorManager {
|
||||||
} else {
|
} else {
|
||||||
this._cursorActor.add_actor(this._cursorSprite);
|
this._cursorActor.add_actor(this._cursorSprite);
|
||||||
}
|
}
|
||||||
this._cursorWatcher = PointerWatcher.getPointerWatcher();
|
|
||||||
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +98,6 @@ export class CursorManager {
|
||||||
this._cursorTrackerSetPointerVisibleBound = null;
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
this._cursorSprite = null;
|
this._cursorSprite = null;
|
||||||
this._cursorActor = null;
|
this._cursorActor = null;
|
||||||
this._cursorWatcher = null;
|
|
||||||
this._cursorSeat = null;
|
this._cursorSeat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +122,6 @@ export class CursorManager {
|
||||||
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
||||||
_startCloningMouse() {
|
_startCloningMouse() {
|
||||||
Globals.logger.log_debug('CursorManager _startCloningMouse');
|
Globals.logger.log_debug('CursorManager _startCloningMouse');
|
||||||
if (this._cursorWatch == null) {
|
|
||||||
if (Clutter.Container === undefined) {
|
if (Clutter.Container === undefined) {
|
||||||
this._mainActor.add_child(this._cursorActor);
|
this._mainActor.add_child(this._cursorActor);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -143,13 +139,24 @@ export class CursorManager {
|
||||||
return GLib.SOURCE_CONTINUE;
|
return GLib.SOURCE_CONTINUE;
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
const interval = 1000 / this._refreshRate;
|
const refreshInterval = 1000 / this._refreshRate;
|
||||||
this._cursorWatch = this._cursorWatcher.addWatch(interval, this._updateMousePosition.bind(this));
|
|
||||||
|
|
||||||
|
// we'll force repaint the cursor every frame,
|
||||||
|
// this keeps the cursor up-to-date and is sort of a hack that's a critical part of making sure
|
||||||
|
// the XR Effect refreshes even if nothing on-screen has changed (bypass the texture caching)
|
||||||
|
this._redraw_timeline = Clutter.Timeline.new_for_actor(this._cursorActor, refreshInterval);
|
||||||
|
this._redraw_timeline.set_repeat_count(-1);
|
||||||
|
|
||||||
|
var on = false;
|
||||||
|
this._redraw_timeline.connect('completed', (() => {
|
||||||
|
this._cursorActor.set_opacity(this._cursorActor.opacity + (on ? 1 : -1));
|
||||||
const [x, y] = global.get_pointer();
|
const [x, y] = global.get_pointer();
|
||||||
this._updateMousePosition(x, y);
|
this._cursorActor.set_position(x, y);
|
||||||
|
on = !on;
|
||||||
|
}).bind(this));
|
||||||
|
this._redraw_timeline.start();
|
||||||
|
|
||||||
this._updateMouseSprite();
|
this._updateMouseSprite();
|
||||||
}
|
|
||||||
|
|
||||||
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||||
this._cursorTracker.set_keep_focus_while_hidden(true);
|
this._cursorTracker.set_keep_focus_while_hidden(true);
|
||||||
|
|
@ -170,10 +177,6 @@ export class CursorManager {
|
||||||
// completely reverts _startCloningMouse
|
// completely reverts _startCloningMouse
|
||||||
_stopCloningMouse() {
|
_stopCloningMouse() {
|
||||||
Globals.logger.log_debug('CursorManager _stopCloningMouse');
|
Globals.logger.log_debug('CursorManager _stopCloningMouse');
|
||||||
if (this._cursorWatch != null) {
|
|
||||||
this._cursorWatch.remove();
|
|
||||||
this._cursorWatch = null;
|
|
||||||
|
|
||||||
if (this._cursorChangedConnection) {
|
if (this._cursorChangedConnection) {
|
||||||
this._cursorTracker.disconnect(this._cursorChangedConnection);
|
this._cursorTracker.disconnect(this._cursorChangedConnection);
|
||||||
this._cursorChangedConnection = null;
|
this._cursorChangedConnection = null;
|
||||||
|
|
@ -194,6 +197,10 @@ export class CursorManager {
|
||||||
GLib.source_remove(this._moveToTopTimeout);
|
GLib.source_remove(this._moveToTopTimeout);
|
||||||
this._moveToTopTimeout = null;
|
this._moveToTopTimeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._redraw_timeline) {
|
||||||
|
this._redraw_timeline.stop();
|
||||||
|
this._redraw_timeline = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._cursorUnfocusInhibited) {
|
if (this._cursorUnfocusInhibited) {
|
||||||
|
|
@ -203,10 +210,6 @@ export class CursorManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateMousePosition(x, y) {
|
|
||||||
this._cursorActor.set_position(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateMouseSprite() {
|
_updateMouseSprite() {
|
||||||
const sprite = this._cursorTracker.get_sprite();
|
const sprite = this._cursorTracker.get_sprite();
|
||||||
if (sprite) {
|
if (sprite) {
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,6 @@ export const XREffect = GObject.registerClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_paint_target(node, paintContext) {
|
vfunc_paint_target(node, paintContext) {
|
||||||
var now = Date.now();
|
|
||||||
var lastPaint = this._last_paint || 0;
|
|
||||||
var frametime = this._frametime;
|
var frametime = this._frametime;
|
||||||
var calibratingImage = this.calibratingImage;
|
var calibratingImage = this.calibratingImage;
|
||||||
var customBannerImage = this.customBannerImage;
|
var customBannerImage = this.customBannerImage;
|
||||||
|
|
@ -317,11 +315,6 @@ export const XREffect = GObject.registerClass({
|
||||||
this.setIntermittentUniformVariables = setIntermittentUniformVariables.bind(this);
|
this.setIntermittentUniformVariables = setIntermittentUniformVariables.bind(this);
|
||||||
this.setIntermittentUniformVariables();
|
this.setIntermittentUniformVariables();
|
||||||
|
|
||||||
this._redraw_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._frametime, () => {
|
|
||||||
if ((now - lastPaint) > frametime) global.stage.queue_redraw();
|
|
||||||
return GLib.SOURCE_CONTINUE;
|
|
||||||
});
|
|
||||||
|
|
||||||
this._uniforms_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
this._uniforms_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
||||||
this.setIntermittentUniformVariables();
|
this.setIntermittentUniformVariables();
|
||||||
return GLib.SOURCE_CONTINUE;
|
return GLib.SOURCE_CONTINUE;
|
||||||
|
|
@ -360,16 +353,11 @@ export const XREffect = GObject.registerClass({
|
||||||
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
|
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
|
||||||
Cogl.PipelineFilter.LINEAR
|
Cogl.PipelineFilter.LINEAR
|
||||||
);
|
);
|
||||||
|
|
||||||
super.vfunc_paint_target(node, paintContext);
|
|
||||||
} else {
|
|
||||||
super.vfunc_paint_target(node, paintContext);
|
|
||||||
}
|
}
|
||||||
this._last_paint = now;
|
super.vfunc_paint_target(node, paintContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
if (this._redraw_timeout_id) GLib.source_remove(this._redraw_timeout_id);
|
|
||||||
if (this._uniforms_timeout_id) GLib.source_remove(this._uniforms_timeout_id);
|
if (this._uniforms_timeout_id) GLib.source_remove(this._uniforms_timeout_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue