Remove X11 window validation.

Despite being a 'client resource', the window can become invalid due to
events outside of the client code's control, which causes
XGetWindowAttributes to fail because it retrieves servers-side data
that is no longer available. Hence it is something we should expect to
see happen, and not (always) an indication of a bug that needs fixing.
Also, we should be able to safely continue with an invalid window.

At this point it's up to the client code to catch the X error and
handle it appropriately. The EGL spec does not indicate that it should
catch it instead and generate an error (eglSwapBuffers can generate
EGL_CONTEXT_LOST but that's reserved for power management events).

Bug chromium:861882
Bug chromium:824522

Change-Id: I78a364516b9466f652c94de68553369935590bde
Reviewed-on: https://swiftshader-review.googlesource.com/19868
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Main/FrameBufferX11.cpp b/src/Main/FrameBufferX11.cpp
index ca56b59..b3ae3b4 100644
--- a/src/Main/FrameBufferX11.cpp
+++ b/src/Main/FrameBufferX11.cpp
@@ -50,12 +50,11 @@
 			assert(x_display);
 		}
 
-		validateWindow();
-
 		int screen = DefaultScreen(x_display);
 		x_gc = libX11->XDefaultGC(x_display, screen);
 		int depth = libX11->XDefaultDepth(x_display, screen);
 
+		XVisualInfo x_visual;
 		Status status = libX11->XMatchVisualInfo(x_display, screen, 32, TrueColor, &x_visual);
 		bool match = (status != 0 && x_visual.blue_mask == 0xFF);   // Prefer X8R8G8B8
 		Visual *visual = match ? x_visual.visual : libX11->XDefaultVisual(x_display, screen);
@@ -118,9 +117,6 @@
 			shmctl(shminfo.shmid, IPC_RMID, 0);
 		}
 
-		// Last chance to check the window before we close the display.
-		validateWindow();
-
 		if(ownX11)
 		{
 			libX11->XCloseDisplay(x_display);
@@ -147,8 +143,6 @@
 	{
 		copy(source);
 
-		assert(validateWindow());
-
 		if(!mit_shm)
 		{
 			libX11->XPutImage(x_display, x_window, x_gc, x_image, 0, 0, 0, 0, width, height);
@@ -190,21 +184,6 @@
 			libX11->XDrawString(x_display, x_window, x_gc, 50, 50, string, strlen(string));
 		}
 	}
-
-	bool FrameBufferX11::validateWindow()
-	{
-		// Since we don't own the window, it is the external client code's responsibility
-		// to not destroy it until we're done with it. We help out by validating it.
-		XWindowAttributes windowAttributes;
-		Status status = libX11->XGetWindowAttributes(x_display, x_window, &windowAttributes);
-
-		if(status != True)
-		{
-			abort();   // Fail hard if we can't obtain the window's attributes.
-		}
-
-		return true;
-	}
 }
 
 NO_SANITIZE_FUNCTION sw::FrameBuffer *createFrameBuffer(void *display, Window window, int width, int height)
diff --git a/src/Main/FrameBufferX11.hpp b/src/Main/FrameBufferX11.hpp
index aa06276..dc96331 100644
--- a/src/Main/FrameBufferX11.hpp
+++ b/src/Main/FrameBufferX11.hpp
@@ -31,21 +31,18 @@
 
 		~FrameBufferX11() override;
 
-		void flip(sw::Surface *source) override {blit(source, nullptr, nullptr);};
+		void flip(sw::Surface *source) override { blit(source, nullptr, nullptr); }
 		void blit(sw::Surface *source, const Rect *sourceRect, const Rect *destRect) override;
 
 		void *lock() override;
 		void unlock() override;
 
 	private:
-		bool validateWindow();
-
-		bool ownX11;
+		const bool ownX11;
 		Display *x_display;
-		Window x_window;
-		XImage *x_image;
+		const Window x_window;
+		XImage *x_image = nullptr;
 		GC x_gc;
-		XVisualInfo x_visual;
 
 		bool mit_shm;
 		XShmSegmentInfo shminfo;