[cairo-commit] src/cairo-win32-surface.c

Vladimir Vukicevic vladimir at kemper.freedesktop.org
Mon Mar 3 17:44:08 PST 2008


 src/cairo-win32-surface.c |   28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

New commits:
commit 2f9350424fd7eb03ecbdbdee2831944d4e9c35af
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Mon Mar 3 17:43:41 2008 -0800

    [win32] Treat all incoming HDCs as RGB24, regardless of depth
    
    Assuming A8/A1 doesn't really make sense in any case, and doing
    this allows for rendering to 8bpp displays.

diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 660d3c5..4df953f 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1677,9 +1677,10 @@ _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 another surface format,
+ * you will need to create one through
+ * cairo_win32_surface_create_with_dib().
  *
  * Return value: the newly created surface
  **/
@@ -1692,25 +1693,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)


More information about the cairo-commit mailing list