[cairo-commit] cairo/src Makefile.am, 1.37,
1.38 cairo-win32-private.h, NONE, 1.1 cairo-win32.h, 1.2,
1.3 cairo_win32_font.c, 1.2, 1.3 cairo_win32_surface.c, 1.2, 1.3
Owen Taylor
commit at pdx.freedesktop.org
Tue Feb 1 21:45:54 PST 2005
Committed by: otaylor
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv5813/src
Modified Files:
Makefile.am cairo-win32.h cairo_win32_font.c
cairo_win32_surface.c
Added Files:
cairo-win32-private.h
Log Message:
2005-02-02 Owen Taylor <otaylor at redhat.com>
* src/cairo_win32_font.c: Mostly-functioning Win32 font backend;
no glyph paths yet.
* configure.in: Turn on building of the Win32 font backend.
* src/cairo-win32-private.h src/Makefile.am: Private header for
the Win32 backend.
* src/cairo-win32-private.h src/cairo_win32_surface.c:
Internally export _cairo_win32_print_gdi_error() for use
in the font code.
* src/cairo-win32-private.h src/cairo_win32_surface.c:
Add _cairo_win32_surface_create_dib to create a DIB surface.
src/cairo-win32-private.h src/cairo_win32_surface.c:
Add _cairo_surface_is_win32()
* configure.in: Check for vasnprintf.
* test/cairo_test.c (xasprintf): Add a simple fixed-buffer size
snprintf fallback in the absence of vasnprintf.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/src/Makefile.am,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- Makefile.am 1 Feb 2005 23:06:36 -0000 1.37
+++ Makefile.am 2 Feb 2005 05:45:52 -0000 1.38
@@ -32,7 +32,7 @@
libcairo_win32_sources =
if CAIRO_HAS_WIN32_SURFACE
libcairo_win32_headers = cairo-win32.h
-libcairo_win32_sources += cairo_win32_surface.c
+libcairo_win32_sources += cairo_win32_surface.c cairo-win32-private.h
endif
if CAIRO_HAS_WIN32_FONT
libcairo_win32_sources += cairo_win32_font.c
--- NEW FILE: cairo-win32-private.h ---
(This appears to be a binary file; contents omitted.)
Index: cairo-win32.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo-win32.h 1 Feb 2005 23:06:36 -0000 1.2
+++ cairo-win32.h 2 Feb 2005 05:45:52 -0000 1.3
@@ -51,7 +51,7 @@
cairo_win32_surface_create (HDC hdc);
cairo_font_t *
-cairo_win32_font_create_for_logfont (LOGFONT *logfont,
+cairo_win32_font_create_for_logfont (LOGFONTW *logfont,
cairo_matrix_t *scale);
#endif /* CAIRO_HAS_WIN32_SURFACE */
Index: cairo_win32_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_win32_font.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_win32_font.c 1 Feb 2005 23:06:36 -0000 1.2
+++ cairo_win32_font.c 2 Feb 2005 05:45:52 -0000 1.3
@@ -32,16 +32,29 @@
* Contributor(s):
*/
+#include <string.h>
+#include <stdio.h>
+
#include "cairo-win32-private.h"
-const cairo_font_backend_t cairo_ft_font_backend;
+#ifndef SPI_GETFONTSMOOTHINGTYPE
+#define SPI_GETFONTSMOOTHINGTYPE 0x200a
[...1156 lines suppressed...]
static cairo_status_t
@@ -819,8 +1081,6 @@
int num_glyphs,
cairo_path_t *path)
{
- cairo_win32_font_t *font = abstract_font;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -847,7 +1107,7 @@
/* implement the platform-specific interface */
cairo_font_t *
-cairo_win32_font_create_for_logfont (LOGFONT *logfont,
+cairo_win32_font_create_for_logfont (LOGFONTW *logfont,
cairo_matrix_t *scale)
{
cairo_font_scale_t sc;
Index: cairo_win32_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_win32_surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_win32_surface.c 1 Feb 2005 23:06:36 -0000 1.2
+++ cairo_win32_surface.c 2 Feb 2005 05:45:52 -0000 1.3
@@ -33,17 +33,9 @@
* Owen Taylor <otaylor at redhat.com>
*/
-/* We depend on various features introduced with Win2k and Win98,
- * like AlphaBlend. If it turns out to be a problem, we could
- * use GetProcAddress() to look them up.
- */
-#define WINVER 0x0500
-
-#include <windows.h>
#include <stdio.h>
-#include "cairo-win32.h"
-#include "cairoint.h"
+#include "cairo-win32-private.h"
static const cairo_surface_backend_t cairo_win32_surface_backend;
@@ -84,11 +76,6 @@
return CAIRO_STATUS_NO_MEMORY;
}
-static cairo_status_t
-_get_cairo_error (void)
-{
-}
-
void
cairo_set_target_win32 (cairo_t *cr,
HDC hdc)
@@ -110,24 +97,6 @@
cairo_surface_destroy (surface);
}
-typedef struct _cairo_win32_surface {
- cairo_surface_t base;
-
- cairo_format_t format;
-
- HDC dc;
-
- /* We create off-screen surfaces as DIB's */
- HBITMAP bitmap;
- cairo_surface_t *image;
-
- cairo_rectangle_t clip_rect;
-
- int set_clip;
- HRGN saved_clip;
-
-} cairo_win32_surface_t;
-
static cairo_status_t
_create_dc_and_bitmap (HDC original_dc,
cairo_format_t format,
@@ -283,14 +252,13 @@
}
static cairo_surface_t *
-_cairo_win32_surface_create_similar (void *abstract_src,
- cairo_format_t format,
- int drawable,
- int width,
- int height)
+_cairo_win32_surface_create_for_dc (HDC original_dc,
+ cairo_format_t format,
+ int drawable,
+ int width,
+ int height)
{
- cairo_win32_surface_t *src = abstract_src;
- cairo_win32_surface_t *surface = abstract_src;
+ cairo_win32_surface_t *surface;
HDC dc = NULL;
HBITMAP bitmap = NULL;
char *bits;
@@ -300,7 +268,7 @@
if (!surface)
return NULL;
- if (_create_dc_and_bitmap (src->dc, format,
+ if (_create_dc_and_bitmap (original_dc, format,
width, height,
&dc, &bitmap, &bits, &rowstride) != CAIRO_STATUS_SUCCESS)
goto FAIL;
@@ -338,6 +306,41 @@
}
+static cairo_surface_t *
+_cairo_win32_surface_create_similar (void *abstract_src,
+ cairo_format_t format,
+ int drawable,
+ int width,
+ int height)
+{
+ cairo_win32_surface_t *src = abstract_src;
+
+ return _cairo_win32_surface_create_for_dc (src->dc, format, drawable,
+ width, height);
+}
+
+/**
+ * _cairo_win32_surface_create_dib:
+ * @format: format of pixels in the surface to create
+ * @width: width of the surface, in pixels
+ * @height: height of the surface, in pixels
+ *
+ * Creates a device-independent-bitmap surface not associated with
+ * any particular existing surface or device context. The created
+ * bitmap will be unititialized.
+ *
+ * Return value: the newly created surface, or %NULL if it couldn't
+ * be created (probably because of lack of memory)
+ **/
+cairo_surface_t *
+_cairo_win32_surface_create_dib (cairo_format_t format,
+ int width,
+ int height)
+{
+ return _cairo_win32_surface_create_for_dc (NULL, format, TRUE,
+ width, height);
+}
+
static void
_cairo_win32_surface_destroy (void *abstract_surface)
{
@@ -913,6 +916,20 @@
return (cairo_surface_t *)surface;
}
+/**
+ * _cairo_surface_is_win32:
+ * @surface: a #cairo_surface_t
+ *
+ * Checks if a surface is an #cairo_win32_surface_t
+ *
+ * Return value: True if the surface is an win32 surface
+ **/
+int
+_cairo_surface_is_win32 (cairo_surface_t *surface)
+{
+ return surface->backend == &cairo_win32_surface_backend;
+}
+
static const cairo_surface_backend_t cairo_win32_surface_backend = {
_cairo_win32_surface_create_similar,
_cairo_win32_surface_destroy,
More information about the cairo-commit
mailing list