]> git.pld-linux.org Git - packages/crossmingw32-cairo.git/blame - cairo-add-cairo-API-to-setup-Win32-surface-for-HDC.patch
- one more mingw32 specific change; release 2
[packages/crossmingw32-cairo.git] / cairo-add-cairo-API-to-setup-Win32-surface-for-HDC.patch
CommitLineData
ff93a0af
JB
1From 16898ba11b4d6e9e2e64bb2d02d0fb5adbe266e2 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
3 =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
4Date: Thu, 26 Mar 2015 19:33:43 +0000
5Subject: win32: Add cairo API to set up a Win32 surface for an HDC with an
6 alpha channel.
7MIME-Version: 1.0
8Content-Type: text/plain; charset=UTF-8
9Content-Transfer-Encoding: 8bit
10
11Signed-off-by: Руслан Ижбулатов <lrn1986@gmail.com>
12Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
13
14diff --git a/src/cairo-win32.h b/src/cairo-win32.h
15index 3d2e1c6..db4cac6 100644
16--- a/src/cairo-win32.h
17+++ b/src/cairo-win32.h
18@@ -49,6 +49,10 @@ cairo_public cairo_surface_t *
19 cairo_win32_surface_create (HDC hdc);
20
21 cairo_public cairo_surface_t *
22+cairo_win32_surface_create_with_format (HDC hdc,
23+ cairo_format_t format);
24+
25+cairo_public cairo_surface_t *
26 cairo_win32_printing_surface_create (HDC hdc);
27
28 cairo_public cairo_surface_t *
29diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
30index 965f2c4..1571480 100644
31--- a/src/win32/cairo-win32-display-surface.c
32+++ b/src/win32/cairo-win32-display-surface.c
33@@ -917,31 +917,41 @@ static const cairo_surface_backend_t cairo_win32_display_surface_backend = {
34 */
35
36 /**
37- * cairo_win32_surface_create:
38+ * cairo_win32_surface_create_with_format:
39 * @hdc: the DC to create a surface for
40+ * @format: format of pixels in the surface to create
41 *
42 * Creates a cairo surface that targets the given DC. The DC will be
43 * queried for its initial clip extents, and this will be used as the
44- * size of the cairo surface. The resulting surface will always be of
45- * format %CAIRO_FORMAT_RGB24; should you need another surface format,
46- * you will need to create one through
47- * cairo_win32_surface_create_with_dib().
48+ * size of the cairo surface.
49 *
50- * Return value: the newly created surface
51+ * Supported formats are:
52+ * %CAIRO_FORMAT_ARGB32
53+ * %CAIRO_FORMAT_RGB24
54 *
55- * Since: 1.0
56+ * Note: @format only tells cairo how to draw on the surface, not what
57+ * the format of the surface is. Namely, cairo does not (and cannot)
58+ * check that @hdc actually supports alpha-transparency.
59+ *
60+ * Return value: the newly created surface, NULL on failure
61+ *
62+ * Since: 1.14.3
63 **/
64 cairo_surface_t *
65-cairo_win32_surface_create (HDC hdc)
66+cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
67 {
68 cairo_win32_display_surface_t *surface;
69
70- cairo_format_t format;
71 cairo_status_t status;
72 cairo_device_t *device;
73
74- /* Assume that everything coming in as a HDC is RGB24 */
75- format = CAIRO_FORMAT_RGB24;
76+ switch (format) {
77+ default:
78+ return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
79+ case CAIRO_FORMAT_ARGB32:
80+ case CAIRO_FORMAT_RGB24:
81+ break;
82+ }
83
84 surface = malloc (sizeof (*surface));
85 if (surface == NULL)
86@@ -977,6 +987,28 @@ cairo_win32_surface_create (HDC hdc)
87 }
88
89 /**
90+ * cairo_win32_surface_create:
91+ * @hdc: the DC to create a surface for
92+ *
93+ * Creates a cairo surface that targets the given DC. The DC will be
94+ * queried for its initial clip extents, and this will be used as the
95+ * size of the cairo surface. The resulting surface will always be of
96+ * format %CAIRO_FORMAT_RGB24; should you need another surface format,
97+ * you will need to create one through
98+ * cairo_win32_surface_create_with_format() or
99+ * cairo_win32_surface_create_with_dib().
100+ *
101+ * Return value: the newly created surface, NULL on failure
102+ *
103+ * Since: 1.0
104+ **/
105+cairo_surface_t *
106+cairo_win32_surface_create (HDC hdc)
107+{
108+ return cairo_win32_surface_create_with_format (hdc, CAIRO_FORMAT_RGB24);
109+}
110+
111+/**
112 * cairo_win32_surface_create_with_dib:
113 * @format: format of pixels in the surface to create
114 * @width: width of the surface, in pixels
115@@ -1027,12 +1059,16 @@ cairo_win32_surface_create_with_ddb (HDC hdc,
116 HDC screen_dc, ddb_dc;
117 HBITMAP saved_dc_bitmap;
118
119- if (format != CAIRO_FORMAT_RGB24)
120+ switch (format) {
121+ default:
122+/* XXX handle these eventually */
123+ case CAIRO_FORMAT_A8:
124+ case CAIRO_FORMAT_A1:
125 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
126-/* XXX handle these eventually
127- format != CAIRO_FORMAT_A8 ||
128- format != CAIRO_FORMAT_A1)
129-*/
130+ case CAIRO_FORMAT_ARGB32:
131+ case CAIRO_FORMAT_RGB24:
132+ break;
133+ }
134
135 if (!hdc) {
136 screen_dc = GetDC (NULL);
137--
138cgit v0.10.2
This page took 0.083952 seconds and 4 git commands to generate.