From patchwork Thu Aug 4 11:02:23 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: 3263 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 BD4CF24070 for ; Thu, 4 Aug 2011 11:02:26 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6488BA18207 for ; Thu, 4 Aug 2011 11:02:26 +0000 (UTC) Received: by qyk31 with SMTP id 31so381380qyk.11 for ; Thu, 04 Aug 2011 04:02:25 -0700 (PDT) Received: by 10.229.44.195 with SMTP id b3mr505561qcf.7.1312455745743; Thu, 04 Aug 2011 04:02:25 -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.6.73 with SMTP id 9cs10522qcy; Thu, 4 Aug 2011 04:02:25 -0700 (PDT) Received: by 10.216.38.77 with SMTP id z55mr565163wea.105.1312455744431; Thu, 04 Aug 2011 04:02:24 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id b48si3587086wed.9.2011.08.04.04.02.24; Thu, 04 Aug 2011 04:02:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Qovh1-0007fW-N3 for ; Thu, 04 Aug 2011 11:02:23 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id ABF342E8067 for ; Thu, 4 Aug 2011 11:02:23 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glcompbench X-Launchpad-Branch: ~glcompbench-dev/glcompbench/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 55 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 55: Refactor the CompositeWindow update_texture*() interface. Message-Id: <20110804110223.10479.36713.launchpad@loganberry.canonical.com> Date: Thu, 04 Aug 2011 11:02:23 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13604"; Instance="initZopeless config overlay" X-Launchpad-Hash: ef11ea3c0f058ca1be68d3359535ad5716639d75 ------------------------------------------------------------ revno: 55 committer: Alexandros Frantzis branch nick: trunk timestamp: Wed 2011-08-03 15:34:10 +0100 message: Refactor the CompositeWindow update_texture*() interface. modified: src/composite-canvas.cc src/composite-window-eglimage.cc src/composite-window-eglimage.h src/composite-window-gl.cc src/composite-window-gl.h src/composite-window-glxpixmap.cc src/composite-window-glxpixmap.h src/composite-window-pixman.cc src/composite-window-pixman.h src/composite-window-ximage.cc src/composite-window-ximage.h src/composite-window.cc src/composite-window.h --- lp:glcompbench https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk You are subscribed to branch lp:glcompbench. To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription === modified file 'src/composite-canvas.cc' --- src/composite-canvas.cc 2011-07-18 13:28:08 +0000 +++ src/composite-canvas.cc 2011-08-03 14:34:10 +0000 @@ -448,7 +448,7 @@ { CompositeWindow *comp_win = *iter; if (comp_win->get_texture().is_valid()) - comp_win->update_texture_from_pixmap(false); + comp_win->update_texture_from_pixmap(); } } === modified file 'src/composite-window-eglimage.cc' --- src/composite-window-eglimage.cc 2011-04-04 12:56:06 +0000 +++ src/composite-window-eglimage.cc 2011-08-03 14:34:10 +0000 @@ -37,34 +37,44 @@ CompositeWindowEGLImage::~CompositeWindowEGLImage() { - if (egl_image_) + release_tfp(); +} + +void +CompositeWindowEGLImage::release_tfp() +{ + if (egl_image_) { eglDestroyImageKHR_(egl_display_, egl_image_); + egl_image_ = 0; + } } void -CompositeWindowEGLImage::update_texture_from_pixmap(bool recreate) +CompositeWindowEGLImage::update_texture() { + CompositeWindowGL::update_texture(); + const EGLint egl_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; + release_tfp(); + + egl_image_ = eglCreateImageKHR_(egl_display_, EGL_NO_CONTEXT, + EGL_NATIVE_PIXMAP_KHR, + reinterpret_cast(pix_), + egl_image_attribs); + + Log::debug(" => EGLImage <= %p\n", egl_image_); + Log::debug(" => eglError 0x%x\n", eglGetError()); +} + +void +CompositeWindowEGLImage::update_texture_from_pixmap() +{ Profiler::ScopedSamples scoped_tfp(CompositeWindow::get_profiler_tfp_pair()); - if (recreate) { - if (egl_image_) { - eglDestroyImageKHR_(egl_display_, egl_image_); - egl_image_ = 0; - } - egl_image_ = eglCreateImageKHR_(egl_display_, EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, - reinterpret_cast(pix_), - egl_image_attribs); - - Log::debug(" => EGLImage <= %p\n", egl_image_); - Log::debug(" => eglError 0x%x\n", eglGetError()); - } - /* Update texture with new data */ eglWaitNative(EGL_CORE_NATIVE_ENGINE); === modified file 'src/composite-window-eglimage.h' --- src/composite-window-eglimage.h 2011-07-15 08:16:54 +0000 +++ src/composite-window-eglimage.h 2011-08-03 14:34:10 +0000 @@ -39,9 +39,11 @@ egl_image_(0), egl_display_(egl_display) {} ~CompositeWindowEGLImage(); - void update_texture_from_pixmap(bool recreate); + void update_texture(); + void update_texture_from_pixmap(); private: + void release_tfp(); EGLImageKHR egl_image_; EGLDisplay egl_display_; }; === modified file 'src/composite-window-gl.cc' --- src/composite-window-gl.cc 2011-07-15 08:16:54 +0000 +++ src/composite-window-gl.cc 2011-08-03 14:34:10 +0000 @@ -30,11 +30,9 @@ glDeleteTextures(1, &tex_); } -bool +void CompositeWindowGL::update_texture() { - bool ret = false; - if (!tex_ && attr_.map_state != 0) { glGenTextures(1, &tex_); @@ -45,14 +43,10 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Log::debug(" => texture <= 0x%x\n", (unsigned) tex_); - ret = true; } else if (tex_ && attr_.map_state == 0) { Log::debug(" => Deleting texture 0x%x\n", (unsigned) tex_); glDeleteTextures(1, &tex_); - tex_ = 0; } - - return ret; } === modified file 'src/composite-window-gl.h' --- src/composite-window-gl.h 2011-07-15 08:16:54 +0000 +++ src/composite-window-gl.h 2011-08-03 14:34:10 +0000 @@ -36,7 +36,7 @@ virtual ~CompositeWindowGL(); virtual Texture get_texture() { return CompositeWindow::Texture(tex_); } - virtual bool update_texture(); + virtual void update_texture(); protected: GLuint tex_; === modified file 'src/composite-window-glxpixmap.cc' --- src/composite-window-glxpixmap.cc 2011-07-20 09:17:11 +0000 +++ src/composite-window-glxpixmap.cc 2011-08-03 14:34:10 +0000 @@ -52,24 +52,28 @@ } void -CompositeWindowGLXPixmap::update_texture_from_pixmap(bool recreate) +CompositeWindowGLXPixmap::update_texture() { + CompositeWindowGL::update_texture(); + const int pixmap_attribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, None }; + release_tfp(); + glx_pixmap_ = glXCreatePixmap(xdpy_, glx_fbconfig_, pix_, + pixmap_attribs); + + Log::debug(" => GLXPixmap <= %p\n", glx_pixmap_); +} + +void +CompositeWindowGLXPixmap::update_texture_from_pixmap() +{ Profiler::ScopedSamples scoped_tfp(CompositeWindow::get_profiler_tfp_pair()); - if (recreate) { - release_tfp(); - glx_pixmap_ = glXCreatePixmap(xdpy_, glx_fbconfig_, pix_, - pixmap_attribs); - - Log::debug(" => GLXPixmap <= %p\n", glx_pixmap_); - } - /* Update texture with new data */ glXWaitX(); === modified file 'src/composite-window-glxpixmap.h' --- src/composite-window-glxpixmap.h 2011-07-20 08:23:33 +0000 +++ src/composite-window-glxpixmap.h 2011-08-03 14:34:10 +0000 @@ -37,7 +37,8 @@ glx_fbconfig_ (glx_fbconfig), glx_pixmap_bound_(false) {} ~CompositeWindowGLXPixmap(); - void update_texture_from_pixmap(bool recreate); + void update_texture(); + void update_texture_from_pixmap(); private: void release_tfp(); === modified file 'src/composite-window-pixman.cc' --- src/composite-window-pixman.cc 2011-07-19 16:01:23 +0000 +++ src/composite-window-pixman.cc 2011-08-03 14:34:10 +0000 @@ -188,31 +188,31 @@ } void -CompositeWindowPixman::update_texture_from_pixmap(bool recreate) +CompositeWindowPixman::update_texture() +{ + release_resources(); + + if (use_shm_) { + if (!ensure_ximage_shm() || !ensure_pixman_image()) + return; + } + else { + if (!ensure_ximage() || !ensure_pixman_image()) + return; + } +} + +void +CompositeWindowPixman::update_texture_from_pixmap() { Profiler::ScopedSamples scoped_tfp(CompositeWindow::get_profiler_tfp_pair()); - if (recreate) - release_resources(); - if (use_shm_) { - if (!ensure_ximage_shm() || !ensure_pixman_image()) - return; - XShmGetImage(xdpy_, pix_, ximage_, 0, 0, AllPlanes); } else { - if (!ensure_ximage() || !ensure_pixman_image()) - return; - XGetSubImage(xdpy_, pix_, 0, 0, width_, height_, AllPlanes, ZPixmap, ximage_, 0, 0); } } - -bool -CompositeWindowPixman::update_texture() -{ - return false; -} === modified file 'src/composite-window-pixman.h' --- src/composite-window-pixman.h 2011-07-18 16:26:56 +0000 +++ src/composite-window-pixman.h 2011-08-03 14:34:10 +0000 @@ -47,8 +47,8 @@ return CompositeWindow::Texture(pixman_image_); } - bool update_texture(); - void update_texture_from_pixmap(bool recreate); + void update_texture(); + void update_texture_from_pixmap(); private: bool have_xshm(); === modified file 'src/composite-window-ximage.cc' --- src/composite-window-ximage.cc 2011-04-04 12:56:06 +0000 +++ src/composite-window-ximage.cc 2011-08-03 14:34:10 +0000 @@ -36,23 +36,27 @@ } void -CompositeWindowXImage::update_texture_from_pixmap(bool recreate) +CompositeWindowXImage::update_texture() +{ + CompositeWindowGL::update_texture(); + + glBindTexture(GL_TEXTURE_2D, tex_); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + width_, height_, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); +} + +void +CompositeWindowXImage::update_texture_from_pixmap() { Profiler::ScopedSamples scoped_tfp(CompositeWindow::get_profiler_tfp_pair()); - glBindTexture(GL_TEXTURE_2D, tex_); - - if (recreate) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, - width_, height_, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - } - if (ximage_) XDestroyImage(ximage_); ximage_ = XGetImage(xdpy_, pix_, 0, 0, width_, height_, AllPlanes, ZPixmap); if (ximage_) { + glBindTexture(GL_TEXTURE_2D, tex_); /* * Note that the data we get from the pixmap is BGRA but the texture * expects RGBA, so what we are doing here is technically incorrect === modified file 'src/composite-window-ximage.h' --- src/composite-window-ximage.h 2011-07-15 08:16:54 +0000 +++ src/composite-window-ximage.h 2011-08-03 14:34:10 +0000 @@ -35,7 +35,8 @@ CompositeWindowGL(xdpy, win), ximage_(0) {} ~CompositeWindowXImage(); - void update_texture_from_pixmap(bool recreate); + void update_texture(); + void update_texture_from_pixmap(); private: XImage *ximage_; === modified file 'src/composite-window.cc' --- src/composite-window.cc 2011-07-15 08:16:54 +0000 +++ src/composite-window.cc 2011-08-03 14:34:10 +0000 @@ -96,10 +96,10 @@ } /* Create or delete texture if needed */ - update_tfp = update_texture() || update_tfp; - - if (update_tfp) - update_texture_from_pixmap(true); + if (update_tfp) { + update_texture(); + update_texture_from_pixmap(); + } /* * We have to free the pixmap after calling update_texture_from_pixmap(), @@ -123,5 +123,5 @@ if (damage_) XDamageSubtract(xdpy_, damage_, None, None); - update_texture_from_pixmap(false); + update_texture_from_pixmap(); } === modified file 'src/composite-window.h' --- src/composite-window.h 2011-07-15 08:16:54 +0000 +++ src/composite-window.h 2011-08-03 14:34:10 +0000 @@ -49,8 +49,13 @@ Window get_xwindow(); virtual Texture get_texture() = 0; - virtual bool update_texture() = 0; - virtual void update_texture_from_pixmap(bool recreate) = 0; + /* + * Update the texture itself (whatever that happens + * to be, eg GL texture + TFP, pixman image) + */ + virtual void update_texture() = 0; + /* Update the texture contents from the pixmap */ + virtual void update_texture_from_pixmap() = 0; protected: Display *xdpy_;