pgui: Workaround for DirectEntry flickering issues w/ pipelining

See #1070.  This is a temporary solution (one which isn't complete- it doesn't properly handle state changes).
This commit is contained in:
rdb 2020-12-12 13:54:14 +01:00
parent 4f63ef635d
commit 761c54f63d
3 changed files with 91 additions and 9 deletions

View File

@ -113,6 +113,12 @@ set_cursor_position(int position) {
_cursor_position = position;
_cursor_stale = true;
_blink_start = ClockObject::get_global_clock()->get_frame_time();
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_cursor();
}
#endif
}
}
@ -185,6 +191,13 @@ set_max_width(PN_stdfloat max_width) {
LightReMutexHolder holder(_lock);
_max_width = max_width;
_text_geom_stale = true;
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_text();
update_cursor();
}
#endif
}
/**
@ -206,9 +219,17 @@ INLINE void PGEntry::
set_num_lines(int num_lines) {
LightReMutexHolder holder(_lock);
nassertv(num_lines >= 1);
_num_lines = num_lines;
_text_geom_stale = true;
update_text();
if (_num_lines != num_lines) {
_num_lines = num_lines;
_text_geom_stale = true;
update_text();
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_cursor();
}
#endif
}
}
/**
@ -300,6 +321,13 @@ set_obscure_mode(bool flag) {
if (_obscure_mode != flag) {
_obscure_mode = flag;
_text_geom_stale = true;
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_text();
update_cursor();
}
#endif
}
}
@ -325,6 +353,13 @@ set_overflow_mode(bool flag) {
_overflow_mode = flag;
_text_geom_stale = true;
_cursor_stale = true;
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_text();
update_cursor();
}
#endif
}
}
@ -518,6 +553,11 @@ set_wtext(const std::wstring &wtext) {
ret = _obscure_text.set_wtext(std::wstring(_text.get_num_characters(), '*'));
}
_text_geom_stale = true;
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_text();
}
#endif
set_cursor_position(std::min(_cursor_position, _text.get_num_characters()));
return ret;
}

View File

@ -176,8 +176,10 @@ bool PGEntry::
cull_callback(CullTraverser *trav, CullTraverserData &data) {
LightReMutexHolder holder(_lock);
PGItem::cull_callback(trav, data);
update_text();
update_cursor();
if (Thread::get_current_pipeline_stage() == 0) {
update_text();
update_cursor();
}
// Now render the text.
CullTraverserData next_data(data, _text_render_root.node());
@ -260,7 +262,7 @@ press(const MouseWatcherParameter &param, bool background) {
}
_cursor_stale = true;
if (overflow_mode){
_text_geom_stale = true;
_text_geom_stale = true;
}
}
@ -276,7 +278,7 @@ press(const MouseWatcherParameter &param, bool background) {
}
_cursor_stale = true;
if (overflow_mode){
_text_geom_stale = true;
_text_geom_stale = true;
}
}
@ -286,7 +288,7 @@ press(const MouseWatcherParameter &param, bool background) {
_cursor_position = 0;
_cursor_stale = true;
if (overflow_mode){
_text_geom_stale = true;
_text_geom_stale = true;
}
type(param);
}
@ -297,7 +299,7 @@ press(const MouseWatcherParameter &param, bool background) {
_cursor_position = _text.get_num_characters();
_cursor_stale = true;
if (overflow_mode){
_text_geom_stale = true;
_text_geom_stale = true;
}
type(param);
}
@ -306,6 +308,17 @@ press(const MouseWatcherParameter &param, bool background) {
}
}
PGItem::press(param, background);
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
if (_text_geom_stale) {
update_text();
}
if (_cursor_stale) {
update_cursor();
}
}
#endif
}
/**
@ -411,6 +424,17 @@ keystroke(const MouseWatcherParameter &param, bool background) {
}
}
PGItem::keystroke(param, background);
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
if (_text_geom_stale) {
update_text();
}
if (_cursor_stale) {
update_cursor();
}
}
#endif
}
/**
@ -434,6 +458,17 @@ candidate(const MouseWatcherParameter &param, bool background) {
}
}
PGItem::candidate(param, background);
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
if (_text_geom_stale) {
update_text();
}
if (_cursor_stale) {
update_cursor();
}
}
#endif
}
/**
@ -924,4 +959,10 @@ update_state() {
} else {
set_state(S_inactive);
}
#ifdef THREADED_PIPELINE
if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
update_text();
update_cursor();
}
#endif
}

View File

@ -23,6 +23,7 @@
#include "pvector.h"
#include "clockObject.h"
#include "textAssembler.h"
#include "pipeline.h"
/**
* This is a particular kind of PGItem that handles simple one-line or short