From b3ce7ea750f00ec4f00338dda4e88a0b4836188f Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Tue, 29 Jan 2008 11:00:57 -0800 Subject: [PATCH] b=367618, initial win32 8bpp bits, r=stuart --- gfx/cairo/README | 5 +++ gfx/cairo/cairo/src/cairo-win32-surface.c | 27 +++--------- gfx/cairo/windows-8bit.patch | 51 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 gfx/cairo/windows-8bit.patch diff --git a/gfx/cairo/README b/gfx/cairo/README index 7678bb3a9f9..da7578aa70c 100644 --- a/gfx/cairo/README +++ b/gfx/cairo/README @@ -30,3 +30,8 @@ endian.patch: include cairo-platform.h for endian macros fixed-24-8.patch: Switch fixed point mode from 16.16 to 24.8 quartz-get-image-surface.patch: Add cairo_quartz_get_image_surface API analogous to the win32 one + +buggy-repeat.patch: Unconditionally turn on buggy-repeat handling to bandaid bug 413583. + +windows-8bit.patch: Initial important bits to get something drawing on 8bpp win32 + diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c index 78e59cacf2d..4ed24101a03 100644 --- a/gfx/cairo/cairo/src/cairo-win32-surface.c +++ b/gfx/cairo/cairo/src/cairo-win32-surface.c @@ -1677,9 +1677,9 @@ _cairo_win32_surface_show_glyphs (void *surface, * * Creates a cairo surface that targets the given DC. The DC will be * queried for its initial clip extents, and this will be used as the - * size of the cairo surface. Also, if the DC is a raster DC, it will - * be queried for its pixel format and the cairo surface format will - * be set appropriately. + * size of the cairo surface. The resulting surface will always + * be of format CAIRO_FORMAT_RGB24; should you need an ARGB32 surface, + * you will need to create one through cairo_win32_surface_create_with_dib. * * Return value: the newly created surface **/ @@ -1692,25 +1692,8 @@ cairo_win32_surface_create (HDC hdc) cairo_format_t format; RECT rect; - if (GetDeviceCaps(hdc, TECHNOLOGY) == DT_RASDISPLAY) { - depth = GetDeviceCaps(hdc, BITSPIXEL); - if (depth == 32) - format = CAIRO_FORMAT_RGB24; - else if (depth == 24) - format = CAIRO_FORMAT_RGB24; - else if (depth == 16) - format = CAIRO_FORMAT_RGB24; - else if (depth == 8) - format = CAIRO_FORMAT_A8; - else if (depth == 1) - format = CAIRO_FORMAT_A1; - else { - _cairo_win32_print_gdi_error("cairo_win32_surface_create(bad BITSPIXEL)"); - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); - } - } else { - format = CAIRO_FORMAT_RGB24; - } + /* Assume that everything coming in as a HDC is RGB24 */ + format = CAIRO_FORMAT_RGB24; surface = malloc (sizeof (cairo_win32_surface_t)); if (surface == NULL) diff --git a/gfx/cairo/windows-8bit.patch b/gfx/cairo/windows-8bit.patch new file mode 100644 index 00000000000..104f40ecf61 --- /dev/null +++ b/gfx/cairo/windows-8bit.patch @@ -0,0 +1,51 @@ +# HG changeset patch +# User Vladimir Vukicevic +# Date 1201565841 28800 +# Node ID 114e54eaf3df3b8b8666d831ab48312735bb04b1 +# Parent 86a787b2874770fa96503a7e513b362fd2c76ba4 +b=367618, can't run in 8bpp mode on win32 + +diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c +--- a/gfx/cairo/cairo/src/cairo-win32-surface.c ++++ b/gfx/cairo/cairo/src/cairo-win32-surface.c +@@ -1677,9 +1677,9 @@ _cairo_win32_surface_show_glyphs (void + * + * Creates a cairo surface that targets the given DC. The DC will be + * queried for its initial clip extents, and this will be used as the +- * size of the cairo surface. Also, if the DC is a raster DC, it will +- * be queried for its pixel format and the cairo surface format will +- * be set appropriately. ++ * size of the cairo surface. The resulting surface will always ++ * be of format CAIRO_FORMAT_RGB24; should you need an ARGB32 surface, ++ * you will need to create one through cairo_win32_surface_create_with_dib. + * + * Return value: the newly created surface + **/ +@@ -1692,25 +1692,8 @@ cairo_win32_surface_create (HDC hdc) + cairo_format_t format; + RECT rect; + +- if (GetDeviceCaps(hdc, TECHNOLOGY) == DT_RASDISPLAY) { +- depth = GetDeviceCaps(hdc, BITSPIXEL); +- if (depth == 32) +- format = CAIRO_FORMAT_RGB24; +- else if (depth == 24) +- format = CAIRO_FORMAT_RGB24; +- else if (depth == 16) +- format = CAIRO_FORMAT_RGB24; +- else if (depth == 8) +- format = CAIRO_FORMAT_A8; +- else if (depth == 1) +- format = CAIRO_FORMAT_A1; +- else { +- _cairo_win32_print_gdi_error("cairo_win32_surface_create(bad BITSPIXEL)"); +- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); +- } +- } else { +- format = CAIRO_FORMAT_RGB24; +- } ++ /* Assume that everything coming in as a HDC is RGB24 */ ++ format = CAIRO_FORMAT_RGB24; + + surface = malloc (sizeof (cairo_win32_surface_t)); + if (surface == NULL)