Commit 5b9bb476 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Reintroduce connection flushes after PutImage requests

These were removed in [1] because the message loop was changed to
TYPE_UI, which automatically flushes.  However, if there are a lot of
tasks in the queue, the flush may happen later than we'd like, and
this increases latency between frames.  This CL adds the flushes back
in an effort to fix perf regressions.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2343314

R=sky
BUG=1119639

Change-Id: I04d6854fce7df69830f421dd81d734a14ae6d5a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377609
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802363}
parent 41df5301
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/task/current_thread.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
...@@ -218,6 +217,9 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) { ...@@ -218,6 +217,9 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) {
.offset = 0, .offset = 0,
}); });
needs_swap_ = true; needs_swap_ = true;
// Flush now to ensure the X server gets the request as early as
// possible to reduce frame-to-frame latency.
connection_->Flush();
return; return;
} }
if (surface_) if (surface_)
...@@ -229,6 +231,10 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) { ...@@ -229,6 +231,10 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) {
if (composite_ && if (composite_ &&
CompositeBitmap(connection_, widget_, rect.x(), rect.y(), rect.width(), CompositeBitmap(connection_, widget_, rect.x(), rect.y(), rect.width(),
rect.height(), depth_, gc_, skia_pixmap.addr())) { rect.height(), depth_, gc_, skia_pixmap.addr())) {
// Flush now to ensure the X server gets the request as early as
// possible to reduce frame-to-frame latency.
connection_->Flush();
return; return;
} }
...@@ -236,8 +242,9 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) { ...@@ -236,8 +242,9 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) {
DrawPixmap(connection, visual_, widget_, gc_, skia_pixmap, rect.x(), rect.y(), DrawPixmap(connection, visual_, widget_, gc_, skia_pixmap, rect.x(), rect.y(),
rect.x(), rect.y(), rect.width(), rect.height()); rect.x(), rect.y(), rect.width(), rect.height());
// We must be running on a UI thread so that the connection will be flushed. // Flush now to ensure the X server gets the request as early as
DCHECK(base::CurrentUIThread::IsSet()); // possible to reduce frame-to-frame latency.
connection_->Flush();
} }
void X11SoftwareBitmapPresenter::OnSwapBuffers( void X11SoftwareBitmapPresenter::OnSwapBuffers(
......
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