Permalink
Browse files

Add in_clip method for Cairo 1.10+

  • Loading branch information...
1 parent 964b916 commit 16c2a50a283b66019cb6681c4c08d57d47069882 @mgdm mgdm committed Sep 19, 2011
Showing with 40 additions and 0 deletions.
  1. +9 −0 cairo.c
  2. +28 −0 cairo_context.c
  3. +3 −0 php_cairo.h
View
@@ -167,6 +167,12 @@ ZEND_BEGIN_ARG_INFO(cairo_arc_args, ZEND_SEND_BY_VAL)
ZEND_ARG_INFO(0, angle2)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO(cairo_in_clip_args, ZEND_SEND_BY_VAL)
+ ZEND_ARG_OBJ_INFO(0, context, CairoContext, 0)
+ ZEND_ARG_INFO(0, x)
+ ZEND_ARG_INFO(0, y)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO(cairo_curve_to_args, ZEND_SEND_BY_VAL)
ZEND_ARG_OBJ_INFO(0, context, CairoContext, 0)
ZEND_ARG_INFO(0, x1)
@@ -850,6 +856,9 @@ static const zend_function_entry cairo_functions[] = {
PHP_FE(cairo_clip, cairo_context_args)
PHP_FE(cairo_clip_preserve, cairo_context_args)
PHP_FE(cairo_reset_clip, cairo_context_args)
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+ PHP_FE(cairo_in_clip, cairo_in_clip_args)
+#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
PHP_FE(cairo_clip_extents, cairo_context_args)
PHP_FE(cairo_clip_rectangle_list, cairo_context_args)
View
@@ -1093,6 +1093,31 @@ PHP_FUNCTION(cairo_clip)
}
/* }}} */
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+/* {{{ proto boolean cairo_in_clip(CairoContext object, double x, double y)
+ proto boolean CairoContext->inClip(double x, double y)
+ Tests whether the given point is inside the area that would be visible
+ through the current clip
+*/
+PHP_FUNCTION(cairo_in_clip)
+{
+ zval *context_zval = NULL;
+ cairo_context_object *context_object;
+ double x = 0.0, y = 0.0;
+
+ PHP_CAIRO_ERROR_HANDLING(FALSE)
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &context_zval, cairo_ce_cairocontext, &x, &y) == FAILURE) {
+ PHP_CAIRO_RESTORE_ERRORS(FALSE)
+ return;
+ }
+ PHP_CAIRO_RESTORE_ERRORS(FALSE)
+
+ context_object = (cairo_context_object *)cairo_context_object_get(context_zval TSRMLS_CC);
+ RETURN_BOOL(cairo_in_clip(context_object->context, x, y));
+}
+/* }}} */
+#endif
+
/* {{{ proto void cairo_clip_preserve(CairoContext object)
proto void CairoContext->clipPreserve()
Establishes a new clip region by intersecting the current clip region with the current path as it
@@ -2824,6 +2849,9 @@ const zend_function_entry cairo_context_methods[] = {
PHP_ME_MAPPING(setTolerance, cairo_set_tolerance, CairoContext_setTolerance_args, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(getTolerance, cairo_get_tolerance, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(clip, cairo_clip, NULL, ZEND_ACC_PUBLIC)
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+ PHP_ME_MAPPING(inClip, cairo_in_clip, NULL, ZEND_ACC_PUBLIC)
+#endif
PHP_ME_MAPPING(clipPreserve, cairo_clip_preserve, NULL, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(resetClip, cairo_reset_clip, NULL, ZEND_ACC_PUBLIC)
View
@@ -241,6 +241,9 @@ PHP_FUNCTION(cairo_set_tolerance);
PHP_FUNCTION(cairo_get_tolerance);
PHP_FUNCTION(cairo_clip);
PHP_FUNCTION(cairo_clip_preserve);
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+PHP_FUNCTION(cairo_in_clip);
+#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
PHP_FUNCTION(cairo_clip_extents);
PHP_FUNCTION(cairo_clip_rectangle_list);

0 comments on commit 16c2a50

Please sign in to comment.