drm-tests: Add support for EXT_image_flush_external_extension

The null_platform_test needs to call EGLImageFlushExternalEXT before every
page flip if this extension is supported by the driver.

BUG=chromium:656786
CQ-DEPEND=CL:400846
TEST=run test on nyan_big

Change-Id: I133e175fec2193fcc0d85861204c8e64f52521b8
Reviewed-on: https://chromium-review.googlesource.com/399958
Commit-Ready: Haixia Shi <hshi@chromium.org>
Tested-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
diff --git a/null_platform_test.c b/null_platform_test.c
index 2078f8e..6a5ff3c 100644
--- a/null_platform_test.c
+++ b/null_platform_test.c
@@ -138,6 +138,7 @@
 	struct gbm_bo *bos[2];
 	uint32_t ids[2];
 	struct bs_egl_fb *egl_fbs[2];
+	EGLImageKHR egl_images[2];
 	for (size_t fb_index = 0; fb_index < 2; fb_index++) {
 		uint32_t format = GBM_FORMAT_XRGB8888;
 		if (test_page_flip_format_change && fb_index) {
@@ -169,6 +170,7 @@
 			bs_debug_error("failed to create framebuffer from EGLImageKHR");
 			return 1;
 		}
+		egl_images[fb_index] = egl_image;
 	}
 
 	int ret = drmModeSetCrtc(fd, pipe.crtc_id, ids[0], 0 /* x */, 0 /* y */, &pipe.connector_id,
@@ -215,6 +217,12 @@
 
 		usleep(1e6 / 120); /* 120 Hz */
 		glFinish();
+
+		if (!bs_egl_image_flush_external(egl, egl_images[fb_idx])) {
+			bs_debug_error("failed to call image_flush_external");
+			return 1;
+		}
+
 		ret = drmModePageFlip(fd, pipe.crtc_id, ids[fb_idx], DRM_MODE_PAGE_FLIP_EVENT,
 				      &waiting_for_flip);
 		if (ret) {