diff options
Diffstat (limited to 'src/cairo-win32-surface.c')
-rw-r--r-- | src/cairo-win32-surface.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index fd7f9e0b..d6d109c4 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -75,7 +75,7 @@ _cairo_win32_print_gdi_error (const char *context) fprintf (stderr, "%s: Unknown GDI error", context); } else { fprintf (stderr, "%s: %s", context, (char *)lpMsgBuf); - + LocalFree (lpMsgBuf); } @@ -116,11 +116,11 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, case CAIRO_FORMAT_RGB24: num_palette = 0; break; - + case CAIRO_FORMAT_A8: num_palette = 256; break; - + case CAIRO_FORMAT_A1: num_palette = 2; break; @@ -141,7 +141,7 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, bitmap_info->bmiHeader.biXPelsPerMeter = 72. / 0.0254; /* unused here */ bitmap_info->bmiHeader.biYPelsPerMeter = 72. / 0.0254; /* unused here */ bitmap_info->bmiHeader.biPlanes = 1; - + switch (format) { /* We can't create real RGB24 bitmaps because something seems to * break if we do, especially if we don't set up an image @@ -155,7 +155,7 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, bitmap_info->bmiHeader.biClrUsed = 0; /* unused */ bitmap_info->bmiHeader.biClrImportant = 0; break; - + case CAIRO_FORMAT_A8: bitmap_info->bmiHeader.biBitCount = 8; bitmap_info->bmiHeader.biCompression = BI_RGB; @@ -168,9 +168,9 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, bitmap_info->bmiColors[i].rgbRed = i; bitmap_info->bmiColors[i].rgbReserved = 0; } - + break; - + case CAIRO_FORMAT_A1: bitmap_info->bmiHeader.biBitCount = 1; bitmap_info->bmiHeader.biCompression = BI_RGB; @@ -204,7 +204,7 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, surface->bitmap); if (!surface->saved_dc_bitmap) goto FAIL; - + if (bitmap_info && num_palette > 2) free (bitmap_info); @@ -218,11 +218,11 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, case CAIRO_FORMAT_RGB24: *rowstride_out = 4 * width; break; - + case CAIRO_FORMAT_A8: *rowstride_out = (width + 3) & ~3; break; - + case CAIRO_FORMAT_A1: *rowstride_out = ((width + 31) & ~31) / 8; break; @@ -233,7 +233,7 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, FAIL: status = _cairo_win32_print_gdi_error ("_create_dc_and_bitmap"); - + if (bitmap_info && num_palette > 2) free (bitmap_info); @@ -241,17 +241,17 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface, SelectObject (surface->dc, surface->saved_dc_bitmap); surface->saved_dc_bitmap = NULL; } - + if (surface->bitmap) { DeleteObject (surface->bitmap); surface->bitmap = NULL; } - + if (surface->dc) { DeleteDC (surface->dc); surface->dc = NULL; } - + return status; } @@ -284,9 +284,9 @@ _cairo_win32_surface_create_for_dc (HDC original_dc, status = CAIRO_STATUS_NO_MEMORY; goto FAIL; } - + surface->format = format; - + surface->clip_rect.x = 0; surface->clip_rect.y = 0; surface->clip_rect.width = width; @@ -375,7 +375,7 @@ _cairo_win32_surface_get_subimage (cairo_win32_surface_t *surface, height); if (local->base.status) return CAIRO_STATUS_NO_MEMORY; - + if (!BitBlt (local->dc, 0, 0, width, height, @@ -395,7 +395,7 @@ _cairo_win32_surface_get_subimage (cairo_win32_surface_t *surface, } *local_out = local; - + return CAIRO_STATUS_SUCCESS; FAIL: @@ -441,7 +441,7 @@ _cairo_win32_surface_release_source_image (void *abstract_surf void *image_extra) { cairo_win32_surface_t *local = image_extra; - + if (local) cairo_surface_destroy ((cairo_surface_t *)local); } @@ -489,14 +489,14 @@ _cairo_win32_surface_acquire_dest_image (void *abstract_surfa x2 = interest_rect->x + interest_rect->width; if (interest_rect->y + interest_rect->height < y2) y2 = interest_rect->y + interest_rect->height; - + if (x1 >= x2 || y1 >= y2) { *image_out = NULL; *image_extra = NULL; - + return CAIRO_STATUS_SUCCESS; } - + status = _cairo_win32_surface_get_subimage (abstract_surface, x1, y1, x2 - x1, y2 - y1, &local); @@ -505,7 +505,7 @@ _cairo_win32_surface_acquire_dest_image (void *abstract_surfa *image_out = (cairo_image_surface_t *)local->image; *image_extra = local; - + image_rect->x = x1; image_rect->y = y1; image_rect->width = x2 - x1; @@ -523,7 +523,7 @@ _cairo_win32_surface_release_dest_image (void *abstract_surfa { cairo_win32_surface_t *surface = abstract_surface; cairo_win32_surface_t *local = image_extra; - + if (!local) return; @@ -588,22 +588,22 @@ _composite_alpha_blend (cairo_win32_surface_t *dst, */ if (!alpha_blend_checked) { OSVERSIONINFO os; - + os.dwOSVersionInfoSize = sizeof (os); GetVersionEx (&os); - + /* If running on Win98, disable using AlphaBlend() * to avoid Win98 AlphaBlend() bug */ if (VER_PLATFORM_WIN32_WINDOWS != os.dwPlatformId || os.dwMajorVersion != 4 || os.dwMinorVersion != 10) { HMODULE msimg32_dll = LoadLibrary ("msimg32"); - + if (msimg32_dll != NULL) alpha_blend = (cairo_alpha_blend_func_t)GetProcAddress (msimg32_dll, "AlphaBlend"); } - + alpha_blend_checked = TRUE; } @@ -611,7 +611,7 @@ _composite_alpha_blend (cairo_win32_surface_t *dst, return CAIRO_INT_STATUS_UNSUPPORTED; if (GetDeviceCaps(dst->dc, SHADEBLENDCAPS) == SB_NONE) return CAIRO_INT_STATUS_UNSUPPORTED; - + blend_function.BlendOp = AC_SRC_OVER; blend_function.BlendFlags = 0; blend_function.SourceConstantAlpha = alpha; @@ -625,7 +625,7 @@ _composite_alpha_blend (cairo_win32_surface_t *dst, width, height, blend_function)) return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite"); - + return CAIRO_STATUS_SUCCESS; } @@ -671,7 +671,7 @@ _cairo_win32_surface_composite (cairo_operator_t op, if (src->base.backend != dst->base.backend) return CAIRO_INT_STATUS_UNSUPPORTED; - + integer_transform = _cairo_matrix_is_integer_translation (&pattern->matrix, &itx, &ity); if (!integer_transform) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -706,7 +706,7 @@ _cairo_win32_surface_composite (cairo_operator_t op, if (alpha == 255 && (op == CAIRO_OPERATOR_SOURCE || (src->format == CAIRO_FORMAT_RGB24 && op == CAIRO_OPERATOR_OVER))) { - + if (!BitBlt (dst->dc, dst_x, dst_y, width, height, @@ -716,7 +716,7 @@ _cairo_win32_surface_composite (cairo_operator_t op, return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite"); return CAIRO_STATUS_SUCCESS; - + } else if ((src->format == CAIRO_FORMAT_RGB24 || src->format == CAIRO_FORMAT_ARGB32) && (dst->format == CAIRO_FORMAT_RGB24 || dst->format == CAIRO_FORMAT_ARGB32) && op == CAIRO_OPERATOR_OVER) { @@ -725,7 +725,7 @@ _cairo_win32_surface_composite (cairo_operator_t op, src_x, src_y, dst_x, dst_y, width, height); } - + return CAIRO_INT_STATUS_UNSUPPORTED; } @@ -747,13 +747,13 @@ categorize_solid_dest_operator (cairo_operator_t op, source = SOURCE_TRANSPARENT; else source = SOURCE_OTHER; - + switch (op) { case CAIRO_OPERATOR_CLEAR: /* 0 0 */ case CAIRO_OPERATOR_OUT: /* 1 - Ab 0 */ return DO_CLEAR; break; - + case CAIRO_OPERATOR_SOURCE: /* 1 0 */ case CAIRO_OPERATOR_IN: /* Ab 0 */ return DO_SOURCE; @@ -768,7 +768,7 @@ categorize_solid_dest_operator (cairo_operator_t op, else return DO_UNSUPPORTED; break; - + case CAIRO_OPERATOR_DEST_OUT: /* 0 1 - Aa */ case CAIRO_OPERATOR_XOR: /* 1 - Ab 1 - Aa */ if (source == SOURCE_SOLID) @@ -778,7 +778,7 @@ categorize_solid_dest_operator (cairo_operator_t op, else return DO_UNSUPPORTED; break; - + case CAIRO_OPERATOR_DEST: /* 0 1 */ case CAIRO_OPERATOR_DEST_OVER:/* 1 - Ab 1 */ case CAIRO_OPERATOR_SATURATE: /* min(1,(1-Ab)/Aa) 1 */ @@ -794,7 +794,7 @@ categorize_solid_dest_operator (cairo_operator_t op, else return DO_UNSUPPORTED; break; - + case CAIRO_OPERATOR_ADD: /* 1 1 */ if (source == SOURCE_TRANSPARENT) return DO_NOTHING; @@ -843,11 +843,11 @@ _cairo_win32_surface_fill_rectangles (void *abstract_surface, default: return CAIRO_INT_STATUS_UNSUPPORTED; } - + new_brush = CreateSolidBrush (new_color); if (!new_brush) return _cairo_win32_print_gdi_error ("_cairo_win32_surface_fill_rectangles"); - + for (i = 0; i < num_rects; i++) { RECT rect; @@ -861,14 +861,14 @@ _cairo_win32_surface_fill_rectangles (void *abstract_surface, } DeleteObject (new_brush); - + return CAIRO_STATUS_SUCCESS; FAIL: status = _cairo_win32_print_gdi_error ("_cairo_win32_surface_fill_rectangles"); - + DeleteObject (new_brush); - + return status; } @@ -901,7 +901,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, return _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region (reset)"); return CAIRO_STATUS_SUCCESS; - + } else { pixman_box16_t *boxes = pixman_region_rects (region); int num_boxes = pixman_region_num_rects (region); @@ -938,7 +938,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, gdi_region = ExtCreateRegion (NULL, data_size, data); free (data); - + if (!gdi_region) return CAIRO_STATUS_NO_MEMORY; @@ -1143,11 +1143,11 @@ cairo_win32_surface_create (HDC hdc) surface->image = NULL; surface->format = format; - + surface->dc = hdc; surface->bitmap = NULL; surface->saved_dc_bitmap = NULL; - + surface->clip_rect.x = rect.left; surface->clip_rect.y = rect.top; surface->clip_rect.width = rect.right - rect.left; |