Commit graph

7811 commits

Author SHA1 Message Date
Chris Wilson
a04873c077 qt: Trivial compile fix for boilerplate. 2010-01-22 23:01:51 +00:00
Chris Wilson
0f09349dd8 gl: Exercise Window destinations with boilerplate
Add a gl-window boilerplate target to exercise using GL to render to a
visible Drawable -- for instance, a window has a different coordinate
system to a framebuffer...
2010-01-22 23:01:51 +00:00
Chris Wilson
ccea7fd7c1 gl: Port to cairo_device_t 2010-01-22 23:01:50 +00:00
Chris Wilson
3acd520c9d xml: Port to cairo_device_t 2010-01-22 23:01:50 +00:00
Chris Wilson
49ab86772a script: Port cairo_script_context_t to cairo_device_t
Use the unifying cairo_device_t for cairo_script_context_t and replace.
2010-01-22 23:01:50 +00:00
Chris Wilson
f617d5fc98 Add cairo_device_t
The device is a generic method for accessing the underlying interface
with the native graphics subsystem, typically the X connection or
perhaps the GL context. By exposing a cairo_device_t on a surface and
its various methods we enable finer control over interoperability with
external interactions of the device by applications. The use case in
mind is, for example, a multi-threaded gstreamer which needs to serialise
its own direct access to the device along with Cairo's across many
threads.

Secondly, the cairo_device_t is a unifying API for the mismash of
backend specific methods for controlling creation of surfaces with
explicit devices and a convenient hook for debugging and introspection.

The principal components of the API are the memory management of:

  cairo_device_reference(),
  cairo_device_finish() and
  cairo_device_destroy();

along with a pair of routines for serialising interaction:

  cairo_device_acquire() and
  cairo_device_release()

and a method to flush any outstanding accesses:

  cairo_device_flush().

The device for a particular surface may be retrieved using:

  cairo_surface_get_device().

The device returned is owned by the surface.
2010-01-22 23:01:50 +00:00
Chris Wilson
82f8aa548d Recursive mutex.
Implement a recursive mutex which will be needed for cairo_device_t.
In particular only pthreads by default is a non-recursive mutex (to my
knowledge) - both win32 critical sections and mutexes on Quartz are
recursive.
2010-01-22 23:01:50 +00:00
Chris Wilson
d2f251f84b configure: Globally define AC_GNU_SOURCE
We were using _GNU_SOURCE throughout the codebase, so simply define it
once during configure. This is the easiest method to enable recursive
mutexes using pthreads, as required in a pending patch.
2010-01-22 23:01:50 +00:00
Chris Wilson
934d0d0d65 Real zero-copy cow snapshotting
The first iteration of COW snapshotting always made an initial copy when
the snapshot was requested (and reused that copy until the surface was
modified). However, in a few circumstances we can avoid even that copy
so long as the surface is still alive and unmodified between the
snapshotting and its use. In order to do so, we need a new proxy surface
that can automatically perform the copy if the target should disappear
prior to use.
2010-01-22 23:01:50 +00:00
Chris Wilson
6b3e19aa43 Remove content matching from snapshot lookup.
This was never used, so remove the complexity from the interface.
2010-01-22 23:01:50 +00:00
Chris Wilson
dc8290814c Add subsurface.
A subsurface is a region of another surface that may be used either to
restrict the writable area of a context or the readable extents of a
source. Whilst writing, access to the exterior of the subsurface is
prevented via clipping and when used as a source reads from the exterior
of the subsurface are governed via the extend mechanism of the pattern.
2010-01-22 23:01:50 +00:00
Chris Wilson
b8eacbfae1 Add surface-offset internal API.
This is a simplified version of the wrapping surface where the target
surface is just a subsurface onto which we wish to draw the current
operation. In particular this is useful for the subsurface API as well
as fallbacks.
2010-01-22 23:01:50 +00:00
Chris Wilson
f2c32d0183 Unify the two freed object pools
Discard some duplicate code and shared a single freed object pointer
pool between the pattern and clip.
2010-01-22 23:01:50 +00:00
Chris Wilson
cfd204824f Constify stroke style and matrices.
As a simple step to ensure that we do not inadvertently modify (or at least
generate compiler warns if we try) user data, mark the incoming style
and matrices as constant.
2010-01-22 23:01:49 +00:00
Benjamin Otte
3e17c559b0 [test] Add pthread-same-source test
Multiple threads render using the same source surface, but with
different extend and filter.
2010-01-22 23:01:49 +00:00
Benjamin Otte
30a12f802f [test] Add a simple multithreading test 2010-01-22 23:01:49 +00:00
Benjamin Otte
038829eb84 [test] Add new test checking is_clear is handled properly
This test does various operations with a clear source surface with
various content types.
The idea is to make sure optimizations done when surface->is_clear ==
TRUE only happen in the proper cases.
2010-01-22 23:01:49 +00:00
Chris Wilson
bf7fb4e0e0 script: Handle cache allocation failure more gracefully
Instead of bailing out if we cannot store the glyph cache on the font,
simply do not store the glyph cache on the font...
2010-01-22 23:01:49 +00:00
Chris Wilson
2b312806f1 script: Free the correct pattern after failure.
The error path attempted to free the resolved pattern which it had just
discovered was NULL and not the locally allocated pattern...
2010-01-22 23:01:49 +00:00
Chris Wilson
bc2d0ad114 script: Permit surface operations on the context
By implicitly reference the target of the context instead, i.e.
this reduces the use of:

  /target get (example.png) write-to-png pop

as a common idiom where the context is kept on the stack and the surface
forgotten.
2010-01-22 23:01:49 +00:00
Chris Wilson
411c09eed7 perf: Enable a surface cache for perf-trace
Real applications that control their Drawable externally to Cairo are
'disadvantaged' by cairo-perf-trace when it creates a similar surface
for each new instance of the same Drawable. The difficulty in
maintaining one perf surface for every application surface is that the
traces do not track lifetimes for the application surfaces, so we would
just accumulate stale surfaces. The surface cache takes a different
approach and returns the same surface for each active Drawable, and
maintains a hold-over of the MRU 16 surfaces. This achieves 60-80% hit
rate with firefox, which is probably as good as can be expected.
Obviously for double-buffered applications we only every draw to freshly
created surfaces (and Gtk+ bypasses cairo to do the final copy -- the
ideal application would just use a push-group for double buffering, in
which case we would capture and replay the entire expose event).

To enable use of the surface cache whilst replaying use -c:

  ./cairo-perf-trace -c firefox-talos-gfx
2010-01-22 23:01:46 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00
Chris Wilson
558f950170 surface-wrapper: Avoid copying patterns and clips unless transformed.
An older variant of the fixes for moving the device transformation out
of the surface layer, but languished in a side branch. The only benefit
of this patch is that it avoids the copy where possible.
2010-01-22 22:30:43 +00:00
Chris Wilson
8f69481722 gitignore: refresh
Add forgotten local targets to .gitignore
2010-01-22 22:30:43 +00:00
Eric Anholt
5914e99572 [gl] Cache a temporary glyph compositing mask for reuse later.
Cuts firefox-talos-gfx time from 56 seconds to 43 seconds.
2010-01-22 09:21:36 -08:00
Eric Anholt
1bf0f64ee7 [gl] Composite component-alpha glyphs directly instead of through a mask.
Cuts gnome-terminal-vim time from 58 seconds to 20.
2010-01-22 09:00:29 -08:00
Eric Anholt
12d521df8a [gl] Use GL_RGBA textures even for CAIRO_CONTENT_COLOR.
When the texture is GL_RGB, GL_CLAMP_TO_BORDER (EXTEND_NONE) fills the
border color alpha channel with 1, when the whole reason we were using
the border color was to get a color and alpha of 0.  We're forced to
use GL_RGBA textures and do extra work to fill in the alpha channel of
them to 1 to get cairo's desired behavior.

This fixes a failure in rotate-image-surface-paint and 4 other
testcases.  No performance difference in firefox-talos-gfx.
2010-01-21 13:19:17 -08:00
Eric Anholt
e316cb9db5 [gl] Add support for component-alpha glyph rendering.
This is done using a mask and the two-pass trick I did for EXA.  Fixes
text-antialias-subpixel.
2010-01-21 12:43:20 -08:00
Eric Anholt
ceeb7e7e70 [gl] Use the UNSUPPORTED() macro in more places for fallback debugging. 2010-01-20 11:23:20 -08:00
Andrea Canciani
5d9e2fd84b [quartz] Leftbehind change from a39075c88f
This commit completes the change in a39075c88f.
It removes unused variables and corrects the extents rect computation.
2010-01-15 16:30:07 +01:00
Chris Wilson
6950b233e4 qt: Make flush() robust.
Hanno Meyer-Thurow reported in

  http://bugs.freedesktop.org/show_bug.cgi?id=26063
  [PATCH] various fixes to cairo-qt

a few issues related to _cairo_qt_surface_flush() where firefox was
crashing after being built to use cairo-qt.

This is an amalgam of those patches that hopefully address the issue.
2010-01-15 14:27:58 +00:00
Chris Wilson
4e315d8472 pattern: Premultiply color-stop when converting to solid
Fixes: test/linear-uniform
       https://bugzilla.mozilla.org/show_bug.cgi?id=539165
       Bug 539165 - gradients with a single stop do not have their color
                    multiplied by the alpha.

As reported by Jeff Muizelaar, we regressed in 2d790daa as the
color-stops are not premultiplied and so could not be treated as an
ordinary cairo_color_t. Instead we have to create a intermediate
cairo_color_t from the original values in order for the
premultiplication to be performed.
2010-01-15 12:25:53 +00:00
Chris Wilson
f40560a9bb test: Add linear-uniform
Jeff reported a regression found by Mozilla whereby a uniform gradient
was not being premultiplied on conversion to a solid pattern.

  https://bugzilla.mozilla.org/show_bug.cgi?id=539165
  [Bug 539165] gradients with a single stop do not have their color
               multiplied by the alpha.
2010-01-15 12:25:53 +00:00
Chris Wilson
e22c02dbae test: Add degenerate-arcs
A simple test to ensure that using degenerate-arcs such as when drawing
a rounded rectangle with radii=0 construct a proper path.
2010-01-15 12:25:53 +00:00
Andrea Canciani
a39075c88f [quartz] Fix generic masking
Masking with unbounded operators was broken because an incorrect
transformation was applied to inverted mask used for the fixup.
2010-01-15 11:04:28 +01:00
Andrea Canciani
27701ed844 [quartz] Approximate dense dashing patterns
Quartz doesn't try to approximate dash pattern even if they are well
beyond suface sampling frequency. Approximating dash patterns when their
density is too high avoids looping indefinitely in these degenerate cases.
2010-01-15 11:04:27 +01:00
Andrea Canciani
ad7ab00c10 [quartz] Improve A8 and A1 support
Use A8 images as alpha-only masks intread of greyscale images.
Add support to A1 images (they were ignored before).
2010-01-15 11:04:27 +01:00
Adrian Johnson
f3b3a5c43f Fix bug in _cairo_ft_index_to_ucs4
Previously it would miss the first character causing the space glyph to
return 0x00A0 instead of 0x0020.
2010-01-15 07:47:30 +10:30
Eric Anholt
e26e2c8cc4 [gl] Fix the color bits of CAIRO_CONTENT_ALPHA surface patterns to be 0.
Fixes surface-pattern-operator and alpha-similar.
2010-01-14 10:07:46 -08:00
Eric Anholt
520945603c [gl] Remove the special-casing of acquiring a pattern surface.
_cairo_pattern_acquire_surface() should do fine at it, and matches
what cairo-drm-i915 does.
2010-01-14 10:00:37 -08:00
Eric Anholt
dbf9faf823 [gl] Use GLSL for fill_rectangles when available.
Ultimately, we want all of our paths to use shaders when they are
exposed -- it brings us closer to GL 3.0 compatibility and it should
reduce the work that GL drivers have to do per operation to compute
the required hardware state.
2010-01-14 09:28:58 -08:00
Eric Anholt
57341cf5ac [gl] Use ADD instead of SOURCE when making a mask for overlapping glyphs.
The whole point of making the mask was to avoid overwriting one glyph
with the data from another.  Whoops.

Fixes ft-show-glyphs-positioning, text-rotate, overlapping-glyphs,
clip-text.
2010-01-13 14:28:23 -08:00
Eric Anholt
6e0a63102e [gl] Clear the current_target cache when binding a framebuffer in creation.
Failing to do so meant that we might not re-bind the framebuffer to
the correct one if we didn't follow up surface creation with drawing
to it.

Fixes many testcases.  Thanks to T. Zachary Laine for tracking down
that the current_target was the source of these issues.
2010-01-13 14:28:22 -08:00
T. Zachary Laine
ad0f4bee19 [gl] Clear the is_clear flag on the temporary glyph mask we create.
Normally is_clear is cleared by the caller of one of the 5 basic
entrypoints, but in this temporary surface usage nobody else can do it
for us.

Fixes ft-show-glyphs-table, user-font-rescale, and select-font-face.
2010-01-13 14:28:22 -08:00
T. Zachary Laine
384e50d858 [gl] Removed repeated lines of source
The two removed lines are redundant with code a few lines above them.
2010-01-13 14:28:22 -08:00
Eric Anholt
515ccb63a6 [gl] Fix the glyph cache full flush to really try again.
Previously, the initial error handling would dump through to software
fallback instead of retrying in the following code.
2010-01-13 14:28:22 -08:00
Chris Wilson
4aae4bfa8f test: Fix typo in path-stroke-twice reference image
Sigh. I committed the reference image with the name
path-stroke-twice-ref.png.
2010-01-12 17:11:15 +00:00
Chris Wilson
74ea4c9080 path: Do not remove anti-parallel line segments in case we are stroking
Bug 26010 - cairo_line_to optimizes away path segments
  http://bugs.freedesktop.org/show_bug.cgi?id=26010

As exercised by path-stroke-twice, we incorrectly optimise away a line
segment if the path doubled back upon itself. This is very reminiscent
of the optimisation bug for replacing curve-to with line-to.
2010-01-12 17:07:30 +00:00
Chris Wilson
a5dd5a6069 test: Add path-stroke-twice
Exercises a bug found by alois@astro.ch, whereby we inadvertently remove
a line segment when the path doubles back upon itself.

  Bug 26010 - cairo_line_to optimizes away path segments
  http://bugs.freedesktop.org/show_bug.cgi?id=26010
2010-01-12 17:07:28 +00:00
Chris Wilson
4204605813 type1: Destroy the output stream.
mpsuzuki spotted that the output stream for the subset was not being
destroyed on the error path - on closer inspection, it wasn't destroyed
along the normal path either and may never have been correctly
initialised to NULL on an earlier error.

Reported-by: mpsuzuki@hiroshima-u.ac.jp
2010-01-08 11:58:15 +00:00