[cairo-commit]
cairo/src Makefile.am, 1.75, 1.76 cairo-atsui-font.c,
1.26, 1.27 cairo-quartz-private.h, NONE,
1.1 cairo-quartz-surface.c, 1.22, 1.23
Anders Carlsson
commit at pdx.freedesktop.org
Tue Jan 10 05:29:02 PST 2006
Committed by: andersca
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv1422/src
Modified Files:
Makefile.am cairo-atsui-font.c cairo-quartz-surface.c
Added Files:
cairo-quartz-private.h
Log Message:
2006-01-10 Anders Carlsson <andersca at imendio.com>
* src/Makefile.am:
Add cairo-quartz-private.h
* src/cairo-atsui-font.c:
(_cairo_atsui_font_old_show_glyphs):
If the destination surface is a quartz surface, get the clip mask
from it.
* src/cairo-quartz-private.h: Added.
* src/cairo-quartz-surface.c:
(_cairo_quartz_surface_finish):
(_cairo_quartz_surface_set_clip_region):
(cairo_quartz_surface_create):
Keep a copy of the clip mask around.
(_cairo_surface_is_quartz):
New function which determines if a given surface is a quartz surface.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/src/Makefile.am,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- Makefile.am 29 Dec 2005 15:17:01 -0000 1.75
+++ Makefile.am 10 Jan 2006 13:29:00 -0000 1.76
@@ -33,7 +33,7 @@
if CAIRO_HAS_QUARTZ_SURFACE
libcairo_quartz_headers = cairo-quartz.h
-libcairo_quartz_sources = cairo-quartz-surface.c
+libcairo_quartz_sources = cairo-quartz-surface.c cairo-quartz-private.h
endif
if CAIRO_HAS_XCB_SURFACE
Index: cairo-atsui-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-atsui-font.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cairo-atsui-font.c 16 Dec 2005 11:02:35 -0000 1.26
+++ cairo-atsui-font.c 10 Jan 2006 13:29:00 -0000 1.27
@@ -38,6 +38,7 @@
#include "cairo-atsui.h"
#include "cairoint.h"
#include "cairo.h"
+#include "cairo-quartz-private.h"
typedef struct _cairo_atsui_font_face cairo_atsui_font_face_t;
typedef struct _cairo_atsui_font cairo_atsui_font_t;
@@ -606,13 +607,43 @@
CGContextSetRGBFillColor(myBitmapContext, 0.0f, 0.0f, 0.0f, 0.0f);
}
+ if (_cairo_surface_is_quartz (generic_surface)) {
+ cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *)generic_surface;
+ if (surface->clip_region) {
+ pixman_box16_t *boxes = pixman_region_rects (surface->clip_region);
+ int num_boxes = pixman_region_num_rects (surface->clip_region);
+ CGRect stack_rects[10];
+ CGRect *rects;
+ int i;
+
+ if (num_boxes > 10)
+ rects = malloc (sizeof (CGRect) * num_boxes);
+ else
+ rects = stack_rects;
+
+ for (i = 0; i < num_boxes; i++) {
+ rects[i].origin.x = boxes[i].x1;
+ rects[i].origin.y = boxes[i].y1;
+ rects[i].size.width = boxes[i].x2 - boxes[i].x1;
+ rects[i].size.height = boxes[i].y2 - boxes[i].y1;
+ }
+
+ CGContextClipToRects (myBitmapContext, rects, num_boxes);
+
+ if (rects != stack_rects)
+ free(rects);
+ }
+ } else {
+ /* XXX: Need to get the text clipped */
+ }
+
// TODO - bold and italic text
//
// We could draw the text using ATSUI and get bold, italics
// etc. for free, but ATSUI does a lot of text layout work
// that we don't really need...
-
+
for (i = 0; i < num_glyphs; i++) {
CGGlyph theGlyph = glyphs[i].index;
--- NEW FILE: cairo-quartz-private.h ---
(This appears to be a binary file; contents omitted.)
Index: cairo-quartz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-quartz-surface.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cairo-quartz-surface.c 14 Nov 2005 20:57:32 -0000 1.22
+++ cairo-quartz-surface.c 10 Jan 2006 13:29:00 -0000 1.23
@@ -35,22 +35,7 @@
#include "cairoint.h"
#include "cairo-private.h"
-#include "cairo-quartz.h"
-
-typedef struct cairo_quartz_surface {
- cairo_surface_t base;
-
- CGContextRef context;
-
- cairo_bool_t flipped;
-
- int width;
- int height;
-
- cairo_image_surface_t *image;
-
- CGImageRef cgImage;
-} cairo_quartz_surface_t;
+#include "cairo-quartz-private.h"
static void
ImageDataReleaseFunc(void *info, const void *data, size_t size)
@@ -71,6 +56,9 @@
if (surface->cgImage)
CGImageRelease(surface->cgImage);
+ if (surface->clip_region)
+ pixman_region_destroy (surface->clip_region);
+
return CAIRO_STATUS_SUCCESS;
}
@@ -199,6 +187,16 @@
unsigned int serial;
serial = _cairo_surface_allocate_clip_serial (&surface->image->base);
+
+ if (surface->clip_region)
+ pixman_region_destroy (surface->clip_region);
+
+ if (region) {
+ surface->clip_region = pixman_region_create ();
+ pixman_region_copy (surface->clip_region, region);
+ } else
+ surface->clip_region = NULL;
+
return _cairo_surface_set_clip_region(&surface->image->base,
region, serial);
}
@@ -256,6 +254,7 @@
surface->height = height;
surface->image = NULL;
surface->cgImage = NULL;
+ surface->clip_region = NULL;
surface->flipped = flipped;
// Set up the image surface which Cairo draws into and we blit to & from.
@@ -264,3 +263,9 @@
return (cairo_surface_t *) surface;
}
+
+int
+_cairo_surface_is_quartz (cairo_surface_t *surface)
+{
+ return surface->backend == &cairo_quartz_surface_backend;
+}
More information about the cairo-commit
mailing list