Re: [PATCH 2/3] Support a different pixel format for HDC

LRN <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On 11.03.2015 0:31, Bryce Harrington wrote:
> On Tue, Mar 10, 2015 at 05:52:07PM +0300, LRN wrote:
>>>
>>> Patch #1 is from cairo bugzilla, see the link you gave me in [1].
>>>
>>> Patch #2 (this patch) was used by Mozilla[2] back in 2010. They have [had?]
>>> internal copy of cairo to patch, so maybe they just haven't bothered with
>>> submitting it. Or maybe they did submit it to cairo bugzilla and it got lost
>>> there. Who knows? Either way, the patch is trivial enough, so i wouldn't
>>> worry about this one too much.
>>>
>>>
>>> [1] http://lists.cairographics.org/archives/cairo/2014-April/025148.html
>>> [2] https://bugzilla.mozilla.org/show_bug.cgi?id=577200
>>>
>>
>> Any progress on this?
>>
>> The fallback surface-related crash was fixed in 0.14, so the patch labeled "Enlarge fallback surface" is no longer necessary. I would only need this patch ("Support a different pixel format for HDC") and at least one bit from "Adjust assertions and checks to handle more pixel formats".
>>
>> These patches are very small, the only prerequisite for being able to evaluate them is understanding of cairo and W32 API. I'd very much like to stop patching cairo and push Windows RGBA code into GTK.
>>
> 
> Mind extracting whatever bits are still needed, into new patches?
> Please use git format-patch against cairo trunk for creating them.
> 

Here they are.

Do i need to send each one as a separate email (not an as an attachment) as well?

-- 
O< ascii ribbon - stop html email! - www.asciiribbon.org

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
0001-Add-cairo-API-to-set-up-a-Win32-surface-for-an-HDC-w.patch (text/plain, 3.9 KB)
From 07ab55bc0032e5ae90e1ca78aa1e733114ecef7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
 =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <[email protected]>
Date: Thu, 26 Mar 2015 19:33:43 +0000
Subject: [PATCH 1/2] Add cairo API to set up a Win32 surface for an HDC with
 an alpha channel.

Signed-off-by: Bas Schouten <[email protected]>
---
 src/cairo-win32.h                       |  3 ++
 src/win32/cairo-win32-display-surface.c | 64 ++++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/src/cairo-win32.h b/src/cairo-win32.h
index 3d2e1c6..2dd8934 100644
--- a/src/cairo-win32.h
+++ b/src/cairo-win32.h
@@ -49,6 +49,9 @@ cairo_public cairo_surface_t *
 cairo_win32_surface_create (HDC hdc);
 
 cairo_public cairo_surface_t *
+cairo_win32_surface_create_with_alpha (HDC hdc);
+
+cairo_public cairo_surface_t *
 cairo_win32_printing_surface_create (HDC hdc);
 
 cairo_public cairo_surface_t *
diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 965f2c4..6644262 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -916,33 +916,14 @@ static const cairo_surface_backend_t cairo_win32_display_surface_backend = {
  *              multiplied by all the src components.
  */
 
-/**
- * cairo_win32_surface_create:
- * @hdc: the DC to create a surface for
- *
- * Creates a cairo surface that targets the given DC.  The DC will be
- * queried for its initial clip extents, and this will be used as the
- * size of the cairo surface.  The resulting surface will always be of
- * format %CAIRO_FORMAT_RGB24; should you need another surface format,
- * you will need to create one through
- * cairo_win32_surface_create_with_dib().
- *
- * Return value: the newly created surface
- *
- * Since: 1.0
- **/
-cairo_surface_t *
-cairo_win32_surface_create (HDC hdc)
+static cairo_surface_t *
+cairo_win32_surface_create_internal (HDC hdc, cairo_format_t format)
 {
     cairo_win32_display_surface_t *surface;
 
-    cairo_format_t format;
     cairo_status_t status;
     cairo_device_t *device;
 
-    /* Assume that everything coming in as a HDC is RGB24 */
-    format = CAIRO_FORMAT_RGB24;
-
     surface = malloc (sizeof (*surface));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -977,6 +958,47 @@ cairo_win32_surface_create (HDC hdc)
 }
 
 /**
+ * cairo_win32_surface_create:
+ * @hdc: the DC to create a surface for
+ *
+ * Creates a cairo surface that targets the given DC.  The DC will be
+ * queried for its initial clip extents, and this will be used as the
+ * size of the cairo surface.  The resulting surface will always be of
+ * format %CAIRO_FORMAT_RGB24; should you need another surface format,
+ * you will need to create one through
+ * cairo_win32_surface_create_with_dib().
+ *
+ * Return value: the newly created surface
+ *
+ * Since: 1.0
+ **/
+cairo_surface_t *
+cairo_win32_surface_create (HDC hdc)
+{
+    return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_RGB24);
+}
+
+/**
+ * cairo_win32_surface_create_with_alpha:
+ * @hdc: the DC to create a surface for
+ *
+ * Creates a cairo surface that targets the given DC.  The DC will be
+ * queried for its initial clip extents, and this will be used as the
+ * size of the cairo surface.  The resulting surface will always be of
+ * format %CAIRO_FORMAT_ARGB32; this format is used when drawing into
+ * transparent windows.
+ *
+ * Return value: the newly created surface
+ *
+ * Since: 1.14.3
+ **/
+cairo_surface_t *
+cairo_win32_surface_create_with_alpha (HDC hdc)
+{
+    return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_ARGB32);
+}
+
+/**
  * cairo_win32_surface_create_with_dib:
  * @format: format of pixels in the surface to create
  * @width: width of the surface, in pixels
-- 
1.8.5.3
0002-Now-that-ARGB32-format-is-available-allow-it-to-be-u.patch (text/plain, 1.2 KB)
From 04b29e116677b2b7d67d4e44248f79da8e54ba58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
 =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <[email protected]>
Date: Thu, 26 Mar 2015 19:40:29 +0000
Subject: [PATCH 2/2] Now that ARGB32 format is available, allow it to be used.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Руслан Ижбулатов <[email protected]>
---
 src/win32/cairo-win32-display-surface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 6644262..5efd53b 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -1049,7 +1049,7 @@ cairo_win32_surface_create_with_ddb (HDC hdc,
     HDC screen_dc, ddb_dc;
     HBITMAP saved_dc_bitmap;
 
-    if (format != CAIRO_FORMAT_RGB24)
+    if (format != CAIRO_FORMAT_RGB24 && format != CAIRO_FORMAT_ARGB32)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
 /* XXX handle these eventually
 	format != CAIRO_FORMAT_A8 ||
-- 
1.8.5.3
0x922360B0.asc (application/pgp-keys, 1.7 KB)
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.11 (MingW32)

mQENBE48DHkBCADjAv/EeFMN+i5XDN2WjSBU/yHbJlIG93/Hpj7Hee65qr82O9us
n3t4W1bk2+YwGBrFdfVlesHF4DObckXveayC+IulVvTJwZhR8igVENvWjIo6oF1N
1B3GV/c8zVCnHdkF0+vYJ9akX6DZf8KvBqKZapK1kc3tll0o+kS9lwNfpWRarUpQ
SBTw2uq+FUEsO3pwVAyvwom4b7AB6fz1tpyl28dOaNDKr2W55ZDPC8aM5PPe/kiH
n3ylOwpgXYqZLhIyJStqL/KcZ76y8o/gDXnilFRLwXu9CbXjapo7MARXByuSVMfb
PHa3XNj5JCzlv4GhEF4HOp4qoVRk8YASTqf/ABEBAAG0F0xSTiA8bHJuMTk4NkBn
bWFpbC5jb20+iQE9BBMBAgAnAhsjBQkJZgGAAh4BAheABQJT5qxpBQsJCAcDBRUK
CQgLBRYCAwEAAAoJEOs4Jb6SI2CwBNMIAKu3L9CGoTlJHZ/0G5AbbcP9zeiIkKkN
yvi1XszHiDz1kaESQYjpDsEWeHQutEhmnK5DNR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EY BLOCK-----
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJVFGGHAAoJEOs4Jb6SI2CwPKIIAJV6ZO4g2bgVUmw+l77QnVds
A8q/r4DNMNAam5y5YC0nldzbOsiD0kulkWGv9xPhQ8facWM8JPPj/OQnVYKnZ7Wk
s6BG5YaJlK+6a/D1doCK2P8OMLFV3F7d+xCTfeMyBV7SZiCowjD4emzV7s5Yp6KL
bWbkMvjjWf4wxttFYnsP8paUYaJY3dI8TyEycIkjxfiDFSw2YVXzEM1T1fI+AuTM
RCMG0kzqxTbiTjlf/OET5eisKrvoPpahIJx80sVyPybcdiROhGBlmiElcPMUT3jX
sZIydaR+ypQX8VRl2Ufm/M8Z8G+cml7xIfx/rpcZrU91XKxDhgy4w8NteEVa96w=
=iIdk
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.