From patchwork Mon Jul 25 13:56:37 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: 3084 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 0BF0923E54 for ; Mon, 25 Jul 2011 13:57:28 +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 C9318A183B4 for ; Mon, 25 Jul 2011 13:57:27 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3003702qwb.11 for ; Mon, 25 Jul 2011 06:57:27 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr3730158qci.114.1311602247510; Mon, 25 Jul 2011 06:57:27 -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 hl14cs77882qcb; Mon, 25 Jul 2011 06:57:27 -0700 (PDT) Received: by 10.14.11.97 with SMTP id 73mr1540949eew.138.1311602246428; Mon, 25 Jul 2011 06:57:26 -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.26 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:26 -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:26 -0700 (PDT) Received: by 10.223.15.81 with SMTP id j17mr310060faa.20.1311602246007; Mon, 25 Jul 2011 06:57:26 -0700 (PDT) Received: from localhost (77.49.93.204.dsl.dyn.forthnet.gr [77.49.93.204]) by mx.google.com with ESMTPS id r12sm3809766fam.0.2011.07.25.06.57.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:25 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 10/21] gl: Use conventional texture upload for GLES2 Date: Mon, 25 Jul 2011 16:56:37 +0300 Message-Id: <1311602208-5973-10-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 GLES2 doesn't support Pixel Buffer Objects. Use conventional texture upload for GLES2 (using client-side memory). Signed-off-by: Chris Wilson --- src/cairo-gl-device.c | 3 ++- src/cairo-gl-gradient.c | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index ca7b6e8..92cd82a 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -176,7 +176,8 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) else return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); - if (gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) && + if (gl_flavor == CAIRO_GL_FLAVOR_DESKTOP && + gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) && ! _cairo_gl_has_extension ("GL_ARB_pixel_buffer_object")) return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index 0718c75..862430e 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -234,33 +234,42 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx, gradient->stops = gradient->stops_embedded; memcpy (gradient->stops_embedded, stops, n_stops * sizeof (cairo_gradient_stop_t)); - dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, ctx->texture_load_pbo); - dispatch->BufferData (GL_PIXEL_UNPACK_BUFFER, - tex_width * sizeof (uint32_t), 0, GL_STREAM_DRAW); - data = dispatch->MapBuffer (GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + glGenTextures (1, &gradient->tex); + _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); + glBindTexture (ctx->tex_target, gradient->tex); - status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width); + /* GL_PIXEL_UNPACK_BUFFER is only available in Desktop GL */ + if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) { + dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, ctx->texture_load_pbo); + dispatch->BufferData (GL_PIXEL_UNPACK_BUFFER, + tex_width * sizeof (uint32_t), 0, GL_STREAM_DRAW); + data = dispatch->MapBuffer (GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); - dispatch->UnmapBuffer (GL_PIXEL_UNPACK_BUFFER); + status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width); - if (unlikely (status)) { - dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); - free (gradient); - return status; - } + dispatch->UnmapBuffer (GL_PIXEL_UNPACK_BUFFER); - glGenTextures (1, &gradient->tex); - _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); - glBindTexture (ctx->tex_target, gradient->tex); + if (unlikely (status)) { + dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); + free (gradient); + return status; + } - if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) glTexImage2D (ctx->tex_target, 0, GL_RGBA8, tex_width, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); - else + + dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); + } + else { + data = _cairo_malloc_ab (tex_width, sizeof (uint32_t)); + + status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width); + glTexImage2D (ctx->tex_target, 0, GL_BGRA, tex_width, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, data); - dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); + free (data); + } /* we ignore errors here and just return an uncached gradient */ if (likely (! _cairo_cache_insert (&ctx->gradients, &gradient->cache_entry)))