void CairoDrawThread(void *pParam) { HWND hwndClientWindow = (HWND) pParam; HPS hpsClientWindow; SWP swpTemp; // Query HPS of HWND hpsClientWindow = WinGetPS(hwndClientWindow); WinQueryWindowPos(hwndClientWindow, &swpTemp); // Set FPU state which might have been changed by some Win* calls! // (Workaround for a PM bug) DisableFPUException(); // Initialize cairo support cairo_os2_init(); // Create cairo surface pCairoSurface = cairo_os2_surface_create(hpsClientWindow, swpTemp.cx, swpTemp.cy); // Tell the surface the HWND too, so if the application decides // that it wants to draw itself, then it will be able to turn // on blit_as_changes. cairo_os2_surface_set_hwnd(pCairoSurface, hwndClientWindow); // Make sure that the changes will be shown only // when we tell so cairo_os2_surface_set_manual_window_refresh(pCairoSurface, TRUE); // Create Cairo drawing handle for the surface pCairoHandle = cairo_create(pCairoSurface); // Do the main drawing loop as long as needed! bShutdownDrawing = 0; CairoDrawLoop(hwndClientWindow, swpTemp.cx, swpTemp.cy, pCairoSurface, pCairoHandle); // Clean up! cairo_destroy(pCairoHandle); cairo_surface_destroy(pCairoSurface); cairo_os2_fini(); WinReleasePS(hpsClientWindow); _endthread(); }
static cairo_test_status_t preamble (cairo_test_context_t *ctx) { cairo_surface_t *surface; /* get the error surface */ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX); #if CAIRO_HAS_GL_SURFACE cairo_gl_surface_set_size (surface, 0, 0); cairo_gl_surface_swapbuffers (surface); #endif #if CAIRO_HAS_OS2_SURFACE cairo_os2_surface_set_hwnd (surface, 0); cairo_os2_surface_set_size (surface, 0, 0); cairo_os2_surface_set_manual_window_refresh (surface, FALSE); #endif #if CAIRO_HAS_PDF_SURFACE cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4); cairo_pdf_surface_set_size (surface, 0, 0); #endif #if CAIRO_HAS_PS_SURFACE cairo_ps_surface_set_eps (surface, FALSE); cairo_ps_surface_set_size (surface, 0, 0); cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2); cairo_ps_surface_dsc_comment (surface, NULL); cairo_ps_surface_dsc_begin_setup (surface); cairo_ps_surface_dsc_begin_page_setup (surface); #endif #if CAIRO_HAS_XCB_SURFACE cairo_xcb_surface_set_size (surface, 0, 0); #endif #if CAIRO_HAS_XLIB_SURFACE cairo_xlib_surface_set_size (surface, 0, 0); cairo_xlib_surface_set_drawable (surface, 0, 0, 0); #endif cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0); cairo_surface_set_device_offset (surface, 0, 0); cairo_surface_set_fallback_resolution (surface, 0, 0); cairo_surface_destroy (surface); return CAIRO_TEST_SUCCESS; }