[cairo-commit] 2 commits - src/cairo-gl-source.c src/win32

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Oct 17 05:12:56 PDT 2015


 src/cairo-gl-source.c                    |    6 +++--
 src/win32/cairo-win32-display-surface.c  |    6 +++--
 src/win32/cairo-win32-printing-surface.c |   36 ++++++++++++++++++++++++-------
 3 files changed, 36 insertions(+), 12 deletions(-)

New commits:
commit 2d026bd2cf4d8cb1973f56b30a7ba8609e3ebb5f
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Oct 17 22:39:09 2015 +1030

    win32-print: support subsurface recording patterns

diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 1571480..025b2c9 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -334,7 +334,8 @@ _cairo_win32_display_surface_create_for_dc (HDC             original_dc,
     _cairo_surface_init (&surface->win32.base,
 			 &cairo_win32_display_surface_backend,
 			 device,
-			 _cairo_content_from_format (format));
+			 _cairo_content_from_format (format),
+			 FALSE); /* is_vector */
 
     cairo_device_destroy (device);
 
@@ -979,7 +980,8 @@ cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
     _cairo_surface_init (&surface->win32.base,
 			 &cairo_win32_display_surface_backend,
 			 device,
-			 _cairo_content_from_format (format));
+			 _cairo_content_from_format (format),
+			 FALSE); /* is_vector */
 
     cairo_device_destroy (device);
 
diff --git a/src/win32/cairo-win32-printing-surface.c b/src/win32/cairo-win32-printing-surface.c
index 510c563..afc0b11 100644
--- a/src/win32/cairo-win32-printing-surface.c
+++ b/src/win32/cairo-win32-printing-surface.c
@@ -60,6 +60,8 @@
 #include "cairo-image-surface-private.h"
 #include "cairo-surface-backend-private.h"
 #include "cairo-surface-clipper-private.h"
+#include "cairo-surface-snapshot-inline.h"
+#include "cairo-surface-subsurface-private.h"
 
 #include <windows.h>
 
@@ -546,6 +548,8 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
     RECT clip;
     cairo_recording_surface_t *recording_surface = (cairo_recording_surface_t *) pattern->surface;
     cairo_box_t bbox;
+    cairo_surface_t *free_me = NULL;
+    cairo_bool_t is_subsurface;
 
     extend = cairo_pattern_get_extend (&pattern->base);
 
@@ -561,15 +565,28 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
     SaveDC (surface->win32.dc);
     _cairo_matrix_to_win32_xform (&p2d, &xform);
 
-    status = _cairo_recording_surface_get_bbox (recording_surface, &bbox, NULL);
-    if (status)
-	return status;
+    if (_cairo_surface_is_snapshot (&recording_surface->base)) {
+	free_me = _cairo_surface_snapshot_get_target (&recording_surface->base);
+	recording_surface = (cairo_recording_surface_t *) free_me;
+    }
+
+    if (recording_surface->base.backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
+	cairo_surface_subsurface_t *sub = (cairo_surface_subsurface_t *) recording_surface;
+
+	recording_surface = (cairo_recording_surface_t *) (sub->target);
+	recording_extents = sub->extents;
+	is_subsurface = TRUE;
+    } else {
+	status = _cairo_recording_surface_get_bbox (recording_surface, &bbox, NULL);
+	if (status)
+	    goto err;
 
-    _cairo_box_round_to_rectangle (&bbox, &recording_extents);
+	_cairo_box_round_to_rectangle (&bbox, &recording_extents);
+    }
 
     status = _cairo_win32_printing_surface_get_ctm_clip_box (surface, &clip);
     if (status)
-	return status;
+	goto err;
 
     if (extend == CAIRO_EXTEND_REPEAT || extend == CAIRO_EXTEND_REFLECT) {
 	left = floor (clip.left / _cairo_fixed_to_double (bbox.p2.x - bbox.p1.x));
@@ -589,7 +606,7 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
 	status = _cairo_win32_printing_surface_paint_solid_pattern (surface,
 								    &_cairo_pattern_black.base);
 	if (status)
-	    return status;
+	    goto err;
     }
 
     for (y_tile = top; y_tile < bottom; y_tile++) {
@@ -643,7 +660,8 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
 	    SelectClipPath (surface->win32.dc, RGN_AND);
 
 	    SaveDC (surface->win32.dc); /* Allow clip path to be reset during replay */
-	    status = _cairo_recording_surface_replay_region (&recording_surface->base, NULL,
+	    status = _cairo_recording_surface_replay_region (&recording_surface->base,
+							     is_subsurface ? &recording_extents : NULL,
 							     &surface->win32.base,
 							     CAIRO_RECORDING_REGION_NATIVE);
 	    assert (status != CAIRO_INT_STATUS_UNSUPPORTED);
@@ -651,7 +669,7 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
 	    RestoreDC (surface->win32.dc, -2);
 
 	    if (status)
-		return status;
+		goto err;
 	}
     }
 
@@ -660,6 +678,8 @@ _cairo_win32_printing_surface_paint_recording_pattern (cairo_win32_printing_surf
     surface->has_ctm = old_has_ctm;
     RestoreDC (surface->win32.dc, -1);
 
+  err:
+    cairo_surface_destroy (free_me);
     return status;
 }
 
commit b7d864e8c18e4407e69ff897cae7a42eb09b03c9
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Oct 17 22:38:50 2015 +1030

    Compile fix

diff --git a/src/cairo-gl-source.c b/src/cairo-gl-source.c
index 1223529..ba11b7e 100644
--- a/src/cairo-gl-source.c
+++ b/src/cairo-gl-source.c
@@ -76,7 +76,8 @@ _cairo_gl_pattern_to_source (cairo_surface_t *dst,
     _cairo_surface_init (&source->base,
 			 &cairo_gl_source_backend,
 			 NULL, /* device */
-			 CAIRO_CONTENT_COLOR_ALPHA);
+			 CAIRO_CONTENT_COLOR_ALPHA,
+			 FALSE); /* is_vector */
 
     *src_x = *src_y = 0;
     status = _cairo_gl_operand_init (&source->operand, pattern,
@@ -103,7 +104,8 @@ _cairo_gl_white_source (void)
     _cairo_surface_init (&source->base,
 			 &cairo_gl_source_backend,
 			 NULL, /* device */
-			 CAIRO_CONTENT_COLOR_ALPHA);
+			 CAIRO_CONTENT_COLOR_ALPHA,
+			 FALSE); /* is_vector */
 
     _cairo_gl_solid_operand_init (&source->operand, CAIRO_COLOR_WHITE);
 


More information about the cairo-commit mailing list