From patchwork Mon Jul 25 13:56:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3086 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9E56023E54 for ; Mon, 25 Jul 2011 13:57:32 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 6749CA183B4 for ; Mon, 25 Jul 2011 13:57:32 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3003702qwb.11 for ; Mon, 25 Jul 2011 06:57:32 -0700 (PDT) Received: by 10.229.25.212 with SMTP id a20mr3469917qcc.148.1311602252157; Mon, 25 Jul 2011 06:57:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs77887qcb; Mon, 25 Jul 2011 06:57:31 -0700 (PDT) Received: by 10.204.37.11 with SMTP id v11mr1365923bkd.339.1311602250956; Mon, 25 Jul 2011 06:57:30 -0700 (PDT) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx.google.com with ESMTPS id 18si7042659fat.105.2011.07.25.06.57.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) client-ip=209.85.161.44; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) smtp.mail=alexandros.frantzis@linaro.org Received: by mail-fx0-f44.google.com with SMTP id 6so6802455fxe.17 for ; Mon, 25 Jul 2011 06:57:30 -0700 (PDT) Received: by 10.223.72.149 with SMTP id m21mr6894110faj.52.1311602219955; Mon, 25 Jul 2011 06:56:59 -0700 (PDT) Received: from localhost (77.49.93.204.dsl.dyn.forthnet.gr [77.49.93.204]) by mx.google.com with ESMTPS id n27sm3803788faa.28.2011.07.25.06.56.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:56:59 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 02/21] gl: Store the GL flavor (Desktop or ES) in the device struct Date: Mon, 25 Jul 2011 16:56:29 +0300 Message-Id: <1311602208-5973-2-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> References: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis Signed-off-by: Chris Wilson --- src/cairo-gl-device.c | 1 + src/cairo-gl-info.c | 16 ++++++++++++++++ src/cairo-gl-private.h | 11 +++++++++++ 3 files changed, 28 insertions(+), 0 deletions(-) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index d206da8..35339aa 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -183,6 +183,7 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) _cairo_gl_has_extension ("GL_MESA_pack_invert"); ctx->current_operator = -1; + ctx->gl_flavor = _cairo_gl_get_flavor (); status = _cairo_gl_context_init_shaders (ctx); if (unlikely (status)) diff --git a/src/cairo-gl-info.c b/src/cairo-gl-info.c index 168d194..12a618d 100644 --- a/src/cairo-gl-info.c +++ b/src/cairo-gl-info.c @@ -55,6 +55,22 @@ _cairo_gl_get_version (void) return CAIRO_GL_VERSION_ENCODE (major, minor); } +cairo_gl_flavor_t +_cairo_gl_get_flavor (void) +{ + const char *version = (const char *) glGetString (GL_VERSION); + cairo_gl_flavor_t flavor; + + if (version == NULL) + flavor = CAIRO_GL_FLAVOR_NONE; + else if (strstr (version, "OpenGL ES") != NULL) + flavor = CAIRO_GL_FLAVOR_ES; + else + flavor = CAIRO_GL_FLAVOR_DESKTOP; + + return flavor; +} + cairo_bool_t _cairo_gl_has_extension (const char *ext) { diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 73818b1..602550f 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -86,6 +86,13 @@ /* VBO size that we allocate, smaller size means we gotta flush more often */ #define CAIRO_GL_VBO_SIZE 16384 +/* GL flavor */ +typedef enum cairo_gl_flavor { + CAIRO_GL_FLAVOR_NONE = 0, + CAIRO_GL_FLAVOR_DESKTOP = 1, + CAIRO_GL_FLAVOR_ES = 2 +} cairo_gl_flavor_t; + /* Indices for vertex attributes used by BindAttribLocation etc */ enum { CAIRO_GL_VERTEX_ATTRIB_INDEX = 0, @@ -279,6 +286,7 @@ struct _cairo_gl_context { cairo_bool_t has_mesa_pack_invert; cairo_gl_dispatch_t dispatch; GLfloat modelviewprojection_matrix[16]; + cairo_gl_flavor_t gl_flavor; void (*acquire) (void *ctx); void (*release) (void *ctx); @@ -557,6 +565,9 @@ _cairo_gl_shader_fini (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader); cairo_private int _cairo_gl_get_version (void); +cairo_private cairo_gl_flavor_t +_cairo_gl_get_flavor (void); + cairo_private cairo_bool_t _cairo_gl_has_extension (const char *ext);