2007-01-09 14:27:32 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2006 Jeff Muizelaar <jeff@infidigm.net>
|
|
|
|
|
* Copyright © 2006 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
* Authors: Jeff Muizelaar <jeff@infidigm.net>
|
|
|
|
|
* Carl Worth <cworth@cworth.org>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "cairo-perf.h"
|
|
|
|
|
|
2011-08-31 17:55:07 +02:00
|
|
|
static cairo_time_t
|
2009-08-03 22:23:19 +01:00
|
|
|
do_unaligned_clip (cairo_t *cr, int width, int height, int loops)
|
2007-01-09 14:27:32 -08:00
|
|
|
{
|
|
|
|
|
cairo_perf_timer_start ();
|
2008-10-28 09:11:23 +00:00
|
|
|
|
2009-08-03 22:23:19 +01:00
|
|
|
while (loops--) {
|
2009-08-16 09:57:07 +01:00
|
|
|
cairo_save (cr);
|
|
|
|
|
|
2009-08-03 22:23:19 +01:00
|
|
|
/* First a triangular clip that obviously isn't along device-pixel
|
|
|
|
|
* boundaries. */
|
|
|
|
|
cairo_move_to (cr, 50, 50);
|
|
|
|
|
cairo_line_to (cr, 50, 90);
|
|
|
|
|
cairo_line_to (cr, 90, 90);
|
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
cairo_clip (cr);
|
2007-01-09 14:27:32 -08:00
|
|
|
|
2009-08-03 22:23:19 +01:00
|
|
|
/* Then a rectangular clip that would be but for the non-integer
|
|
|
|
|
* scaling. */
|
|
|
|
|
cairo_scale (cr, 1.1, 1.1);
|
|
|
|
|
cairo_rectangle (cr, 55, 55, 35, 35);
|
|
|
|
|
cairo_clip (cr);
|
2008-10-28 09:11:23 +00:00
|
|
|
|
2009-08-03 22:23:19 +01:00
|
|
|
/* And paint something to force the clip to be evaluated. */
|
|
|
|
|
cairo_paint (cr);
|
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
|
|
|
|
2009-08-16 09:57:07 +01:00
|
|
|
cairo_restore (cr);
|
2009-08-03 22:23:19 +01:00
|
|
|
}
|
2007-01-09 14:27:32 -08:00
|
|
|
cairo_perf_timer_stop ();
|
|
|
|
|
|
|
|
|
|
return cairo_perf_timer_elapsed ();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-30 17:28:21 +01:00
|
|
|
cairo_bool_t
|
|
|
|
|
unaligned_clip_enabled (cairo_perf_t *perf)
|
|
|
|
|
{
|
|
|
|
|
return cairo_perf_can_run (perf, "unaligned-clip", NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-09 14:27:32 -08:00
|
|
|
void
|
|
|
|
|
unaligned_clip (cairo_perf_t *perf, cairo_t *cr, int width, int height)
|
|
|
|
|
{
|
2010-03-30 04:10:28 +01:00
|
|
|
cairo_perf_run (perf, "unaligned-clip", do_unaligned_clip, NULL);
|
2007-01-09 14:27:32 -08:00
|
|
|
}
|