From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Stipples support in MS-Windows port Date: Mon, 27 May 2024 13:20:17 +0700 Message-ID: References: <87a5l49a53.fsf@yahoo.com> <87seyw7udp.fsf@yahoo.com> <87wmo0zzni.fsf@yahoo.com> <86r0e83gez.fsf@gnu.org> <861q661vgf.fsf@gmail.com> <86le4dvxx9.fsf@gmail.com> <87frulynby.fsf@yahoo.com> <86zfslctt8.fsf@gmail.com> <86r0dwag4n.fsf@gnu.org> <86r0dww9ne.fsf@gmail.com> <86le43x6ss.fsf@gmail.com> <86o78z8jw2.fsf@gnu.org> <86o78yr45t.fsf@gmail.com> <86h6em1hih.fsf@gnu.org> <86cyp9h0xq.fsf@gmail.com> <86o78sm2kt.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9472"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , luangruo@yahoo.com, emacs-devel@gnu.org To: "Elijah G." Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 27 08:21:39 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sBTjm-0002Hy-PB for ged-emacs-devel@m.gmane-mx.org; Mon, 27 May 2024 08:21:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBTix-0006wv-LG; Mon, 27 May 2024 02:20:47 -0400 Original-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 1sBTik-0006v5-4n for emacs-devel@gnu.org; Mon, 27 May 2024 02:20:34 -0400 Original-Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBTii-0003Ar-Lr; Mon, 27 May 2024 02:20:33 -0400 Original-Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-804efaa51c2so485789241.3; Sun, 26 May 2024 23:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716790830; x=1717395630; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sI/iJb5GeOJl6yd/NkguT0pnUrHGfNSteSFk9DCXXls=; b=Wb8E/T01gg4+VCB+7AqWOPbLE5gHkm8Rng7PRibw4pERhws0Anmvk6J6f0No/fhVbM F6Wr33hJlS+YFt/8oTA/C1ovdFtIG+8YCiahCQNuYcKDKNack11C3Ab63QIUSlfEeqMh ucmrFpku0MmuxWc2kZVIUy4SnL+ivt2d7xSWIV+mitTO5BecmgrS6Uxg+jxjGRU/6jcW RRVuwo7bn+X1bmwMNSGsdw6Y40IEeeIRWU4xKbu1xau+Gcuy4p19zZ8lnGnces05IxC/ RAAfpLMIHGEQHgFZ1Efmx9KTpv43uALzPPGF7rsN4vemml4+nq8cpA1/KNy9Clq26+vo BeqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716790830; x=1717395630; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sI/iJb5GeOJl6yd/NkguT0pnUrHGfNSteSFk9DCXXls=; b=G4XaynIq9SGQ4iBsjKHVXGs0nTmipiejfvjg+A1YuHF+eH3tZC3NdKF/r+IxqnYoeI pgAtW2epfnpaA66sToZWATBUWtxSNHuOxQBE0oVh7gIEk4AC+AKC/VOVVuRXzYN5qQQl oXiVIKkltprB0I88Z6++F9wb5g3zc+tBHGkoM1Kyl+MezoHcXx1Yl+RRl/kRHjgC0CqF UCDwDcSd451riGS941riUKMuu4iw+1bGsCuFFRZCCL7T30jGTpRJ+kReUFUo08CctbKh 2ZM7mheTQuX+BJ+fPAxkO9Ft/hXOEghLoj0E9dII0RsYrnQTQhu3xU4yMqsWesJ3umDN M1Cg== X-Forwarded-Encrypted: i=1; AJvYcCVvY7tPwRBpj2bmMUIUanG7poLH+tKiL5kbQkHEv/ot3CM7ayhyHo48Rcj87+bdGVNqTabC0BqEA5qNouYLIcVOhS2v X-Gm-Message-State: AOJu0YwVYNzj4Txrxdbr9OJ6HG55LI6YhCnKy9RiLytlVnNhkCNS7MQp fKNAHYj3+XjOVEqCKk4MyPOCM2Q2nrk8lGtSQgqmADl1nnzgvx4PJnnjZk2NuOhswVmYNfOs/1H ZFeI56MMmCr7tZICW+GMNYvUX4q4= X-Google-Smtp-Source: AGHT+IG0DkH6ci3eEGIGqSKn3ODoGQ0+BiUR+iFBtbGxLIkWqKLqUr5BYpRRNPPOzCiAfAoXKf7jiGQ7vh14MqLIJV8= X-Received: by 2002:a05:6102:1804:b0:47e:5c2e:5695 with SMTP id ada2fe7eead31-48a3864dd30mr8302307137.23.1716790829260; Sun, 26 May 2024 23:20:29 -0700 (PDT) In-Reply-To: <86o78sm2kt.fsf@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x92a.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 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, FREEMAIL_FROM=0.001, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:319598 Archived-At: On Mon, 27 May 2024 at 09:05, Elijah G. wrote: > > Yuri Khan writes: > > > 1. Use CreateCompatibleDC to create a memory DC. > > 2. Select the stipple bitmap into this memory DC using SelectObject. > > 3. Call InvertRect on that DC, passing (0, 0)=E2=80=93(w, h) as the tar= get rectangle. > > Thank you for the advises. > Can you explain why use (0, 0)-(w, h) instead the defined RECT from the > code please? RECT from the code indicates the coordinates where you=E2=80=99re drawing t= he stipple. I=E2=80=99m suggesting you invert the stipple bitmap once after creation so that it could be used without further modifications on each draw. In this case you need to act on the stipple bitmap coordinates. > Here is the current function code with the advises applied (except the > third step that i had to use a defined RECT), but it doesn't seems work > neither, i don't know if i did something wrong when applying the steps: Two things: 1. you invert a RECT defined by coordinates where you draw the stipple, and that is most likely outside the bounds of the stipple bitmap; 2. you=E2=80=99re doing it on each draw of this stipple rather than once, s= o if you fix the RECT, you=E2=80=99ll be inverting the stipple each time so odd-numbered draw calls will come out okay but even-numbered draw calls will again be inverted. > --8<---------------cut here---------------start------------->8--- > static void > w32_fill_stipple_pattern (HDC hdc, struct glyph_string *s, Emacs_GC *gc, > int x, int y, unsigned int width, unsigned int = height) > { =E2=80=A6 > RECT r; > r.left =3D x; > r.top =3D y; > r.right =3D x + width; > r.bottom =3D y + height; =E2=80=A6 > HDC comp_dc =3D CreateCompatibleDC(hdc); > SelectObject (comp_dc, bm); > InvertRect (comp_dc, &r); =E2=80=A6 > } > --8<---------------cut here---------------end--------------->8--- > > Also i'm wondering if BitBlt can be another solution too. Using BitBlt on the target DC would be trying to fix the misdraw after the fact. You=E2=80=99d also have to invent a combination of a rop (raster operation) and whichever auxiliary argument it takes so that it turns the foreground color into the background color and vice versa. BitBlt could be used on a memory DC into which the stipple bitmap is selected, to emulate InvertRect, e.g. passing a rop of DSTINVERT, but this brings no benefits.