From patchwork Thu Mar 25 10:16:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 88174 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2PAGu9Z001952 for ; Thu, 25 Mar 2010 10:17:31 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FC429F613; Thu, 25 Mar 2010 03:16:55 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from azsmga101.ch.intel.com (mga07.intel.com [143.182.124.22]) by gabe.freedesktop.org (Postfix) with ESMTP id 84B0F9F380 for ; Thu, 25 Mar 2010 03:16:54 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 25 Mar 2010 03:16:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,306,1267430400"; d="scan'208";a="258527646" Received: from unknown (HELO localhost.localdomain) ([10.255.17.202]) by azsmga001.ch.intel.com with ESMTP; 25 Mar 2010 03:16:52 -0700 From: Chris Wilson To: Jeff Chua Date: Thu, 25 Mar 2010 10:16:44 +0000 Message-Id: <1269512204-24312-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.0.3 In-Reply-To: References: Cc: intel-gfx@lists.freedesktop.org, Petr Vandrovec Subject: [Intel-gfx] [PATCH] uxa: Perform the xrgb -> argb conversion not inplace X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 25 Mar 2010 10:17:31 +0000 (UTC) diff --git a/src/i830_uxa.c b/src/i830_uxa.c index 3af4042..4199f2e 100644 --- a/src/i830_uxa.c +++ b/src/i830_uxa.c @@ -650,6 +650,54 @@ static void i830_uxa_finish_access(PixmapPtr pixmap) pixmap->devPrivate.ptr = NULL; } +static Bool i830_bo_put_image(PixmapPtr pixmap, dri_bo *bo, char *src, int src_pitch, int w, int h) +{ + int stride = i830_pixmap_pitch(pixmap); + + /* fill alpha channel */ + if (pixmap->drawable.depth == 24) { + pixman_image_t *src_image, *dst_image; + + src_image = pixman_image_create_bits (PIXMAN_x8r8g8b8, + w, h, + (uint32_t *) src, src_pitch); + + dst_image = pixman_image_create_bits (PIXMAN_a8r8g8b8, + w, h, + (uint32_t *) bo->virtual, stride); + + if (src_image && dst_image) + pixman_image_composite (PictOpSrc, + src_image, NULL, dst_image, + 0, 0, + 0, 0, + 0, 0, + w, h); + + if (src_image) + pixman_image_unref (src_image); + + if (dst_image) + pixman_image_unref (dst_image); + + if (src_image == NULL|| dst_image == NULL) + return FALSE; + } else if (src_pitch == stride) { + memcpy (bo->virtual, src, stride * h); + } else { + char *dst = bo->virtual; + int row_length = w * pixmap->drawable.bitsPerPixel/8; + int num_rows = h; + while (num_rows--) { + memcpy (dst, src, row_length); + src += src_pitch; + dst += stride; + } + } + + return TRUE; +} + static Bool i830_uxa_pixmap_swap_bo_with_image(PixmapPtr pixmap, char *src, int src_pitch) @@ -662,6 +710,7 @@ i830_uxa_pixmap_swap_bo_with_image(PixmapPtr pixmap, int stride; int w = pixmap->drawable.width; int h = pixmap->drawable.height; + Bool ret; priv = i830_get_pixmap_intel(pixmap); @@ -702,22 +751,11 @@ i830_uxa_pixmap_swap_bo_with_image(PixmapPtr pixmap, return FALSE; } - if (src_pitch == stride) { - memcpy (bo->virtual, src, src_pitch * h); - } else { - char *dst = bo->virtual; - - w *= pixmap->drawable.bitsPerPixel/8; - while (h--) { - memcpy (dst, src, w); - src += src_pitch; - dst += stride; - } - } + ret = i830_bo_put_image(pixmap, bo, src, src_pitch, w, h); drm_intel_gem_bo_unmap_gtt(bo); - return TRUE; + return ret; } static Bool i830_uxa_put_image(PixmapPtr pixmap, @@ -733,33 +771,6 @@ static Bool i830_uxa_put_image(PixmapPtr pixmap, GCPtr gc; Bool ret; - if (pixmap->drawable.depth == 24) { - /* fill alpha channel */ - pixman_image_t *src_image, *dst_image; - - src_image = pixman_image_create_bits (PIXMAN_x8r8g8b8, - w, h, - (uint32_t *) src, src_pitch); - - dst_image = pixman_image_create_bits (PIXMAN_a8r8g8b8, - w, h, - (uint32_t *) src, src_pitch); - - if (src_image && dst_image) - pixman_image_composite (PictOpSrc, - src_image, NULL, dst_image, - 0, 0, - 0, 0, - 0, 0, - w, h); - - if (src_image) - pixman_image_unref (src_image); - - if (dst_image) - pixman_image_unref (dst_image); - } - if (x == 0 && y == 0 && w == pixmap->drawable.width && h == pixmap->drawable.height) @@ -770,9 +781,10 @@ static Bool i830_uxa_put_image(PixmapPtr pixmap, } priv = i830_get_pixmap_intel(pixmap); - if (priv->batch_read_domains || drm_intel_bo_busy(priv->bo)) { + if (priv->batch_read_domains || + drm_intel_bo_busy(priv->bo) || + pixmap->drawable.depth == 24) { dri_bo *bo; - int stride; /* Partial replacement, copy incoming image to a bo and blit. */ scratch = (*screen->CreatePixmap)(screen, w, h, @@ -789,22 +801,15 @@ static Bool i830_uxa_put_image(PixmapPtr pixmap, return FALSE; } - stride = i830_pixmap_pitch(scratch); - if (src_pitch == stride) { - memcpy (bo->virtual, src, stride * h); - } else { - char *dst = bo->virtual; - int row_length = w * pixmap->drawable.bitsPerPixel/8; - int num_rows = h; - while (num_rows--) { - memcpy (dst, src, row_length); - src += src_pitch; - dst += stride; - } - } + ret = i830_bo_put_image(scratch, bo, src, src_pitch, w, h); drm_intel_gem_bo_unmap_gtt(bo); scratch_pixmap = FALSE; + + if (!ret) { + (*screen->DestroyPixmap) (scratch); + return FALSE; + } } else { /* bo is not busy so can be mapped without a stall, upload in-place. */ scratch = GetScratchPixmapHeader(screen, w, h,