From patchwork Thu Apr 7 13:42:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Wool X-Patchwork-Id: 1614515 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.a=rsa-sha256 header.s=google header.b=JcIHHB+p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZ2cm521sz9sFk for ; Thu, 7 Apr 2022 23:42:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9EFB83C8C; Thu, 7 Apr 2022 15:42:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="JcIHHB+p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBCB083DE7; Thu, 7 Apr 2022 15:42:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AC11C81CA4 for ; Thu, 7 Apr 2022 15:42:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vitaly.wool@konsulko.com Received: by mail-lf1-x12e.google.com with SMTP id x33so3250165lfu.1 for ; Thu, 07 Apr 2022 06:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2YnNcF8MmVh4AKb48QjhrElv476Gxc5DySZi9NQfUXE=; b=JcIHHB+pJp9lLmyBYRnYyoKDxfYWGVskDGdoAepf0AtKxBRO4KEwZffRpl6S3T1V2y ARaHtaeV8IDBFD0Qg8cDn/ICq+TqMHBRr3sGq31fA275wXwCebYsPBttLov/2Cd9+QKw 4n8rYr/bsrvf+qrfKOMAibXX67+7bPgK0snL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2YnNcF8MmVh4AKb48QjhrElv476Gxc5DySZi9NQfUXE=; b=G8KaeNjmDtZTAHH389v9SmosPw9ylGzzs+paYAYaOnAuhozX/F5Xr2JtW5ACapoQPH HlNwDmirwfxW2TRGkWsEX7dspSKHNfv2H+cttFAmI6REr59Kf+3HNyxw29BK3S2bnWb5 0zZvU8vbBHLcCBUXrcEICpBCyDN3RhGzEd14tB6g3o7TPpQXr006a1vcAB6nojYTAHpw H8G/xHqK8r1X+owyJEweGDRkOad55Ig0zdkGfFFbqnBAUZcGOUxnDLPwfdz1xxG+nd/w r2/GP8GHCn82EuPR2DnLQTCLNqfJxy6olJdmvnVl2SRqBDUf/AqjwomFJrovvZZPn34Q zhsw== X-Gm-Message-State: AOAM533a/fckMa28ETDKRs+2S30tiBhOdsjCZYaSTQ0uPfVVWbPYoFHj KbePZx96oEvftoQce1/TaXZwBQ== X-Google-Smtp-Source: ABdhPJx2yFay4RGFrpK5PxaFnJdcW2h0VR9IEdT/rK1eA1tU84cY3Rz+AuzKZrtdDDnUgiiuOxjsTw== X-Received: by 2002:a05:6512:108b:b0:44a:6dc2:ffeb with SMTP id j11-20020a056512108b00b0044a6dc2ffebmr9696186lfg.184.1649338938836; Thu, 07 Apr 2022 06:42:18 -0700 (PDT) Received: from localhost.localdomain (m37-3-108-72.cust.tele2.se. [37.3.108.72]) by smtp.gmail.com with ESMTPSA id t17-20020a195f11000000b0046a38a272e3sm29338lfb.196.2022.04.07.06.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 06:42:18 -0700 (PDT) From: Vitaly Wool To: Anatolij Gustschin Cc: u-boot@lists.denx.de, Vitaly Wool Subject: [PATCH] Fix BMP display when the image stretches beyond border Date: Thu, 7 Apr 2022 15:42:09 +0200 Message-Id: <20220407134209.2715218-1-vitaly.wool@konsulko.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When an image stretches beyond the display border, one still needs to seek to the next pixel line to display the visible part of that image correctly. Signed-off-by: Vitaly Wool --- drivers/video/video_bmp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 4d2d961696..d0177daf58 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -238,7 +238,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, struct bmp_image *bmp = map_sysmem(bmp_image, 0); uchar *bmap; ushort padded_width; - unsigned long width, height, byte_width; + unsigned long width, vis_width, height, byte_width; unsigned long pwidth = priv->xsize; unsigned colours, bpix, bmp_bpix; enum video_format eformat; @@ -297,8 +297,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, video_splash_align_axis(&y, priv->ysize, height); } - if ((x + width) > pwidth) - width = pwidth - x; + vis_width = min(pwidth - x, width); if ((y + height) > priv->ysize) height = priv->ysize - y; @@ -318,7 +317,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, debug("compressed %d %d\n", compression, BMP_BI_RLE8); if (compression == BMP_BI_RLE8) { video_display_rle8_bitmap(dev, bmp, bpix, palette, fb, - x, y, width, height); + x, y, vis_width, height); break; } } @@ -330,7 +329,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, for (i = 0; i < height; ++i) { WATCHDOG_RESET(); - for (j = 0; j < width; j++) { + for (j = 0; j < vis_width; j++) { write_pix8(fb, bpix, eformat, palette, bmap); bmap++; fb += bpix / 8; @@ -343,7 +342,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, if (IS_ENABLED(CONFIG_BMP_16BPP)) { for (i = 0; i < height; ++i) { WATCHDOG_RESET(); - for (j = 0; j < width; j++) { + for (j = 0; j < vis_width; j++) { *fb++ = *bmap++; *fb++ = *bmap++; } @@ -355,7 +354,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, case 24: if (IS_ENABLED(CONFIG_BMP_24BPP)) { for (i = 0; i < height; ++i) { - for (j = 0; j < width; j++) { + for (j = 0; j < vis_width; j++) { if (bpix == 16) { /* 16bit 565RGB format */ *(u16 *)fb = ((bmap[2] >> 3) @@ -389,7 +388,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, case 32: if (IS_ENABLED(CONFIG_BMP_32BPP)) { for (i = 0; i < height; ++i) { - for (j = 0; j < width; j++) { + for (j = 0; j < vis_width; j++) { if (eformat == VIDEO_X2R10G10B10) { u32 pix;