From patchwork Sat Nov 17 21:11:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Anholt X-Patchwork-Id: 1759971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 2BB003FC8A for ; Sat, 17 Nov 2012 21:13:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A121E5EF2 for ; Sat, 17 Nov 2012 13:13:40 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from annarchy.freedesktop.org (annarchy.freedesktop.org [131.252.210.176]) by gabe.freedesktop.org (Postfix) with ESMTP id DEE70E5EE7; Sat, 17 Nov 2012 13:11:16 -0800 (PST) Received: from eliezer.anholt.net (annarchy.freedesktop.org [127.0.0.1]) by annarchy.freedesktop.org (Postfix) with ESMTP id BDB5B648A7; Sat, 17 Nov 2012 13:11:16 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id D7999E63B27; Sat, 17 Nov 2012 13:11:14 -0800 (PST) From: Eric Anholt To: intel-gfx@lists.freedesktop.org Date: Sat, 17 Nov 2012 13:11:13 -0800 Message-Id: <1353186674-7234-6-git-send-email-eric@anholt.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353186674-7234-1-git-send-email-eric@anholt.net> References: <1353186674-7234-1-git-send-email-eric@anholt.net> Subject: [Intel-gfx] [PATCH 6/7] uxa: Refactor early-exit paths of uxa_try_driver_composite(). X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 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+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Saves 200b of code at -O2. I noticed this while fixing up the warning in HEAD~1. --- uxa/uxa-render.c | 79 +++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c index d783ea2..3678f6a 100644 --- a/uxa/uxa-render.c +++ b/uxa/uxa-render.c @@ -965,8 +965,9 @@ uxa_try_driver_composite(CARD8 op, int xDst_copy = 0, yDst_copy = 0; int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y; PixmapPtr pSrcPix, pMaskPix = NULL, pDstPix; - PicturePtr localSrc, localMask = NULL; + PicturePtr localSrc = NULL, localMask = NULL; PicturePtr localDst = pDst; + int ret = 0; if (uxa_screen->info->check_composite && !(*uxa_screen->info->check_composite) (op, pSrc, pMask, pDst, width, height)) @@ -1018,9 +1019,8 @@ uxa_try_driver_composite(CARD8 op, pDstPix = uxa_get_offscreen_pixmap(localDst->pDrawable, &dst_off_x, &dst_off_y); if (!pDstPix) { - if (localDst != pDst) - FreePicture(localDst, 0); - return -1; + ret = -1; + goto error; } xDst += localDst->pDrawable->x; @@ -1031,9 +1031,8 @@ uxa_try_driver_composite(CARD8 op, width, height, &xSrc, &ySrc); if (!localSrc) { - if (localDst != pDst) - FreePicture(localDst, 0); - return 0; + ret = 0; + goto error; } if (pMask) { @@ -1042,72 +1041,38 @@ uxa_try_driver_composite(CARD8 op, width, height, &xMask, &yMask); if (!localMask) { - if (localSrc != pSrc) - FreePicture(localSrc, 0); - if (localDst != pDst) - FreePicture(localDst, 0); - - return 0; + ret = 0; + goto error; } } if (!miComputeCompositeRegion(®ion, localSrc, localMask, localDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height)) { - if (localSrc != pSrc) - FreePicture(localSrc, 0); - if (localMask && localMask != pMask) - FreePicture(localMask, 0); - if (localDst != pDst) - FreePicture(localDst, 0); - - return 1; + ret = 1; + goto error; } pSrcPix = uxa_get_offscreen_pixmap(localSrc->pDrawable, &src_off_x, &src_off_y); if (!pSrcPix) { - REGION_UNINIT(screen, ®ion); - - if (localSrc != pSrc) - FreePicture(localSrc, 0); - if (localMask && localMask != pMask) - FreePicture(localMask, 0); - if (localDst != pDst) - FreePicture(localDst, 0); - - return 0; + ret = 0; + goto error; } if (localMask) { pMaskPix = uxa_get_offscreen_pixmap(localMask->pDrawable, &mask_off_x, &mask_off_y); if (!pMaskPix) { - REGION_UNINIT(screen, ®ion); - - if (localSrc != pSrc) - FreePicture(localSrc, 0); - if (localMask && localMask != pMask) - FreePicture(localMask, 0); - if (localDst != pDst) - FreePicture(localDst, 0); - - return 0; + ret = 0; + goto error; } } if (!(*uxa_screen->info->prepare_composite) (op, localSrc, localMask, localDst, pSrcPix, pMaskPix, pDstPix)) { - REGION_UNINIT(screen, ®ion); - - if (localSrc != pSrc) - FreePicture(localSrc, 0); - if (localMask && localMask != pMask) - FreePicture(localMask, 0); - if (localDst != pDst) - FreePicture(localDst, 0); - - return -1; + ret = -1; + goto error; } if (pMask) { @@ -1156,6 +1121,18 @@ uxa_try_driver_composite(CARD8 op, } return 1; + +error: + REGION_UNINIT(screen, ®ion); + + if (localSrc && localSrc != pSrc) + FreePicture(localSrc, 0); + if (localMask && localMask != pMask) + FreePicture(localMask, 0); + if (localDst != pDst) + FreePicture(localDst, 0); + + return ret; } /**