mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 02:58:02 +02:00
Win32: Rename _cairo_win32_print_gdi_error function
...to _cairo_win32_print_api_error, since it should not be used with most GDI functions. Also move the function definition to cairo-win32-system.c and change argument signature.
This commit is contained in:
parent
85f308f690
commit
3bc6b616a4
5 changed files with 40 additions and 45 deletions
|
|
@ -210,7 +210,7 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
&bits,
|
||||
NULL, 0);
|
||||
if (!surface->bitmap) {
|
||||
_cairo_win32_print_gdi_error ("_create_dc_and_bitmap:CreateDIBSection");
|
||||
_cairo_win32_print_api_error (__FUNCTION__, "CreateDIBSection");
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +549,7 @@ _cairo_win32_display_surface_flush (void *abstract_surface, unsigned flags)
|
|||
fallback->win32.dc,
|
||||
surface->win32.extents.x, surface->win32.extents.y,
|
||||
SRCCOPY))
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_display_surface_flush:BitBlt");
|
||||
status = _cairo_win32_print_api_error (__FUNCTION__, "BitBlt");
|
||||
} else if (damage->region) {
|
||||
int n = cairo_region_num_rectangles (damage->region), i;
|
||||
for (i = 0; i < n; i++) {
|
||||
|
|
@ -566,7 +566,7 @@ _cairo_win32_display_surface_flush (void *abstract_surface, unsigned flags)
|
|||
fallback->win32.dc,
|
||||
rect.x, rect.y,
|
||||
SRCCOPY)) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_display_surface_flush:BitBlt");
|
||||
status = _cairo_win32_print_api_error (__FUNCTION__, "BitBlt");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ _have_cleartype_quality (void)
|
|||
version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
|
||||
if (!GetVersionEx (&version_info)) {
|
||||
_cairo_win32_print_gdi_error ("_have_cleartype_quality");
|
||||
_cairo_win32_print_api_error (__FUNCTION__, "GetVersionEx");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ cairo_win32_get_system_text_quality (void)
|
|||
UINT smoothing_type;
|
||||
|
||||
if (!SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &font_smoothing, 0)) {
|
||||
_cairo_win32_print_gdi_error ("_get_system_quality");
|
||||
_cairo_win32_print_api_error (__FUNCTION__, "SystemParametersInfo");
|
||||
return DEFAULT_QUALITY;
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ cairo_win32_get_system_text_quality (void)
|
|||
if (_have_cleartype_quality ()) {
|
||||
if (!SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE,
|
||||
0, &smoothing_type, 0)) {
|
||||
_cairo_win32_print_gdi_error ("_get_system_quality");
|
||||
_cairo_win32_print_api_error (__FUNCTION__, "SystemParametersInfo");
|
||||
return DEFAULT_QUALITY;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ const cairo_compositor_t *
|
|||
_cairo_win32_gdi_compositor_get (void);
|
||||
|
||||
cairo_status_t
|
||||
_cairo_win32_print_gdi_error (const char *context);
|
||||
_cairo_win32_print_api_error (const char *context, const char *api);
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_surface_is_win32 (const cairo_surface_t *surface);
|
||||
|
|
|
|||
|
|
@ -79,41 +79,6 @@
|
|||
* Since: 1.0
|
||||
**/
|
||||
|
||||
/**
|
||||
* _cairo_win32_print_gdi_error:
|
||||
* @context: context string to display along with the error
|
||||
*
|
||||
* Helper function to dump out a human readable form of the
|
||||
* current error code.
|
||||
*
|
||||
* Return value: A cairo status code for the error code
|
||||
**/
|
||||
cairo_status_t
|
||||
_cairo_win32_print_gdi_error (const char *context)
|
||||
{
|
||||
void *lpMsgBuf;
|
||||
DWORD last_error = GetLastError ();
|
||||
|
||||
if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
last_error,
|
||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR) &lpMsgBuf,
|
||||
0, NULL)) {
|
||||
fprintf (stderr, "%s: Unknown GDI error", context);
|
||||
} else {
|
||||
fprintf (stderr, "%s: %S", context, (wchar_t *)lpMsgBuf);
|
||||
|
||||
LocalFree (lpMsgBuf);
|
||||
}
|
||||
|
||||
fflush (stderr);
|
||||
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_win32_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle)
|
||||
|
|
|
|||
|
|
@ -44,14 +44,44 @@
|
|||
* And no other function should live here.
|
||||
*/
|
||||
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/**
|
||||
* _cairo_win32_print_api_error:
|
||||
* @context: context string to display along with the error
|
||||
* @api: name of the failing api
|
||||
*
|
||||
* Helper function to dump out a human readable form of the
|
||||
* current error code.
|
||||
*
|
||||
* Return value: A cairo status code for the error code
|
||||
**/
|
||||
cairo_status_t
|
||||
_cairo_win32_print_api_error (const char *context, const char *api)
|
||||
{
|
||||
const DWORD lang_id = MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT);
|
||||
const DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM;
|
||||
const DWORD last_error = GetLastError ();
|
||||
void *lpMsgBuf = NULL;
|
||||
|
||||
if (!FormatMessageW (flags, NULL, last_error, lang_id, (LPWSTR) &lpMsgBuf, 0, NULL)) {
|
||||
fprintf (stderr, "%s: %s failed with error code %lu\n", context, api, last_error);
|
||||
}
|
||||
else {
|
||||
fprintf (stderr, "%s: %s failed - %S\n", context, api, (wchar_t *)lpMsgBuf);
|
||||
LocalFree (lpMsgBuf);
|
||||
}
|
||||
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
#if CAIRO_MUTEX_IMPL_WIN32
|
||||
#if !CAIRO_WIN32_STATIC_BUILD
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* declare to avoid "no previous prototype for 'DllMain'" warning */
|
||||
BOOL WINAPI
|
||||
DllMain (HINSTANCE hinstDLL,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue