[cairo-commit] perf/cairo-perf-trace.c src/cairo-qt-surface.cpp
Chris Wilson
ickle at kemper.freedesktop.org
Mon Aug 10 13:31:24 PDT 2009
perf/cairo-perf-trace.c | 2 -
src/cairo-qt-surface.cpp | 63 +++++++++++++++++++++++++++++++----------------
2 files changed, 43 insertions(+), 22 deletions(-)
New commits:
commit d1b8e260d43c7dee71244f26d50d8b2e49e9b6e0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon Aug 10 21:29:13 2009 +0100
[qt] Fix compilation
Enabling 'FAST CLIP' appears to trigger an infinite loop so disable.
Enabling 'FAST FILL' has limited effect on performance, so disable whilst
the basic QT surface is improved.
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index a7bfbba..c6f7526 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -105,7 +105,7 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1,1,2)
case CAIRO_SURFACE_TYPE_OS2:
#endif
-#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1,9,3)
+#if CAIRO_HAS_QT_SURFACE
case CAIRO_SURFACE_TYPE_QT:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,3)
diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index a0d573d..56f5c19 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -68,7 +68,9 @@
#include <sys/time.h>
-#define ENABLE_FAST_FILL 1 /* Enable workaround slow regional Qt paths */
+/* Enable workaround slow regional Qt paths */
+#define ENABLE_FAST_FILL 0
+#define ENABLE_FAST_CLIP 0
#if 0
#define D(x) x
@@ -710,17 +712,29 @@ _cairo_qt_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clipper,
cairo_qt_surface_t *qs = cairo_container_of (clipper,
cairo_qt_surface_t,
clipper);
- QPainterPath qpath;
- cairo_status_t status;
- // XXX Antialiasing is ignored
- status = _cairo_quartz_cairo_path_to_qpainterpath (path,
- &qpath,
- fill_rule);
- if (unlikely (status))
- return status;
+ if (path == NULL) {
+ if (qs->pixmap || qs->image) {
+ // we own p
+ qs->p->setClipping (false);
+ } else {
+ qs->p->restore ();
+ qs->p->save ();
+ }
+ } else {
+ QPainterPath qpath;
+ cairo_status_t status;
+
+ // XXX Antialiasing is ignored
+ status = _cairo_quartz_cairo_path_to_qpainterpath (path,
+ &qpath,
+ fill_rule);
+ if (unlikely (status))
+ return status;
+
+ qs->p->setClipPath (qpath, Qt::IntersectClip);
+ }
- qs->p->setClipPath (qpath, Qt::IntersectClip);
return CAIRO_STATUS_SUCCESS;
}
@@ -759,6 +773,7 @@ static cairo_int_status_t
_cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
cairo_clip_t *clip)
{
+ cairo_int_status_t status;
D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", abstract_surface, path ? "(path)" : "(clear)"));
@@ -776,6 +791,7 @@ _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
return CAIRO_INT_STATUS_SUCCESS;
}
+#if ENABLE_FAST_CLIP
// Qt will implicitly enable clipping, and will use ReplaceClip
// instead of IntersectClip if clipping was disabled before
@@ -787,7 +803,6 @@ _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
cairo_region_t *clip_region = NULL;
- cairo_int_status_t status;
status = _cairo_clip_get_region (clip, &clip_region);
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
// We weren't able to extract a region from the traps.
@@ -798,6 +813,10 @@ _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
_cairo_qt_surface_set_clip_region (qs, clip_region);
status = CAIRO_INT_STATUS_SUCCESS;
}
+#else
+ status = (cairo_int_status_t)
+ _cairo_surface_clipper_set_clip (&qs->clipper, clip);
+#endif
return status;
}
@@ -1300,8 +1319,8 @@ _cairo_qt_surface_fill (void *abstract_surface,
//qs->p->setRenderHint (QPainter::Antialiasing, antialias == CAIRO_ANTIALIAS_NONE ? false : true);
qs->p->setRenderHint (QPainter::SmoothPixmapTransform, source->filter != CAIRO_FILTER_FAST);
- if (! _cairo_qt_fast_fill (qs, source,
- path, fill_rule, tolerance, antialias))
+ if (! _cairo_qt_fast_fill (qs, source,
+ path, fill_rule, tolerance, antialias))
{
QPainterPath qpath;
cairo_status_t status;
@@ -1449,10 +1468,6 @@ _cairo_qt_surface_mask (void *abstract_surface,
return CAIRO_INT_STATUS_UNSUPPORTED;
}
-/**
- ** XXX this will go away! it's only implemented for now so that we
- ** can get some text without show_glyphs being available.
- **/
static cairo_int_status_t
_cairo_qt_surface_composite (cairo_operator_t op,
const cairo_pattern_t *pattern,
@@ -1684,6 +1699,9 @@ cairo_qt_surface_create (QPainter *painter)
&cairo_qt_surface_backend,
CAIRO_CONTENT_COLOR_ALPHA);
+ _cairo_surface_clipper_init (&qs->clipper,
+ _cairo_qt_surface_clipper_intersect_clip_path);
+
qs->p = painter;
if (qs->p->paintEngine())
qs->supports_porter_duff = qs->p->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
@@ -1695,10 +1713,6 @@ cairo_qt_surface_create (QPainter *painter)
qs->window = painter->window();
- _cairo_surface_clipper_init (&qs->clipper,
- _cairo_qt_surface_clipper_intersect_clip_path);
-
-
#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
#endif
@@ -1727,6 +1741,10 @@ cairo_qt_surface_create_with_qimage (cairo_format_t format,
&cairo_qt_surface_backend,
_cairo_content_from_format (format));
+ _cairo_surface_clipper_init (&qs->clipper,
+ _cairo_qt_surface_clipper_intersect_clip_path);
+
+
QImage *image = new QImage (width, height,
_qimage_format_from_cairo_format (format));
@@ -1781,6 +1799,9 @@ cairo_qt_surface_create_with_qpixmap (cairo_content_t content,
_cairo_surface_init (&qs->base, &cairo_qt_surface_backend, content);
+ _cairo_surface_clipper_init (&qs->clipper,
+ _cairo_qt_surface_clipper_intersect_clip_path);
+
qs->pixmap = pixmap;
if (!pixmap->isNull()) {
More information about the cairo-commit
mailing list