Skip to content

Instantly share code, notes, and snippets.

@ivan
Created September 22, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan/1643464b9d344a39d82cb80205b61006 to your computer and use it in GitHub Desktop.
Save ivan/1643464b9d344a39d82cb80205b61006 to your computer and use it in GitHub Desktop.
chromium-revert-commit-causing-tearing.patch
From cd0dc202be0a2b5964a920bc48bffd1bc2135c31 Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Sun, 22 Sep 2019 00:26:17 +0000
Subject: [PATCH] Revert "Always use the same visual for GLSurfaceGLX"
This reverts commit ec69eaf767f86d6fc1cd43f4800b0486e8d656af.
---
ui/gl/gl_surface_glx.cc | 41 ++++++++++++++++-------------------------
ui/gl/gl_surface_glx.h | 3 +++
2 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
index b6028631de6c..88f9882c34c9 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -461,12 +461,13 @@ bool GLSurfaceGLX::InitializeOneOff() {
return false;
}
- const auto& visual_info = gl::GLVisualPickerGLX::GetInstance()->rgba_visual();
+ const auto& visual_info = gl::GLVisualPickerGLX::GetInstance()->system_visual();
g_visual = visual_info.visual;
g_depth = visual_info.depth;
g_colormap =
XCreateColormap(gfx::GetXDisplay(), DefaultRootWindow(gfx::GetXDisplay()),
visual_info.visual, AllocNone);
+
// We create a dummy unmapped window for both the main Display and the video
// sync Display so that the Nvidia driver can initialize itself before the
// sandbox is set up.
@@ -592,6 +593,7 @@ NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window)
window_(0),
glx_window_(0),
config_(nullptr),
+ visual_id_(CopyFromParent),
has_swapped_buffers_(false) {}
bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
@@ -603,30 +605,19 @@ bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
}
size_ = gfx::Size(attributes.width, attributes.height);
- XSetWindowAttributes swa = {
- .background_pixmap = 0,
- .background_pixel = 0, // ARGB(0,0,0,0) for compositing WM
- .border_pixel = 0,
- .bit_gravity = NorthWestGravity,
- .colormap = g_colormap,
- };
- auto value_mask = CWBackPixmap | CWBitGravity | CWColormap | CWBorderPixel;
- if (ui::IsCompositingManagerPresent() &&
- XVisualIDFromVisual(attributes.visual) == XVisualIDFromVisual(g_visual)) {
- // When parent and child are using the same visual, the back buffer will be
- // shared between parent and child. If WM compositing is enabled, we set
- // child's background pixel to ARGB(0,0,0,0), so ARGB(0,0,0,0) will be
- // filled to the shared buffer, when the child window is mapped. It can
- // avoid an annoying flash when the child window is mapped below.
- // If WM compositing is disabled, we don't set the background pixel, so
- // nothing will be draw when the child window is mapped.
- value_mask |= CWBackPixel;
- }
-
+ visual_id_ = XVisualIDFromVisual(attributes.visual);
+ // Create a child window, with a CopyFromParent visual (to avoid inducing
+ // extra blits in the driver), that we can resize exactly in Resize(),
+ // correctly ordered with GL, so that we don't have invalid transient states.
+ // See https://crbug.com/326995.
+ XSetWindowAttributes swa;
+ memset(&swa, 0, sizeof(swa));
+ swa.background_pixmap = 0;
+ swa.bit_gravity = NorthWestGravity;
window_ =
- XCreateWindow(gfx::GetXDisplay(), parent_window_, 0 /* x */, 0 /* y */,
- size_.width(), size_.height(), 0 /* border_width */,
- g_depth, InputOutput, g_visual, value_mask, &swa);
+ XCreateWindow(gfx::GetXDisplay(), parent_window_, 0, 0, size_.width(),
+ size_.height(), 0, CopyFromParent, InputOutput,
+ CopyFromParent, CWBackPixmap | CWBitGravity, &swa);
if (!window_) {
LOG(ERROR) << "XCreateWindow failed";
return false;
@@ -750,7 +741,7 @@ GLSurfaceFormat NativeViewGLSurfaceGLX::GetFormat() {
}
unsigned long NativeViewGLSurfaceGLX::GetCompatibilityKey() {
- return XVisualIDFromVisual(g_visual);
+ return visual_id_;
}
gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer(
diff --git a/ui/gl/gl_surface_glx.h b/ui/gl/gl_surface_glx.h
index da2952013449..898e9cddacdd 100644
--- a/ui/gl/gl_surface_glx.h
+++ b/ui/gl/gl_surface_glx.h
@@ -94,6 +94,8 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
gfx::VSyncProvider* GetVSyncProvider() override;
void SetVSyncEnabled(bool enabled) override;
+ VisualID GetVisualID() const { return visual_id_; }
+
protected:
~NativeViewGLSurfaceGLX() override;
@@ -124,6 +126,7 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
GLXFBConfig config_;
gfx::Size size_;
+ VisualID visual_id_;
bool has_swapped_buffers_;
--
2.23.0
@ivan
Copy link
Author

ivan commented Sep 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment