summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Parmenter <pavlov@pavlov.net>2005-11-17 11:55:20 +0000
committerStuart Parmenter <pavlov@pavlov.net>2005-11-17 11:55:20 +0000
commit49136c04f2fcbf463334bf256c72b7b280e2e819 (patch)
tree7679d2874b4c0f45ac1703f6c03c61e79d7983bb
parenta16d93f367af721a535ed13fc5bc07636e6549d2 (diff)
Hooked up tests to run on Windows with a Windows surface
-rw-r--r--ChangeLog6
-rw-r--r--test/cairo-test.c53
2 files changed, 52 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 74f75d700..5fddec350 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-17 Stuart Parmenter <pavlov@pavlov.net>
+
+ * test/cairo-test.c: (create_win32_surface),
+ (cleanup_win32), (cairo_test_expecting):
+ Hooked up tests to run on Windows with a Windows surface
+
2005-11-14 Anders Carlsson <andersca@imendio.com>
* src/cairo-quartz-surface.c:
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 712749edb..623991839 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -230,17 +230,57 @@ cleanup_quartz (void *closure)
/* Testing the win32 surface isn't interesting, since for
* ARGB images it just chains to the image backend
*/
-#if 0 && CAIRO_HAS_WIN32_SURFACE
+#if CAIRO_HAS_WIN32_SURFACE
+#include "cairo-win32.h"
+typedef struct _win32_target_closure
+{
+ HDC dc;
+ HBITMAP bmp;
+} win32_target_closure_t;
+
static cairo_surface_t *
-create_win32_surface (int width, int height, void **closure)
+create_win32_surface (cairo_test_t *test, cairo_format_t format,
+ void **closure)
{
-#error Not yet implemented
+ int width = test->width;
+ int height = test->height;
+
+ BITMAPINFO bmpInfo;
+ unsigned char *bits = NULL;
+ win32_target_closure_t *data = malloc(sizeof(win32_target_closure_t));
+ *closure = data;
+
+ data->dc = CreateCompatibleDC(NULL);
+
+ /* initialize the bitmapinfoheader */
+ memset(&bmpInfo.bmiHeader, 0, sizeof(BITMAPINFOHEADER));
+ bmpInfo.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+ bmpInfo.bmiHeader.biWidth = width;
+ bmpInfo.bmiHeader.biHeight = -height;
+ bmpInfo.bmiHeader.biPlanes = 1;
+ bmpInfo.bmiHeader.biBitCount = 24;
+ bmpInfo.bmiHeader.biCompression = BI_RGB;
+
+ /* create a DIBSection */
+ data->bmp = CreateDIBSection(data->dc, &bmpInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
+
+ /* Flush GDI to make sure the DIBSection is actually created */
+ GdiFlush();
+
+ /* Select the bitmap in to the DC */
+ SelectObject(data->dc, data->bmp);
+
+ return cairo_win32_surface_create(data->dc);
}
static void
cleanup_win32 (void *closure)
{
-#error Not yet implemented
+ win32_target_closure_t *data = (win32_target_closure_t*)closure;
+ DeleteObject(data->bmp);
+ DeleteDC(data->dc);
+
+ free(closure);
}
#endif
@@ -665,10 +705,9 @@ cairo_test_expecting (cairo_test_t *test, cairo_test_draw_function_t draw,
create_quartz_surface, cairo_surface_write_to_png,
cleanup_quartz },
#endif
-#if 0 && CAIRO_HAS_WIN32_SURFACE
+#if CAIRO_HAS_WIN32_SURFACE
{ "win32", CAIRO_FORMAT_RGB24,
- create_win32_surface, cairo_surface_write_to_png,
- cleanup_win32 },
+ create_win32_surface, cairo_surface_write_to_png, cleanup_win32 },
#endif
#if CAIRO_HAS_XCB_SURFACE
{ "xcb", CAIRO_FORMAT_ARGB32,