mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-22 05:50:41 +02:00
Add cairo-quartz-private.h
If the destination surface is a quartz surface, get the clip mask from it. Added. Keep a copy of the clip mask around. (_cairo_surface_is_quartz): New function which determines if a given surface is a quartz surface.
This commit is contained in:
parent
d6cb82c372
commit
ae807fc936
5 changed files with 136 additions and 18 deletions
21
ChangeLog
21
ChangeLog
|
|
@ -1,3 +1,24 @@
|
|||
2006-01-10 Anders Carlsson <andersca@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.
|
||||
|
||||
2006-01-09 Carl Worth <cworth@cworth.org>
|
||||
|
||||
* test/cairo-test.h: Add printf format attribute to cairo_test_log.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ endif
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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 @@ _cairo_atsui_font_old_show_glyphs (void *abstract_font,
|
|||
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;
|
||||
|
||||
|
|
|
|||
61
src/cairo-quartz-private.h
Normal file
61
src/cairo-quartz-private.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2004 Calum Robinson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Calum Robinson
|
||||
*
|
||||
* Contributor(s):
|
||||
* Calum Robinson <calumr@mac.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_QUARTZ_PRIVATE_H
|
||||
#define CAIRO_QUARTZ_PRIVATE_H
|
||||
|
||||
#include <cairoint.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;
|
||||
pixman_region16_t *clip_region;
|
||||
|
||||
CGImageRef cgImage;
|
||||
} cairo_quartz_surface_t;
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_surface_is_quartz (cairo_surface_t *surface);
|
||||
|
||||
#endif /* CAIRO_QUARTZ_PRIVATE_H */
|
||||
|
|
@ -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 @@ _cairo_quartz_surface_finish(void *abstract_surface)
|
|||
if (surface->cgImage)
|
||||
CGImageRelease(surface->cgImage);
|
||||
|
||||
if (surface->clip_region)
|
||||
pixman_region_destroy (surface->clip_region);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -199,6 +187,16 @@ _cairo_quartz_surface_set_clip_region(void *abstract_surface,
|
|||
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 @@ cairo_surface_t *cairo_quartz_surface_create(CGContextRef context,
|
|||
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 @@ cairo_surface_t *cairo_quartz_surface_create(CGContextRef context,
|
|||
|
||||
return (cairo_surface_t *) surface;
|
||||
}
|
||||
|
||||
int
|
||||
_cairo_surface_is_quartz (cairo_surface_t *surface)
|
||||
{
|
||||
return surface->backend == &cairo_quartz_surface_backend;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue