2009-06-14 20:43:05 +01:00
|
|
|
/* Cairo - a vector graphics library with display and print output
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2009 Chris Wilson
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2010-04-27 10:17:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
2009-06-14 20:43:05 +01:00
|
|
|
* 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 Chris Wilson.
|
|
|
|
|
*/
|
|
|
|
|
|
Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)
In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.
Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:
ppc:
Speedups
========
image-rgba evolution-20090607-0 1026085.22 0.18% -> 672972.07 0.77%: 1.52x speedup
▌
image-rgba evolution-20090618-0 680579.98 0.12% -> 573237.66 0.16%: 1.19x speedup
▎
image-rgba swfdec-fill-rate-4xaa-0 460296.92 0.36% -> 407464.63 0.42%: 1.13x speedup
▏
image-rgba swfdec-fill-rate-2xaa-0 128431.95 0.47% -> 115051.86 0.42%: 1.12x speedup
▏
Slowdowns
=========
image-rgba firefox-periodic-table-0 56837.61 0.78% -> 66055.17 3.20%: 1.09x slowdown
▏
2009-07-23 15:32:13 +01:00
|
|
|
#include "cairo-boilerplate-private.h"
|
2009-06-14 20:43:05 +01:00
|
|
|
|
|
|
|
|
#include <cairo-qt.h>
|
|
|
|
|
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
|
|
typedef struct _qt_closure {
|
|
|
|
|
Display *dpy;
|
|
|
|
|
QApplication *app;
|
|
|
|
|
} qt_closure_t;
|
|
|
|
|
|
2009-07-04 21:43:27 +01:00
|
|
|
static void
|
2009-06-14 20:43:05 +01:00
|
|
|
_cairo_boilerplate_qt_cleanup (void *closure)
|
|
|
|
|
{
|
|
|
|
|
qt_closure_t *qtc = (qt_closure_t *) closure;
|
|
|
|
|
|
|
|
|
|
delete qtc->app;
|
|
|
|
|
XCloseDisplay (qtc->dpy);
|
|
|
|
|
free (qtc);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-04 21:43:27 +01:00
|
|
|
static cairo_surface_t *
|
2010-06-24 14:59:18 +03:00
|
|
|
_cairo_boilerplate_qt_create_surface (const char *name,
|
|
|
|
|
cairo_content_t content,
|
|
|
|
|
double width,
|
|
|
|
|
double height,
|
|
|
|
|
double max_width,
|
|
|
|
|
double max_height,
|
|
|
|
|
cairo_boilerplate_mode_t mode,
|
|
|
|
|
void **closure)
|
2009-06-14 20:43:05 +01:00
|
|
|
{
|
|
|
|
|
qt_closure_t *qtc;
|
|
|
|
|
|
|
|
|
|
qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t));
|
|
|
|
|
qtc->dpy = XOpenDisplay (NULL);
|
|
|
|
|
if (qtc->dpy == NULL) {
|
|
|
|
|
free (qtc);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
|
|
|
|
|
XSynchronize (qtc->dpy, True);
|
|
|
|
|
|
|
|
|
|
qtc->app = new QApplication (qtc->dpy);
|
|
|
|
|
*closure = qtc;
|
|
|
|
|
return cairo_qt_surface_create_with_qpixmap (content, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-04 21:43:27 +01:00
|
|
|
static void
|
2009-06-14 20:43:05 +01:00
|
|
|
_cairo_boilerplate_qt_synchronize (void *closure)
|
|
|
|
|
{
|
|
|
|
|
qt_closure_t *qtc = (qt_closure_t *) closure;
|
|
|
|
|
|
|
|
|
|
qtc->app->flush (); /* not sure if this is sufficient */
|
|
|
|
|
}
|
2009-07-04 21:43:27 +01:00
|
|
|
|
|
|
|
|
static const cairo_boilerplate_target_t targets[] = {
|
|
|
|
|
{
|
|
|
|
|
"qt", "qt", NULL, NULL,
|
|
|
|
|
CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0,
|
2010-01-18 23:40:00 +00:00
|
|
|
"cairo_qt_surface_create",
|
2009-07-04 21:43:27 +01:00
|
|
|
_cairo_boilerplate_qt_create_surface,
|
2012-02-12 01:34:34 -05:00
|
|
|
NULL, NULL, NULL,
|
2009-07-04 21:43:27 +01:00
|
|
|
_cairo_boilerplate_get_image_surface,
|
|
|
|
|
cairo_surface_write_to_png,
|
|
|
|
|
_cairo_boilerplate_qt_cleanup
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"qt", "qt", NULL, NULL,
|
|
|
|
|
CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0,
|
2010-01-18 23:40:00 +00:00
|
|
|
"cairo_qt_surface_create",
|
2009-07-04 21:43:27 +01:00
|
|
|
_cairo_boilerplate_qt_create_surface,
|
2012-02-12 01:34:34 -05:00
|
|
|
NULL, NULL, NULL,
|
2009-07-04 21:43:27 +01:00
|
|
|
_cairo_boilerplate_get_image_surface,
|
|
|
|
|
cairo_surface_write_to_png,
|
|
|
|
|
_cairo_boilerplate_qt_cleanup
|
|
|
|
|
},
|
|
|
|
|
};
|
Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)
In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.
Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:
ppc:
Speedups
========
image-rgba evolution-20090607-0 1026085.22 0.18% -> 672972.07 0.77%: 1.52x speedup
▌
image-rgba evolution-20090618-0 680579.98 0.12% -> 573237.66 0.16%: 1.19x speedup
▎
image-rgba swfdec-fill-rate-4xaa-0 460296.92 0.36% -> 407464.63 0.42%: 1.13x speedup
▏
image-rgba swfdec-fill-rate-2xaa-0 128431.95 0.47% -> 115051.86 0.42%: 1.12x speedup
▏
Slowdowns
=========
image-rgba firefox-periodic-table-0 56837.61 0.78% -> 66055.17 3.20%: 1.09x slowdown
▏
2009-07-23 15:32:13 +01:00
|
|
|
extern "C" {
|
2009-07-04 21:43:27 +01:00
|
|
|
CAIRO_BOILERPLATE (qt, targets)
|
Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)
In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.
Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:
ppc:
Speedups
========
image-rgba evolution-20090607-0 1026085.22 0.18% -> 672972.07 0.77%: 1.52x speedup
▌
image-rgba evolution-20090618-0 680579.98 0.12% -> 573237.66 0.16%: 1.19x speedup
▎
image-rgba swfdec-fill-rate-4xaa-0 460296.92 0.36% -> 407464.63 0.42%: 1.13x speedup
▏
image-rgba swfdec-fill-rate-2xaa-0 128431.95 0.47% -> 115051.86 0.42%: 1.12x speedup
▏
Slowdowns
=========
image-rgba firefox-periodic-table-0 56837.61 0.78% -> 66055.17 3.20%: 1.09x slowdown
▏
2009-07-23 15:32:13 +01:00
|
|
|
}
|