[cairo-bugs] [Bug 17971] Extreme slowdown for manual convolutions in most vector backends.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Oct 12 07:52:44 PDT 2008


http://bugs.freedesktop.org/show_bug.cgi?id=17971


Adrian Johnson <ajohnson at redneon.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|ajohnson at redneon.com        |cworth at cworth.org
          Component|pdf backend                 |general




--- Comment #1 from Adrian Johnson <ajohnson at redneon.com>  2008-10-12 07:52:30 PST ---
In this code you are doing two calls to cairo_paint_with_alpha() then
using the output as the source pattern to do another two calls to
cairo_paint_with_alpha(). This is repeated for each iteration.

When the number of blurs is 1 the following operations are performed:
  Pattern A is a triangle fill
  Pattern B is pattern A painted twice
  Pattern C is pattern B painted twice
  paint C onto the target surface

Due to the use of operators not supported by most vector backends
fallback images will be used which requires
_cairo_meta_surface_acquire_source_image() to be called. In the image backend
acquire_source is called 3 times. In the
vector backends acquire_source is called 7 times.

When the number of blurs is 2 the following operations are performed:
  Pattern A is a triangle fill
  Pattern B is pattern A painted twice
  Pattern C is pattern B painted twice
  Pattern D is pattern C painted twice
  paint D onto the target surface

In the image backend acquire_source is called 4 times. In the vector
backends _cairo_meta_surface_acquire_source_image() is called 31
times.

The problem with the vector backends is a result of the way all the
operations are recorded then replayed. The first problem is we do not
yet have copy-on-write in the meta surface. Every time the same meta
surface pattern is painted a copy of the source meta surface is made.

The second problem is every time the same pattern is painted,
_cairo_meta_surface_acquire_source_image() replays the meta surface to
an image surface. All patterns used by this meta surface are also
replayed to the image surface.

So for num blurs = 2, painting pattern D on the target will result in
the following calls to acquire_source:

meta surface     num calls to acquire source
--------------------------------------------
Pattern D                     1
Pattern C                     2
Pattern B                     4
Pattern A                     8
The group with the triangle  16
                         ---------
                         total  31

Fixing this requires two things:

- An implementation of copy-on-write for the meta-surface so that we
  know when we are re-using the same pattern.

- Caching the image created by _cairo_meta_surface_acquire_source_image()
  instead of replaying the meta surface to an image every time
  _cairo_meta_surface_acquire_source_image() is called.

The reason the slow down does not occur in 1.2.4 is that in 1.2.4 the
PDF surface does not implement _create_similar. This will cause
cairo_surface_create_similar() to return an image surface instead of a
meta surface.


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the cairo-bugs mailing list