[cairo-commit] cairo/src cairo-surface.c, 1.85, 1.86 cairo-win32-surface.c, 1.32, 1.33 cairo.h, 1.142, 1.143 cairoint.h, 1.175, 1.176

Owen Taylor commit at pdx.freedesktop.org
Mon Aug 1 11:45:44 PDT 2005


Committed by: otaylor

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv8995/src

Modified Files:
	cairo-surface.c cairo-win32-surface.c cairo.h cairoint.h 
Log Message:
2005-08-01  Owen Taylor  <otaylor at redhat.com>

        * src/cairo.h src/cairoint.h src/cairo-surface.c:
        Add cairo_mark_dirty[_rectangle]() and cairo_flush() for

        * src/cairo-win32-surface.c: Implement a cairo_flush()
        that restores the original clip. Also restore the original
        flush when a surface is finished.

        * ROADMAP: Check off the item.


Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cairo-surface.c	28 Jul 2005 17:41:08 -0000	1.85
+++ cairo-surface.c	1 Aug 2005 18:45:42 -0000	1.86
@@ -310,7 +310,15 @@
 	surface->finished = TRUE;
 	return;
     }
-	
+
+    if (!surface->status && surface->backend->flush) {
+	status = surface->backend->flush (surface);
+	if (status) {
+	    _cairo_surface_set_error (surface, status);
+	    return;
+	}
+    }
+
     status = surface->backend->finish (surface);
     if (status) {
 	_cairo_surface_set_error (surface, status);
@@ -393,6 +401,93 @@
 }
 
 /**
+ * cairo_surface_flush:
+ * @surface: a #cairo_surface_t
+ * 
+ * Do any pending drawing for the surface and also restore any
+ * temporary modification's cairo has made to the surface's
+ * state. This function must be called before switching from
+ * drawing on the surface with cairo to drawing on it directly
+ * with native APIs. If the surface doesn't support direct access,
+ * then this function does nothing.
+ **/
+void
+cairo_surface_flush (cairo_surface_t *surface)
+{
+    if (surface->status) {
+	_cairo_surface_set_error (surface, surface->status);
+	return;
+    }
+
+    if (surface->finished) {
+	_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+	return;
+    }
+
+    if (surface->backend->flush) {
+	cairo_status_t status;
+
+	status = surface->backend->flush (surface);
+	
+	if (status)
+	    _cairo_surface_set_error (surface, status);
+    }
+}
+
+/**
+ * cairo_surface_mark_dirty:
+ * @surface: a #cairo_surface_t
+ *
+ * Tells cairo that drawing has been done to surface using means other
+ * than cairo, and that cairo should reread any cached areas. Note
+ * that you must call cairo_surface_flush() before doing such drawing.
+ */
+void
+cairo_surface_mark_dirty (cairo_surface_t *surface)
+{
+    cairo_surface_mark_dirty_rectangle (surface, 0, 0, -1, -1);
+}
+
+/**
+ * cairo_surface_mark_dirty_rectangle:
+ * @surface: a #cairo_surface_t
+ * @x: X coordinate of dirty rectangle
+ * @y: Y coordinate of dirty rectangle
+ * @width: width of dirty rectangle
+ * @height: height of dirty rectangle
+ *
+ * Like cairo_surface_mark_dirty(), but drawing has been done only to
+ * the specified rectangle, so that cairo can retain cached contents
+ * for other parts of the surface.
+ */
+void
+cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
+				    int              x,
+				    int              y,
+				    int              width,
+				    int              height)
+{
+    if (surface->status) {
+	_cairo_surface_set_error (surface, surface->status);
+	return;
+    }
+
+    if (surface->finished) {
+	_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
+	return;
+    }
+
+    if (surface->backend->mark_dirty_rectangle) {
+	cairo_status_t status;
+	
+	status = surface->backend->mark_dirty_rectangle (surface, x, y, width, height);
+	
+	if (status)
+	    _cairo_surface_set_error (surface, status);
+    }
+}
+
+/**
  * cairo_surface_set_device_offset:
  * @surface: a #cairo_surface_t
  * @x_offset: the offset in the X direction, in device units

Index: cairo-win32-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32-surface.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- cairo-win32-surface.c	28 Jul 2005 17:37:41 -0000	1.32
+++ cairo-win32-surface.c	1 Aug 2005 18:45:42 -0000	1.33
@@ -340,8 +340,9 @@
     if (surface->image)
 	cairo_surface_destroy (surface->image);
 
-    if (surface->saved_clip)
+    if (surface->saved_clip) {
 	DeleteObject (surface->saved_clip);
+    }
 
     /* If we created the Bitmap and DC, destroy them */
     if (surface->bitmap) {
@@ -792,7 +793,6 @@
 	    surface->set_clip = 0;
 	}
 	    
-
 	return CAIRO_STATUS_SUCCESS;
     
     } else {
@@ -893,6 +893,12 @@
     return CAIRO_STATUS_SUCCESS;
 }
 
+static cairo_status_t
+_cairo_win32_surface_flush (void *abstract_surface)
+{
+    return _cairo_surface_reset_clip (abstract_surface);
+}
+
 cairo_surface_t *
 cairo_win32_surface_create (HDC hdc)
 {
@@ -964,5 +970,9 @@
     _cairo_win32_surface_set_clip_region,
     NULL, /* intersect_clip_path */
     _cairo_win32_surface_get_extents,
-    NULL  /* show_glyphs */
+    NULL, /* show_glyphs */
+    NULL, /* fill_path */
+    NULL, /* get_font_options */
+    _cairo_win32_surface_flush,
+    NULL  /* mark_dirty_rectangle */
 };

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- cairo.h	28 Jul 2005 17:41:08 -0000	1.142
+++ cairo.h	1 Aug 2005 18:45:42 -0000	1.143
@@ -1149,6 +1149,19 @@
 				cairo_font_options_t *options);
 
 void
+cairo_surface_flush (cairo_surface_t *surface);
+
+void
+cairo_surface_mark_dirty (cairo_surface_t *surface);
+
+void
+cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
+				    int              x,
+				    int              y,
+				    int              width,
+				    int              height);
+
+void
 cairo_surface_set_device_offset (cairo_surface_t *surface,
 				 double           x_offset,
 				 double           y_offset);

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- cairoint.h	29 Jul 2005 19:45:01 -0000	1.175
+++ cairoint.h	1 Aug 2005 18:45:42 -0000	1.176
@@ -779,6 +779,17 @@
     void
     (*get_font_options)         (void                  *surface,
 				 cairo_font_options_t  *options);
+
+    cairo_status_t
+    (*flush)                    (void                  *surface);
+
+    cairo_status_t
+    (*mark_dirty_rectangle)     (void                  *surface,
+				 int                    x,
+				 int                    y,
+				 int                    width,
+				 int                    height);
+
 } cairo_surface_backend_t;
 
 typedef struct _cairo_format_masks {




More information about the cairo-commit mailing list