[cairo-commit] 6 commits - src/cairo.c src/cairo-color.c src/cairo-device.c src/cairo-gstate.c src/cairo.h src/cairoint.h src/cairo-pattern.c src/drm

Andrea Canciani ranma42 at kemper.freedesktop.org
Fri Jul 8 13:49:25 PDT 2011


 src/cairo-color.c      |   13 -------------
 src/cairo-device.c     |    4 ++--
 src/cairo-gstate.c     |   12 +-----------
 src/cairo-pattern.c    |   31 +++----------------------------
 src/cairo.c            |    3 ++-
 src/cairo.h            |   23 ++++++++++++++---------
 src/cairoint.h         |    8 +-------
 src/drm/cairo-drm-xr.c |    9 +++++----
 8 files changed, 28 insertions(+), 75 deletions(-)

New commits:
commit 05a0b24ecbafccf63e0114889301fc23268a9efc
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Fri Jul 8 11:24:16 2011 +0200

    device: Fix documentation of device types
    
    The documentation of device types incorrectly talks about surfaces and
    lacks the new INVALID type.

diff --git a/src/cairo.h b/src/cairo.h
index ef3028b..3cab6bc 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1952,26 +1952,27 @@ cairo_device_reference (cairo_device_t *device);
 
 /**
  * cairo_device_type_t:
- * @CAIRO_DEVICE_TYPE_DRM: The surface is of type Direct Render Manager
- * @CAIRO_DEVICE_TYPE_GL: The surface is of type OpenGL
- * @CAIRO_DEVICE_TYPE_SCRIPT: The surface is of type script
- * @CAIRO_DEVICE_TYPE_XCB: The surface is of type xcb
- * @CAIRO_DEVICE_TYPE_XLIB: The surface is of type xlib
- * @CAIRO_DEVICE_TYPE_XML: The surface is of type XML
+ * @CAIRO_DEVICE_TYPE_INVALID: The device is not valid
+ * @CAIRO_DEVICE_TYPE_DRM: The device is of type Direct Render Manager
+ * @CAIRO_DEVICE_TYPE_GL: The device is of type OpenGL
+ * @CAIRO_DEVICE_TYPE_SCRIPT: The device is of type script
+ * @CAIRO_DEVICE_TYPE_XCB: The device is of type xcb
+ * @CAIRO_DEVICE_TYPE_XLIB: The device is of type xlib
+ * @CAIRO_DEVICE_TYPE_XML: The device is of type XML
  *
  * #cairo_device_type_t is used to describe the type of a given
  * device. The devices types are also known as "backends" within cairo.
  *
  * The device type can be queried with cairo_device_get_type()
  *
- * The various #cairo_device_t functions can be used with surfaces of
+ * The various #cairo_device_t functions can be used with devices of
  * any type, but some backends also provide type-specific functions
  * that must only be called with a device of the appropriate
  * type. These functions have names that begin with
  * <literal>cairo_<emphasis>type</emphasis>_device</literal> such as
  * cairo_xcb_device_debug_cap_xrender_version().
  *
- * The behavior of calling a type-specific function with a surface of
+ * The behavior of calling a type-specific function with a device of
  * the wrong type is undefined.
  *
  * New entries may be added in future versions.
commit 02a331de13313085d671716031a3b61778014b87
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jul 6 22:49:29 2011 +0200

    device: Define the CAIRO_DEVICE_TYPE_INVALID device type
    
    Define a new device type to indicate that the device is not valid.
    The -1 value is along the same line as CAIRO_FORMAT_INVALID (and is
    likely to have the same issues).

diff --git a/src/cairo-device.c b/src/cairo-device.c
index 3c200e0..b6dde63 100644
--- a/src/cairo-device.c
+++ b/src/cairo-device.c
@@ -365,7 +365,7 @@ cairo_device_get_type (cairo_device_t *device)
     if (device == NULL ||
 	CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count))
     {
-	return (cairo_device_type_t) -1;
+	return CAIRO_DEVICE_TYPE_INVALID;
     }
 
     return device->backend->type;
diff --git a/src/cairo.h b/src/cairo.h
index 0907b95..ef3028b 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1984,7 +1984,9 @@ typedef enum _cairo_device_type {
     CAIRO_DEVICE_TYPE_SCRIPT,
     CAIRO_DEVICE_TYPE_XCB,
     CAIRO_DEVICE_TYPE_XLIB,
-    CAIRO_DEVICE_TYPE_XML
+    CAIRO_DEVICE_TYPE_XML,
+
+    CAIRO_DEVICE_TYPE_INVALID = -1
 } cairo_device_type_t;
 
 cairo_public cairo_device_type_t
commit 35d8d206355b281d09d50b61d6497cea39e09624
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jul 6 22:45:02 2011 +0200

    device: Add CAIRO_STATUS_DEVICE_FINISHED
    
    Instead of abusing CAIRO_STATUS_SURFACE_FINISHED to indicate the use
    of a finished device, define and use the new error status
    CAIRO_STATUS_DEVICE_FINISHED.

diff --git a/src/cairo-device.c b/src/cairo-device.c
index f905caf..3c200e0 100644
--- a/src/cairo-device.c
+++ b/src/cairo-device.c
@@ -411,7 +411,7 @@ cairo_device_acquire (cairo_device_t *device)
 	return device->status;
 
     if (unlikely (device->finished))
-	return _cairo_device_set_error (device, CAIRO_STATUS_SURFACE_FINISHED); /* XXX */
+	return _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_FINISHED);
 
     CAIRO_MUTEX_LOCK (device->mutex);
     if (device->mutex_depth++ == 0) {
diff --git a/src/cairo.c b/src/cairo.c
index 8f16d6d..0aae04b 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -167,7 +167,8 @@ static const cairo_t _cairo_nil[] = {
     DEFINE_NIL_CONTEXT (CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED),
     DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_TYPE_MISMATCH),
     DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_ERROR),
-    DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION)
+    DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION),
+    DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_FINISHED)
 };
 
 COMPILE_TIME_ASSERT (ARRAY_LENGTH (_cairo_nil) == CAIRO_STATUS_LAST_STATUS - 1);
diff --git a/src/cairo.h b/src/cairo.h
index 6871665..0907b95 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -275,6 +275,7 @@ typedef struct _cairo_user_data_key {
  *   construction operation was used outside of a
  *   cairo_mesh_pattern_begin_patch()/cairo_mesh_pattern_end_patch()
  *   pair (Since 1.12)
+ * @CAIRO_STATUS_DEVICE_FINISHED: target device has been finished (Since 1.12)
  * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
  *   status values defined in this enumeration.  When using this value, note
  *   that the version of cairo at run-time may have additional status values
@@ -327,6 +328,7 @@ typedef enum _cairo_status {
     CAIRO_STATUS_DEVICE_TYPE_MISMATCH,
     CAIRO_STATUS_DEVICE_ERROR,
     CAIRO_STATUS_INVALID_MESH_CONSTRUCTION,
+    CAIRO_STATUS_DEVICE_FINISHED,
 
     CAIRO_STATUS_LAST_STATUS
 } cairo_status_t;
commit 780534cd31af6f4837a4f5a0e445ae609c3559c3
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jul 6 22:23:05 2011 +0200

    gstate: Remove useless code
    
    gstate->source has been initialized as the static black pattern, so
    its status is success.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index ac73ca9..d9672c2 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -86,8 +86,6 @@ cairo_status_t
 _cairo_gstate_init (cairo_gstate_t  *gstate,
 		    cairo_surface_t *target)
 {
-    cairo_status_t status;
-
     VG (VALGRIND_MAKE_MEM_UNDEFINED (gstate, sizeof (cairo_gstate_t)));
 
     gstate->next = NULL;
@@ -131,15 +129,7 @@ _cairo_gstate_init (cairo_gstate_t  *gstate,
     /* Now that the gstate is fully initialized and ready for the eventual
      * _cairo_gstate_fini(), we can check for errors (and not worry about
      * the resource deallocation). */
-    status = target->status;
-    if (unlikely (status))
-	return status;
-
-    status = gstate->source->status;
-    if (unlikely (status))
-	return status;
-
-    return CAIRO_STATUS_SUCCESS;
+    return target->status;
 }
 
 /**
commit 4679b28e211613391764919578161d400bc9075f
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Thu Jul 7 18:28:42 2011 +0200

    color: Remove unused functions
    
    _cairo_color_init() and _cairo_color_init_rgb() are basically unused
    (except in some experimantal code, which is trivial to fix).

diff --git a/src/cairo-color.c b/src/cairo-color.c
index d20fea4..9c85255 100644
--- a/src/cairo-color.c
+++ b/src/cairo-color.c
@@ -77,19 +77,6 @@ _cairo_stock_color (cairo_stock_t stock)
     }
 }
 
-void
-_cairo_color_init (cairo_color_t *color)
-{
-    *color = cairo_color_white;
-}
-
-void
-_cairo_color_init_rgb (cairo_color_t *color,
-		       double red, double green, double blue)
-{
-    _cairo_color_init_rgba (color, red, green, blue, 1.0);
-}
-
 /* Convert a double in [0.0, 1.0] to an integer in [0, 65535]
  * The conversion is designed to divide the input range into 65536
  * equally-sized regions. This is achieved by multiplying by 65536 and
diff --git a/src/cairoint.h b/src/cairoint.h
index 121676c..3ab7701 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1043,13 +1043,6 @@ cairo_private uint16_t
 _cairo_color_double_to_short (double d) cairo_const;
 
 cairo_private void
-_cairo_color_init (cairo_color_t *color);
-
-cairo_private void
-_cairo_color_init_rgb (cairo_color_t *color,
-		       double red, double green, double blue);
-
-cairo_private void
 _cairo_color_init_rgba (cairo_color_t *color,
 			double red, double green, double blue,
 			double alpha);
diff --git a/src/drm/cairo-drm-xr.c b/src/drm/cairo-drm-xr.c
index c3b1bbd..49d1728 100644
--- a/src/drm/cairo-drm-xr.c
+++ b/src/drm/cairo-drm-xr.c
@@ -669,10 +669,11 @@ xr_poly_fill_rect (DrawablePtr drawable,
 	    }
 	}
 
-	_cairo_color_init_rgb (&color,
-			       ((gc->fgPixel & 0x00ff0000) >> 16) / 255.,
-			       ((gc->fgPixel & 0x0000ff00) >> 8) / 255.,
-			       ((gc->fgPixel & 0x000000ff) >> 0) / 255.);
+	_cairo_color_init_rgba (&color,
+				((gc->fgPixel & 0x00ff0000) >> 16) / 255.,
+				((gc->fgPixel & 0x0000ff00) >>  8) / 255.,
+				((gc->fgPixel & 0x000000ff) >>  0) / 255.,
+				1.0);
 	_cairo_pattern_init_solid (&pattern, &color, CAIRO_CONTENT_COLOR);
 
 	status = _cairo_surface_fill (surface,
commit 9374cf0a9730843881043c39ab4c6f6d31af7cce
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jul 6 15:14:55 2011 +0200

    pattern: Implement _rgb functions as wrappers over _rgba functions
    
    cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb()
    implement the same logic as cairo_pattern_create_rgba() and
    cairo_pattern_add_color_stop_rgba() with an alpha == 1.0.
    
    Instead of duplicating the code, they can simply call into the more
    general functions.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 1e9326d..7fab4f3 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -587,17 +587,7 @@ _cairo_pattern_create_in_error (cairo_status_t status)
 cairo_pattern_t *
 cairo_pattern_create_rgb (double red, double green, double blue)
 {
-    cairo_color_t color;
-
-    red   = _cairo_restrict_value (red,   0.0, 1.0);
-    green = _cairo_restrict_value (green, 0.0, 1.0);
-    blue  = _cairo_restrict_value (blue,  0.0, 1.0);
-
-    _cairo_color_init_rgb (&color, red, green, blue);
-
-    CAIRO_MUTEX_INITIALIZE ();
-
-    return _cairo_pattern_create_solid (&color);
+    return cairo_pattern_create_rgba (red, green, blue, 1.0);
 }
 slim_hidden_def (cairo_pattern_create_rgb);
 
@@ -1821,23 +1811,7 @@ cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
 				  double	   green,
 				  double	   blue)
 {
-    if (pattern->status)
-	return;
-
-    if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
-	pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
-    {
-	_cairo_pattern_set_error (pattern, CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
-	return;
-    }
-
-    offset = _cairo_restrict_value (offset, 0.0, 1.0);
-    red    = _cairo_restrict_value (red,    0.0, 1.0);
-    green  = _cairo_restrict_value (green,  0.0, 1.0);
-    blue   = _cairo_restrict_value (blue,   0.0, 1.0);
-
-    _cairo_pattern_add_color_stop ((cairo_gradient_pattern_t *) pattern,
-				   offset, red, green, blue, 1.0);
+    cairo_pattern_add_color_stop_rgba (pattern, offset, red, green, blue, 1.0);
 }
 
 /**
@@ -1894,6 +1868,7 @@ cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern,
     _cairo_pattern_add_color_stop ((cairo_gradient_pattern_t *) pattern,
 				   offset, red, green, blue, alpha);
 }
+slim_hidden_def (cairo_pattern_add_color_stop_rgba);
 
 /**
  * cairo_pattern_set_matrix:
diff --git a/src/cairoint.h b/src/cairoint.h
index 424457f..121676c 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2438,6 +2438,7 @@ slim_hidden_proto (cairo_matrix_translate);
 slim_hidden_proto (cairo_move_to);
 slim_hidden_proto (cairo_new_path);
 slim_hidden_proto (cairo_paint);
+slim_hidden_proto (cairo_pattern_add_color_stop_rgba);
 slim_hidden_proto (cairo_pattern_create_for_surface);
 slim_hidden_proto (cairo_pattern_create_rgb);
 slim_hidden_proto (cairo_pattern_create_rgba);


More information about the cairo-commit mailing list