From nobody Fri Nov 14 19:43:48 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1762141079; cv=none; d=zohomail.com; s=zohoarc; b=V3ZtO3hIIkgSXp94wgzm9zKcYZqqNqZ+uF1860bcNLEt9Z6a0Lax8JnDpiETy1/zcSz12o8Tvj/1+rxIvsHsgEh7tGYCpBEAl6A32sw8yAzIUYkbuXlmUdn6lvPZiqm6CDFAo6D5DKI7V7aWLIQw7CMSE4ijDe2XbSYvhFpgiwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762141079; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cMbXfgZRuT2nh3bxQp6pTWkQzuGProvthfWpUuX6w4o=; b=k/8+7cKAGuDe3kpTNrD+f4O5NtWGJL2P0UKYeffd3wbbuCwcBQ5bfodtrSacnc+fCDCRtATZ95sPCMYyKg9ca65iu2NTcW2e+YXlJJODb+VtA6x+WmVaXZfnU5C3LIOSQowtJFyHMToS63oxh/oU5CQ350bwEOmGs58z9DOPTsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762141079797837.9411143524637; Sun, 2 Nov 2025 19:37:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFlN3-0005jm-10; Sun, 02 Nov 2025 22:36:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vFlMw-0005hJ-85 for qemu-devel@nongnu.org; Sun, 02 Nov 2025 22:36:35 -0500 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vFlMr-00080y-Vj for qemu-devel@nongnu.org; Sun, 02 Nov 2025 22:36:32 -0500 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3EC86140010B; Sun, 2 Nov 2025 22:36:28 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sun, 02 Nov 2025 22:36:28 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 2 Nov 2025 22:36:27 -0500 (EST) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 3e75ec8a; Mon, 3 Nov 2025 03:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1762140988; x= 1762227388; bh=cMbXfgZRuT2nh3bxQp6pTWkQzuGProvthfWpUuX6w4o=; b=H xNTZc341Y7TSAAh3MlLT9TZEyEfA9FmeGvMOB+ud3WtZFB6t/+jGJ257R1HxPRGM Z+GtUcwz5tBk5ubr+vXEW3vztuB9qLDo2nUp+2N3N6M3RyXI60IpJvPjQaBrJ2ti IwdidGVqMqL8kjALzz3mS4QbttNUoKxAo3SwoNqNxxxfhMXtwsTG9pItMxPacMOJ nDwaWLxCwUZxUVUVAexPeL/WPBDCjGw7zYdoLdADZcbNCNIROe00N42Cfew6j8aX 6xNwTUHZa+BTygNzNvdP8NksTjVaZboX2eD4oOUl2Xr30BPEWxkjGhQI/ED4CfyC Jbj3tMu7MtSQCedKtNH4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762140988; x=1762227388; bh=c MbXfgZRuT2nh3bxQp6pTWkQzuGProvthfWpUuX6w4o=; b=c1q+F8B4XlWt/DyGi ptR79PmqOWIUJbS+MlblgH0vmLtbgYVcuead3umdeijIvHR7AqcLc52ypFVa66Yb DD5AViKDIvyWBWgTT5jvbgVCxxionu5i2g1ZlWxS8OZW7rTdwTdE3bRQt7As2hVq x9hoJV/9JXOUBg/9w9d2LHYsM7Neukfi03kOIzWbO9qwXBPiHIf8ePZnuDV/zZlO B2c3WmZ89pt9zQI6LVJ4OVccAR1Sa9E4rOYxnRj7KDjsSBxmqx+p2MCWduW6mJz8 GQiXVuNSUiL3m5aa26emZPaKyePYaFCmIlBbn8FDOGsJmAuoeeJT4I8nnFfhLt6N eyTBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddujeejtdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeevhhgrugculfgrsghlohhnshhk ihcuoegthhgrugesjhgrsghlohhnshhkihdrgiihiieqnecuggftrfgrthhtvghrnhepgf eiteejhfelheefieetjefgleejfffhueffvdduieejgfeuueeuvddvkeejhfelnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheptghhrggusehjrg gslhhonhhskhhirdighiiipdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhu thdprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuhdprhgtphhtthhope hqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghpthhtoheptghhrggusehj rggslhhonhhskhhirdighiii X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: balaton@eik.bme.hu, Chad Jablonski Subject: [PATCH v2 6/7] ati-vga: Add expand_colors() helper for monochrome color expansion Date: Sun, 2 Nov 2025 22:36:07 -0500 Message-ID: <20251103033608.120908-7-chad@jablonski.xyz> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103033608.120908-1-chad@jablonski.xyz> References: <20251103033608.120908-1-chad@jablonski.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.153; envelope-from=chad@jablonski.xyz; helo=fhigh-a2-smtp.messagingengine.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, PDS_OTHER_BAD_TLD=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1762141084834158500 Content-Type: text/plain; charset="utf-8" Convert 1bpp monochrome images to 32bpp ARGB given a foreground and background color. This also supports most significant and least significant bit ordering. This is useful for host data transfers of glyphs when drawing text in X. Signed-off-by: Chad Jablonski --- hw/display/ati_2d.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 15cf29a061..181bf634f0 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -45,6 +45,28 @@ static int ati_bpp_from_datatype(ATIVGAState *s) } =20 #define DEFAULT_CNTL (s->regs.dp_gui_master_cntl & GMC_DST_PITCH_OFFSET_CN= TL) +/* Convert 1bpp monochrome data to 32bpp ARGB using color expansion */ +static void expand_colors(uint8_t *color_dst, const uint8_t *mono_src, + uint32_t width, uint32_t height, + uint32_t fg_color, uint32_t bg_color, + bool lsb_to_msb) +{ + uint32_t byte, color; + uint8_t *pixel; + int i, j, bit; + /* Rows are 32-bit aligned */ + int bytes_per_row =3D ((width + 31) / 32) * 4; + + for (i =3D 0; i < height; i++) { + for (j =3D 0; j < width; j++) { + byte =3D mono_src[i * bytes_per_row + (j / 8)]; + bit =3D lsb_to_msb ? 7 - (j % 8) : j % 8; + color =3D (byte >> bit) & 0x1 ? fg_color : bg_color; + pixel =3D &color_dst[(i * width + j) * 4]; + memcpy(pixel, &color, sizeof(color)); + } + } +} =20 void ati_2d_blt(ATIVGAState *s) { --=20 2.51.0