mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-01 18:28:00 +02:00
Mostly-functioning Win32 font backend; no glyph paths yet.
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() Check for vasnprintf. Add a simple fixed-buffer size snprintf fallback in the absence of vasnprintf.
This commit is contained in:
parent
211d115f18
commit
199c41dafe
11 changed files with 1361 additions and 649 deletions
25
ChangeLog
25
ChangeLog
|
|
@ -1,3 +1,28 @@
|
|||
2005-02-02 Owen Taylor <otaylor@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.
|
||||
|
||||
2005-02-01 Kristian Høgsberg <krh@redhat.com>
|
||||
|
||||
* src/cairo_pdf_surface.c (_cairo_pdf_surface_composite): Pretend
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ AM_PROG_LIBTOOL
|
|||
AC_STDC_HEADERS
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
AC_CHECK_FUNCS(vasnprintf)
|
||||
|
||||
AC_CHECK_LIBM
|
||||
|
||||
LIBS="$LIBS $LIBM"
|
||||
|
|
@ -153,7 +155,7 @@ else
|
|||
AM_CONDITIONAL(CAIRO_HAS_WIN32_SURFACE, true)
|
||||
fi
|
||||
|
||||
if true || test "x$use_win32" != "xyes"; then
|
||||
if test "x$use_win32" != "xyes"; then
|
||||
WIN32_FONT_FEATURE=CAIRO_HAS_NO_WIN32_FONT
|
||||
AM_CONDITIONAL(CAIRO_HAS_WIN32_FONT, false)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ endif
|
|||
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
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
77
src/cairo-win32-private.h
Normal file
77
src/cairo-win32-private.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2005 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Owen Taylor <otaylor@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_WIN32_PRIVATE_H
|
||||
#define CAIRO_WIN32_PRIVATE_H
|
||||
|
||||
/* 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 <cairo-win32.h>
|
||||
#include <cairoint.h>
|
||||
|
||||
typedef struct _cairo_win32_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
cairo_format_t format;
|
||||
|
||||
HDC dc;
|
||||
|
||||
/* We create off-screen surfaces as DIBs */
|
||||
HBITMAP bitmap;
|
||||
cairo_surface_t *image;
|
||||
|
||||
cairo_rectangle_t clip_rect;
|
||||
|
||||
int set_clip;
|
||||
HRGN saved_clip;
|
||||
|
||||
} cairo_win32_surface_t;
|
||||
|
||||
cairo_status_t
|
||||
_cairo_win32_print_gdi_error (const char *context);
|
||||
|
||||
cairo_surface_t *
|
||||
_cairo_win32_surface_create_dib (cairo_format_t format,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_surface_is_win32 (cairo_surface_t *surface);
|
||||
|
||||
#endif /* CAIRO_WIN32_PRIVATE_H */
|
||||
|
|
@ -33,17 +33,9 @@
|
|||
* Owen Taylor <otaylor@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 @@ _cairo_win32_print_gdi_error (const char *context)
|
|||
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_set_target_win32 (cairo_t *cr,
|
|||
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 @@ _create_dc_and_bitmap (HDC original_dc,
|
|||
}
|
||||
|
||||
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 @@ _cairo_win32_surface_create_similar (void *abstract_src,
|
|||
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 @@ _cairo_win32_surface_create_similar (void *abstract_src,
|
|||
|
||||
}
|
||||
|
||||
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 @@ cairo_win32_surface_create (HDC hdc)
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ cairo_surface_t *
|
|||
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 */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -33,17 +33,9 @@
|
|||
* Owen Taylor <otaylor@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 @@ _cairo_win32_print_gdi_error (const char *context)
|
|||
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_set_target_win32 (cairo_t *cr,
|
|||
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 @@ _create_dc_and_bitmap (HDC original_dc,
|
|||
}
|
||||
|
||||
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 @@ _cairo_win32_surface_create_similar (void *abstract_src,
|
|||
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 @@ _cairo_win32_surface_create_similar (void *abstract_src,
|
|||
|
||||
}
|
||||
|
||||
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 @@ cairo_win32_surface_create (HDC hdc)
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -44,9 +44,10 @@
|
|||
static void
|
||||
xasprintf (char **strp, const char *fmt, ...)
|
||||
{
|
||||
#ifdef HAVE_VASPRINTF
|
||||
va_list va;
|
||||
int ret;
|
||||
|
||||
|
||||
va_start (va, fmt);
|
||||
ret = vasprintf (strp, fmt, va);
|
||||
va_end (va);
|
||||
|
|
@ -55,6 +56,32 @@ xasprintf (char **strp, const char *fmt, ...)
|
|||
fprintf (stderr, "Out of memory\n");
|
||||
exit (1);
|
||||
}
|
||||
#else /* !HAVE_VASNPRINTF */
|
||||
#define BUF_SIZE 1024
|
||||
va_list va;
|
||||
char buffer[BUF_SIZE];
|
||||
int ret;
|
||||
|
||||
va_start (va, fmt);
|
||||
ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
|
||||
va_end (va);
|
||||
|
||||
if (ret < 0) {
|
||||
fprintf (stderr, "Failure in vsnprintf\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (strlen (buffer) == sizeof(buffer) - 1) {
|
||||
fprintf (stderr, "Overflowed fixed buffer\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
*strp = strdup (buffer);
|
||||
if (!*strp) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !HAVE_VASNPRINTF */
|
||||
}
|
||||
|
||||
cairo_test_status_t
|
||||
|
|
|
|||
|
|
@ -44,9 +44,10 @@
|
|||
static void
|
||||
xasprintf (char **strp, const char *fmt, ...)
|
||||
{
|
||||
#ifdef HAVE_VASPRINTF
|
||||
va_list va;
|
||||
int ret;
|
||||
|
||||
|
||||
va_start (va, fmt);
|
||||
ret = vasprintf (strp, fmt, va);
|
||||
va_end (va);
|
||||
|
|
@ -55,6 +56,32 @@ xasprintf (char **strp, const char *fmt, ...)
|
|||
fprintf (stderr, "Out of memory\n");
|
||||
exit (1);
|
||||
}
|
||||
#else /* !HAVE_VASNPRINTF */
|
||||
#define BUF_SIZE 1024
|
||||
va_list va;
|
||||
char buffer[BUF_SIZE];
|
||||
int ret;
|
||||
|
||||
va_start (va, fmt);
|
||||
ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
|
||||
va_end (va);
|
||||
|
||||
if (ret < 0) {
|
||||
fprintf (stderr, "Failure in vsnprintf\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (strlen (buffer) == sizeof(buffer) - 1) {
|
||||
fprintf (stderr, "Overflowed fixed buffer\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
*strp = strdup (buffer);
|
||||
if (!*strp) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !HAVE_VASNPRINTF */
|
||||
}
|
||||
|
||||
cairo_test_status_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue