Commit 1be92e0a authored by disher@chromium.org's avatar disher@chromium.org

Refresh output cache when setting display mode

Historically, all the entry-points into the OutputConfigurator needed to refresh
their view of the cached output data.  This newly-added entry-point doesn't do
this which can lead to the cached data becoming stale (since it technically only
applies within the context where the corresponding XRRScreenResources are
valid).
Ideally, no such information would be cached and every attempt to evaluate or
change the state of the video outputs would start by requesting this structure.
That change is of larger scope and risk, though, so this is the tactical
solution to the immediate problem suitable for porting to stable branches.

BUG=chromium:140807
TEST=Manually tested that ctrl-F4 and "manage displays" (in chrome://settings)
work on a Lumpy the same way with and without this change


Review URL: https://chromiumcodereview.appspot.com/10825306

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151696 0039d316-1c4b-4281-b951-d872f2087c98
parent 34b77d35
...@@ -396,6 +396,9 @@ bool OutputConfigurator::SetDisplayMode(OutputState new_state) { ...@@ -396,6 +396,9 @@ bool OutputConfigurator::SetDisplayMode(OutputState new_state) {
XRRScreenResources* screen = XRRGetScreenResources(display, window); XRRScreenResources* screen = XRRGetScreenResources(display, window);
CHECK(screen != NULL); CHECK(screen != NULL);
// We are about to act on the cached output data but it could be stale so
// force the outputs to be recached.
ForceRecacheOutputs(display, screen);
UpdateCacheAndXrandrToState(display, UpdateCacheAndXrandrToState(display,
screen, screen,
window, window,
...@@ -465,9 +468,15 @@ bool OutputConfigurator::TryRecacheOutputs(Display* display, ...@@ -465,9 +468,15 @@ bool OutputConfigurator::TryRecacheOutputs(Display* display,
} }
} }
if (!outputs_did_change) if (outputs_did_change) {
return false; // We now know that we need to recache so free and re-alloc the buffer.
// We now know that we need to recache so free and re-alloc the buffer. ForceRecacheOutputs(display, screen);
}
return outputs_did_change;
}
void OutputConfigurator::ForceRecacheOutputs(Display* display,
XRRScreenResources* screen) {
output_count_ = screen->noutput; output_count_ = screen->noutput;
if (output_count_ == 0) { if (output_count_ == 0) {
output_cache_.reset(NULL); output_cache_.reset(NULL);
...@@ -572,7 +581,6 @@ bool OutputConfigurator::TryRecacheOutputs(Display* display, ...@@ -572,7 +581,6 @@ bool OutputConfigurator::TryRecacheOutputs(Display* display,
<< " primary " << primary_mode << " primary " << primary_mode
<< " secondary " << second_mode; << " secondary " << second_mode;
} }
return outputs_did_change;
} }
void OutputConfigurator::UpdateCacheAndXrandrToState( void OutputConfigurator::UpdateCacheAndXrandrToState(
......
...@@ -104,6 +104,11 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher { ...@@ -104,6 +104,11 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher {
// Note that |output_state_| is not updated by this call. // Note that |output_state_| is not updated by this call.
bool TryRecacheOutputs(Display* display, XRRScreenResources* screen); bool TryRecacheOutputs(Display* display, XRRScreenResources* screen);
// Updates |output_count_|, |output_cache_|, |mirror_supported_|,
// |primary_output_index_|, and |secondary_output_index_| with new data.
// Note that |output_state_| is not updated by this call.
void ForceRecacheOutputs(Display* display, XRRScreenResources* screen);
// Uses the data stored in |output_cache_| and the given |new_state| to // Uses the data stored in |output_cache_| and the given |new_state| to
// configure the Xrandr interface and then updates |output_state_| to reflect // configure the Xrandr interface and then updates |output_state_| to reflect
// the new state. // the new state.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment