Author: gnorton
Date: 2007-10-17 16:32:02 -0400 (Wed, 17 Oct 2007)
New Revision: 87708

Modified:
   trunk/libgdiplus/
   trunk/libgdiplus/cairo/src/cairo-quartz-surface.c
   trunk/libgdiplus/src/ChangeLog
   trunk/libgdiplus/src/graphics-private.h
   trunk/libgdiplus/src/graphics.c
Log:
2007-10-17  Geoff Norton  <[EMAIL PROTECTED]>

    * graphics.c: Construct the quartz surface with a image backend so all
    cairo operations can complete without failure.  We blit the image to the
    real cgContext when Flush () is called.
    * graphics-private.h: Set CAIRO_AA_OFFSET_X to 0.5 when running on a Mac.
    Add cg_context to Graphics structure when built with the Quartz surface
    so we can blit the resultant image to the real context.
    Add declarations for the CoreGraphics structures we need for the blitting.
    Add declarations for the CoreGraphics / cairo functions we need to call for
    blitting.
 


Property changes on: trunk/libgdiplus
___________________________________________________________________
Name: svk:merge
   + 248a3c25-2bc5-4592-bb1e-b1aa2d85e5c6:/libgdiplus/mwf-mac:63095

Modified: trunk/libgdiplus/cairo/src/cairo-quartz-surface.c
===================================================================
--- trunk/libgdiplus/cairo/src/cairo-quartz-surface.c   2007-10-17 20:30:31 UTC 
(rev 87707)
+++ trunk/libgdiplus/cairo/src/cairo-quartz-surface.c   2007-10-17 20:32:02 UTC 
(rev 87708)
@@ -1718,6 +1718,8 @@
        return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
+       memset (imageData, 0x0, height * stride);
+
     cgc = CGBitmapContextCreate (imageData,
                                 width,
                                 height,

Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog      2007-10-17 20:30:31 UTC (rev 87707)
+++ trunk/libgdiplus/src/ChangeLog      2007-10-17 20:32:02 UTC (rev 87708)
@@ -1,3 +1,15 @@
+2007-10-17  Geoff Norton  <[EMAIL PROTECTED]>
+
+       * graphics.c: Construct the quartz surface with a image backend so all
+       cairo operations can complete without failure.  We blit the image to the
+       real cgContext when Flush () is called.
+       * graphics-private.h: Set CAIRO_AA_OFFSET_X to 0.5 when running on a 
Mac.
+       Add cg_context to Graphics structure when built with the Quartz surface
+       so we can blit the resultant image to the real context.
+       Add declarations for the CoreGraphics structures we need for the 
blitting.
+       Add declarations for the CoreGraphics / cairo functions we need to call 
for
+       blitting.
+
 2007-08-13  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * text-pango.c: Ensure we can use the results of MeasureString to 

Modified: trunk/libgdiplus/src/graphics-private.h
===================================================================
--- trunk/libgdiplus/src/graphics-private.h     2007-10-17 20:30:31 UTC (rev 
87707)
+++ trunk/libgdiplus/src/graphics-private.h     2007-10-17 20:32:02 UTC (rev 
87708)
@@ -42,8 +42,13 @@
 #include "region-private.h"
 #include "metafile.h"
 
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+#define CAIRO_AA_OFFSET_X              0.5
+#define CAIRO_AA_OFFSET_Y              0.5
+#else
 #define CAIRO_AA_OFFSET_X              1
 #define CAIRO_AA_OFFSET_Y              0.5
+#endif
 
 #define CURVE_MIN_TERMS                        1
 #define CURVE_MAX_TERMS                        7
@@ -131,6 +136,9 @@
        float                   dpi_x;
        float                   dpi_y;
        int                     text_contrast;
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+       void            *cg_context;
+#endif
 } Graphics;
 
 float gdip_unit_conversion (Unit from, Unit to, float dpi, GraphicsType type, 
float nSrc) GDIP_INTERNAL;
@@ -147,6 +155,38 @@
 void gdip_cairo_curve_to (GpGraphics *graphics, double x1, double y1, double 
x2, double y2, double x3, double y3, 
        BOOL convert_units, BOOL antialiasing) GDIP_INTERNAL;
 
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+// For the Quartz backend to function we need a few structures and function 
declarations.
+// Unfortunately including the headers causes conflicts with internal types.  
This must
+// be kept in sync with any changes that might happen (albeit unlikely) to 
apples structures
+struct CGPoint {
+   float x;
+   float y;
+};
+
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+   float width;
+   float height;
+};
+
+typedef struct CGSize CGSize;
+
+struct CGRect {
+   CGPoint origin;
+   CGSize size;
+};
+
+typedef struct CGRect CGRect;
+
+void *CGBitmapContextCreateImage (void *context);
+void CGContextDrawImage (void *context, CGRect rect, void *image);
+void *cairo_quartz_surface_get_cg_context(cairo_surface_t *surface);
+cairo_surface_t *cairo_quartz_surface_create (int format, int width, int 
height);
+cairo_surface_t *cairo_quartz_surface_create_for_cg_context (void *ctx, int 
width, int height);
+#endif
+
 /* include public API */
 #include "image.h"
 #include "graphics.h"

Modified: trunk/libgdiplus/src/graphics.c
===================================================================
--- trunk/libgdiplus/src/graphics.c     2007-10-17 20:30:31 UTC (rev 87707)
+++ trunk/libgdiplus/src/graphics.c     2007-10-17 20:32:02 UTC (rev 87708)
@@ -254,22 +254,16 @@
 #endif
 
 #ifdef CAIRO_HAS_QUARTZ_SURFACE
-
-/* This is a dirty hack; but it gets us around header include issues for now
- FIXME: We need to split all the X11 stuff off into its own file(s) so that
- different backends / font backends can be easily introduced in the future. */
-cairo_surface_t *cairo_quartz_surface_create(void *ctx, int width, int height);
-
 // coverity[+alloc : arg-*3]
 GpStatus
 GdipCreateFromQuartz_macosx (void *ctx, int width, int height, GpGraphics 
**graphics)
 {
-        cairo_surface_t *surface;
+       cairo_surface_t *surface;
 
        if (!graphics)
                return InvalidParameter;
 
-       surface = cairo_quartz_surface_create(ctx, width, height);
+       surface = cairo_quartz_surface_create (0, width, height);
 
        *graphics = gdip_graphics_new(surface);
        (*graphics)->dpi_x = (*graphics)->dpi_y = gdip_get_display_dpi ();
@@ -279,6 +273,7 @@
        (*graphics)->bounds.Height = height;
 
        (*graphics)->type = gtOSXDrawable;
+       (*graphics)->cg_context = ctx;
 
        return Ok;
 }
@@ -1858,6 +1853,18 @@
 
        surface = cairo_get_target (graphics->ct);
        cairo_surface_flush (surface);
+
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+       if (graphics->type == gtOSXDrawable) {
+               CGRect rect;
+       
+               rect.origin.x = 0;
+               rect.origin.y = 0;
+               rect.size.width = graphics->bounds.Width;
+               rect.size.height = graphics->bounds.Height;
+               CGContextDrawImage (graphics->cg_context, rect, 
CGBitmapContextCreateImage (cairo_quartz_surface_get_cg_context (surface)));
+       }
+#endif
        return Ok;
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to