[cairo] State of Win32 backend?
Owen Taylor
otaylor at redhat.com
Thu May 5 13:45:17 PDT 2005
On Wed, 2005-05-04 at 11:33 +0300, Tor Lillqvist wrote:
> Hi,
>
> Cairo HEAD has for some time not built on Win32. The below makes it
> build, but I can't really say whether this is correct or not.
Thanks for looking into it. cairo-snippets is a good way to test
out the win32 backend, but unfortunately, is almost impossible to
build because you need to get libsvg/libsvg-cairo going first.
> Index: src/cairo-win32-font.c
> ===================================================================
> RCS file: /cvs/cairo/cairo/src/cairo-win32-font.c,v
> retrieving revision 1.16
> diff -p -u -4 -r1.16 cairo-win32-font.c
> --- src/cairo-win32-font.c 8 Apr 2005 20:14:17 -0000 1.16
> +++ src/cairo-win32-font.c 4 May 2005 07:30:24 -0000
> @@ -1002,20 +1002,21 @@ _cairo_win32_scaled_font_show_glyphs (vo
> if (_cairo_surface_is_win32 (generic_surface) &&
> surface->format == CAIRO_FORMAT_RGB24 &&
> operator == CAIRO_OPERATOR_OVER &&
> pattern->type == CAIRO_PATTERN_SOLID &&
> - _cairo_pattern_is_opaque (pattern)) {
> + _cairo_pattern_is_opaque_solid (pattern)) {
This is right, but you can drop the
pattern->type == CAIRO_PATTERN_SOLID.
> cairo_solid_pattern_t *solid_pattern = (cairo_solid_pattern_t *)pattern;
>
> /* When compositing OVER on a GDI-understood surface, with a
> * solid opaque color, we can just call ExtTextOut directly.
> */
> COLORREF new_color;
>
> - new_color = RGB (((int)(0xffff * solid_pattern->red)) >> 8,
> - ((int)(0xffff * solid_pattern->green)) >> 8,
> - ((int)(0xffff * solid_pattern->blue)) >> 8);
> + /* XXX Use the unpremultiplied or premultiplied color? */
> + new_color = RGB (((int)(0xffff * solid_pattern->color.red_short)) >> 8,
> + ((int)(0xffff * solid_pattern->color.green_short)) >> 8,
> + ((int)(0xffff * solid_pattern->color.blue_short)) >> 8);
No, this isn't right. You'll compute 0xffff * 0xffff >> 8. The
"0xffff *" isn't needed when you are using red_short.
> Index: src/cairo-win32-surface.c
> ===================================================================
> RCS file: /cvs/cairo/cairo/src/cairo-win32-surface.c,v
> retrieving revision 1.19
> diff -p -u -4 -r1.19 cairo-win32-surface.c
> --- src/cairo-win32-surface.c 26 Apr 2005 02:38:44 -0000 1.19
> +++ src/cairo-win32-surface.c 4 May 2005 07:30:25 -0000
> @@ -532,28 +532,15 @@ _cairo_win32_surface_composite (cairo_op
> {
> cairo_win32_surface_t *dst = abstract_dst;
> cairo_win32_surface_t *src;
> cairo_surface_pattern_t *src_surface_pattern;
> - int alpha;
> int integer_transform;
> int itx, ity;
>
> if (pattern->type != CAIRO_PATTERN_SURFACE ||
> pattern->extend != CAIRO_EXTEND_NONE)
> return CAIRO_INT_STATUS_UNSUPPORTED;
>
> - if (mask_pattern) {
> - /* FIXME: When we fully support RENDER style 4-channel
> - * masks we need to check r/g/b != 1.0.
> - */
> - if (mask_pattern->type != CAIRO_PATTERN_SOLID)
> - return CAIRO_INT_STATUS_UNSUPPORTED;
> -
> - alpha = (int)(0xffff * pattern->alpha * mask_pattern->alpha) >> 8;
> - } else {
> - alpha = (int)(0xffff * pattern->alpha) >> 8;
> - }
This should be something like:
if (mask_pattern) {
/* FIXME: When we fully support RENDER style 4-channel
* masks we need to check r/g/b != 1.0.
*/
if (mask_pattern->type != CAIRO_PATTERN_SOLID)
return CAIRO_INT_STATUS_UNSUPPORTED;
alpha = solid_pattern->color.alpha_short >> 8;
} else {
alpha = 255;
}
>
> - if (alpha == 255 &&
> - src->format == dst->format &&
> - (operator == CAIRO_OPERATOR_SRC ||
> - (src->format == CAIRO_FORMAT_RGB24 && operator == CAIRO_OPERATOR_OVER))) {
> -
> - if (!BitBlt (dst->dc,
> - dst_x, dst_y,
> - width, height,
> - src->dc,
> - src_x + itx, src_y + ity,
> - SRCCOPY))
> - return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite");
> -
> - return CAIRO_STATUS_SUCCESS;
Don't understand why you removed this.
>
> BLENDFUNCTION blend_function;
>
> blend_function.BlendOp = AC_SRC_OVER;
> blend_function.BlendFlags = 0;
> - blend_function.SourceConstantAlpha = alpha;
> + blend_function.SourceConstantAlpha = 255;
Needs to be 'alpha', see above.
> blend_function.AlphaFormat = src->format == CAIRO_FORMAT_ARGB32 ? AC_SRC_ALPHA : 0;
>
> if (!AlphaBlend (dst->dc,
> dst_x, dst_y,
> @@ -780,11 +752,12 @@ _cairo_win32_surface_set_clip_region (vo
> }
> }
>
> static cairo_int_status_t
> -_cairo_win32_get_extents (void *abstract_surface,
> - cairo_rectangle_t *rectangle)
> +_cairo_win32_surface_get_extents (void *abstract_surface,
> + cairo_rectangle_t *rectangle)
> {
> + cairo_win32_surface_t *surface = abstract_surface;
> RECT clip_box;
Looks reasonable.
Regards,
Owen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050505/c84848ab/attachment.pgp
More information about the cairo
mailing list