st/egl: Add get_param to native display interface.
authorChia-I Wu <olv@lunarg.com>
Fri, 5 Mar 2010 03:00:15 +0000 (11:00 +0800)
committerChia-I Wu <olv@lunarg.com>
Fri, 5 Mar 2010 03:32:29 +0000 (11:32 +0800)
get_param can be used to query the parameters of a native display.
There is only NATIVE_PARAM_USE_NATIVE_BUFFER right now.  It queries
whether the window/pixmap surfaces use the native buffers instead of
private buffers.

src/gallium/state_trackers/egl/common/native.h
src/gallium/state_trackers/egl/kms/native_kms.c
src/gallium/state_trackers/egl/x11/native_dri2.c
src/gallium/state_trackers/egl/x11/native_ximage.c

index 4533b3abf97b4ca32d574ef01430e1dce96d7d82..9c22ff3e4322f9de0ca7bac32f99ad92c0dbcd68 100644 (file)
@@ -49,6 +49,14 @@ enum native_attachment {
    NUM_NATIVE_ATTACHMENTS
 };
 
+enum native_param_type {
+   /*
+    * Return TRUE if window/pixmap surfaces use the buffers of the native
+    * types.
+    */
+   NATIVE_PARAM_USE_NATIVE_BUFFER
+};
+
 /**
  * Enumerations for probe results.
  */
@@ -145,6 +153,14 @@ struct native_display {
 
    void (*destroy)(struct native_display *ndpy);
 
+   /**
+    * Query the parameters of the native display.
+    *
+    * The return value is defined by the parameter.
+    */
+   int (*get_param)(struct native_display *ndpy,
+                    enum native_param_type param);
+
    /**
     * Get the supported configs.  The configs are owned by the display, but
     * the returned array should be free()ed.
index 90c82eaf6ce4d93af828d9e953412f90ccf74b9d..94588bfa7430de97ab19c42945d336eb6b7e1c3a 100644 (file)
@@ -665,6 +665,21 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)
    return configs;
 }
 
+static int
+kms_display_get_param(struct native_display *ndpy,
+                      enum native_param_type param)
+{
+   int val;
+
+   switch (param) {
+   default:
+      val = 0;
+      break;
+   }
+
+   return val;
+}
+
 static void
 kms_display_destroy(struct native_display *ndpy)
 {
@@ -811,6 +826,7 @@ kms_create_display(EGLNativeDisplayType dpy,
    }
 
    kdpy->base.destroy = kms_display_destroy;
+   kdpy->base.get_param = kms_display_get_param;
    kdpy->base.get_configs = kms_display_get_configs;
    kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface;
 
index 858033e1c1059e9120ba90544672b1416b4f82ae..8d2a8b1dffe01692cd801bb6ec5e6b5a8f6c8491 100644 (file)
@@ -707,6 +707,25 @@ dri2_display_is_pixmap_supported(struct native_display *ndpy,
    return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));
 }
 
+static int
+dri2_display_get_param(struct native_display *ndpy,
+                       enum native_param_type param)
+{
+   int val;
+
+   switch (param) {
+   case NATIVE_PARAM_USE_NATIVE_BUFFER:
+      /* DRI2GetBuffers use the native buffers */
+      val = TRUE;
+      break;
+   default:
+      val = 0;
+      break;
+   }
+
+   return val;
+}
+
 static void
 dri2_display_destroy(struct native_display *ndpy)
 {
@@ -850,6 +869,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy,
    }
 
    dri2dpy->base.destroy = dri2_display_destroy;
+   dri2dpy->base.get_param = dri2_display_get_param;
    dri2dpy->base.get_configs = dri2_display_get_configs;
    dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
    dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
index 5e0270c296301f294891b30d63563c606347f48d..3421c1951aa250dd9a6de3e37268a551508e3d52 100644 (file)
@@ -699,6 +699,25 @@ ximage_display_is_pixmap_supported(struct native_display *ndpy,
    return (fmt == nconf->color_format);
 }
 
+static int
+ximage_display_get_param(struct native_display *ndpy,
+                         enum native_param_type param)
+{
+   int val;
+
+   switch (param) {
+   case NATIVE_PARAM_USE_NATIVE_BUFFER:
+      /* private buffers are allocated */
+      val = FALSE;
+      break;
+   default:
+      val = 0;
+      break;
+   }
+
+   return val;
+}
+
 static void
 ximage_display_destroy(struct native_display *ndpy)
 {
@@ -753,6 +772,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
    xdpy->base.screen = softpipe_create_screen(xdpy->winsys);
 
    xdpy->base.destroy = ximage_display_destroy;
+   xdpy->base.get_param = ximage_display_get_param;
 
    xdpy->base.get_configs = ximage_display_get_configs;
    xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported;