Commit graph

5908 commits

Author SHA1 Message Date
Adrian Johnson
4fd20fe903 Remove HAS_FT_FONT from cairo-scaled-font-subsets-private.h
Should have been removed when the FT dependency was removed from type 1.
2011-07-20 08:37:03 +09:30
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Chris Wilson
f58ade7bac ps: Add HAS_FT_FONT guards for type1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Andrea Canciani
29d19c683b build: Fix compilation
83bfd85a13 and
2458120dee did not update some backends
properly, breaking their compilation.
2011-07-19 08:10:21 +02:00
Adrian Johnson
bf5892e2a6 Add win32 font backend functions for Type 1 subsetting
Native Type 1 font subsetting now works on Windows.
2011-07-18 22:31:34 +09:30
Adrian Johnson
068df654da type1-subset: Remove FT dependency part 6
Remove all remaining FT dependencies from the Type1 subsetting.
2011-07-18 22:26:43 +09:30
Adrian Johnson
895dfc628a type1-subset: Remove FT dependency part 5
Add a font backend function, load_type1_data, for loading Type 1 font
data. Replace the FT code for loading the font with a call
load_type1_data.
2011-07-18 22:23:21 +09:30
Adrian Johnson
a94644f177 type1-subset: Remove FT dependency part 4
Remove the dependency on FT for getting the font name.

The font name is obtained directly from the font.
2011-07-18 22:20:07 +09:30
Adrian Johnson
549acc4beb type1-subset: Remove FT dependency part 3
Remove the dependency on FT for getting the bbox and EM size.

The FontBBox and FontMatrix in the font file are parsed to obtain this data.
2011-07-18 22:16:07 +09:30
Adrian Johnson
b83fcf7d52 type1-subset: Remove FT dependency part 2
Remove the dependency on getting the number of glyphs in the font from
FT. The number of glyphs is instead obtained by counting the
charstrings.

Some fixed size malloced data is replaced with cairo_array_t so they
can be populated before we know the number of glyphs.
2011-07-18 22:12:06 +09:30
Adrian Johnson
d46df1dffb type1-subset: Remove FT dependency part 1
Remove cairo_type1_font_subset_get_glyph_names_and_widths().

The glyph names are read from the font file instead of via FT. The
charstrings are parsed to extract the glyph widths.

A new font backend function, index_to_glyph_name, has been added for
obtaining the glyph name for a given glyph index. This function is
supplied with the array of glyph names and a glyph index and is
required to return the array index of the glyph name corresponding to
the glyph index.

The reason for passing in the array of glyph names is that:

1) On windows there is no API for accessing glyph names so we will
use knowledge of how the glyphs in a Type 1 font are numbered to
perform name lookup.

2) We can also use knowledge of how FT assigns the glyph numbers in a
Type 1 font to optimize the name lookup.
2011-07-18 21:55:37 +09:30
Adrian Johnson
9fc3f1086c cff-subset: Fix /guillemotright SID encoding 2011-07-18 21:47:16 +09:30
Adrian Johnson
722e976044 png: fix type1 encoding bugs
glyphs outside of the StandardEncoding were not being displayed by acroread
2011-07-18 21:44:18 +09:30
Chris Wilson
2786864306 gl: Compile fix, missing include cairo-pattern-private.h
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-18 10:31:25 +01:00
Uli Schlachter
43b57d59a1 cairo-xcb: Drop some unused definitions/file
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-18 10:29:15 +02:00
Uli Schlachter
2e264e73df xlib-xcb: Fix an "extension leak"
When the xlib-xcb backend created a new cairo_device_t for a Display*, it called
XAddExtension to get a callback on XCloseDisplay(). However, when the last
surface using this device is destroyed, this extension isn't unregistered
because there is no API for this.

I noticed that gvim was quite slow after a while with xlib-xcb. The reason is
that xlib has a linked list of registered extensions that it has to walk through
for various callbacks. Since xlib-xcb caused lots of "dead" extension, this got
quite slow when there were about 20k entries in this list.

The fix is to make sure that the cairo_device_t isn't finished/destroyed when
the last surface using it is destroyed. For this, we keep an internal reference
which is only dropped when the device is finished. This happens when someone
explicitly calls cairo_device_finish or when our XCloseDisplay hook runs.

The same thing is done by cairo-xlib. I didn't port this over to xlib-xcb
because at that time I didn't understand why it was needed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-18 10:29:08 +02:00
Chris Wilson
54ae2e1619 xcb: Remove more bits of drm integration
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Chris Wilson
2458120dee pattern: Add observer hooks
In order for custom context to automatically track when a pattern is
modify after being set on the context (and before it is used in an
operator), we need for there to be a callback when the pattern is
modified.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Chris Wilson
83bfd85a13 Implement cairo_backend_t
Allow a backend to completely reimplement the Cairo API as it wants. The
goal is to pass operations to the native backends such as Quartz,
Direct2D, Qt, Skia, OpenVG with no overhead. And to permit complete
logging contexts, and whatever else the imagination holds. Perhaps to
experiment with double-paths?

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Chris Wilson
41b5469b95 image: Only discard the outer boxes
This is necessary as the callers do not propagate the clip extents after
finding the singular clip path. *sigh*

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-14 17:34:51 +01:00
Chris Wilson
ebe665867c scaled-font: Fix assertions for original font-face vs font-face
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-14 17:00:48 +01:00
Chris Wilson
507b8abcf6 Excise xcb-drm
The experiment was at best a pyrrhic victory. Whilst it did show that
you could successfully subvert cairo_xcb_surface_t and provide the
rendering locally faster (than the xlib driver at that time), any
performance benefits were lost in the synchronisation overheads and
server-side buffer allocation.

Once cairo-gl is mature, we need to look at how we can overcome these to
improve client-side rendering

In the meantime, cairo-xcb is no longer my playground for
experimentation and is shaping up to become a stable backend...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-14 12:46:26 +01:00
Chris Wilson
5d9da3decf Excise DRM-Xr
I've since incorporated (nearly) all the features from cairo-drm into
xf86-video-intel, making this experiment defunct.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-14 12:35:19 +01:00
Chris Wilson
cd4b2d843b scaled-font: Key the cache on the orignal font_face
We check the incoming scaled font using the original font fce, so we
need to also store it in the cache using the same face, and not the
resolved font_face (which will remain the same unless the fontconfig
configuration is updated).

Hides the quadratic behaviour of font retrieval in recent cairo-traces.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-13 12:35:51 +01:00
Chris Wilson
84c66589bc ft-font: If the pattern is already resolved, use it immediately
This skips an relatively expensive search for the a good match if the
pattern already contains a face or a filename.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-13 12:35:51 +01:00
Chris Wilson
af71e7717e png: Fix support of depth-30 images
Rename the variable depth to bpc to prevent future confusion.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-13 12:35:50 +01:00
Uli Schlachter
cc3e4c6ec9 Handle CAIRO_STATUS_DEVICE_FINISHED in switches
Fixes all warnings that looked like this:

warning: enumeration value 'CAIRO_STATUS_DEVICE_FINISHED' not handled in switch

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 11:19:49 +02:00
Uli Schlachter
508990af8d xcb: Don't use xcb surfaces as snapshots
Eventually someone might try to paint to the xcb surface again. However,
_cairo_surface_begin_modification doesn't like that:

cairo-surface.c:385: _cairo_surface_begin_modification: Assertion
`surface->snapshot_of == ((void *)0)' failed.

There was only a single place in the xcb backend where a cairo_xcb_surface_t
could be used as a snapshot, so the _cairo_surface_has_snapshot that checked for
such a surface can be removed, too.

This does *not* remove all snapshots from the xcb backend, but all the remaining
snapshots are instances of cairo_xcb_picture_t. These surfaces are only ever
created internally and thus can't be modified by users directly.

Fixes: xcb-snapshot-assert

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
4153de4689 xcb: Track cairo_xcb_picture_t surfaces
When e.g. using an image surface as the source for a xcb surface, a
cairo_xcb_picture_t is created and attached to that image surface as a snapshot.
This contains the Picture that was created on the X11 server.

However, as soon as the cairo_xcb_picture_t's cairo_xcb_screen_t is finished and
destroyed, this picture can't be used anymore. This commit now makes sure all
these Pictures are freed when the screen is finished.

This was found because my X server's memory usage grew quite large. Every time
the app was done drawing, it destroyed its last surface which also destroyed the
last reference to the cairo_xcb_screen_t. This meant that the existing Picture
snapshots couldn't be used anymore, but they were still kept around and used up
memory until there wasn't any free memory left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
e775db35d9 xcb: Move cairo_xcb_picture_t to cairo-xcb-private.h
The next commit will make cairo-xcb-screen.c use this struct and add new
members. Splitting off the move into its own commits makes that easier to
understand.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
5b9205cc52 xlib-xcb: Register a XCloseDisplay hook
This commits makes the xlib-xcb backend produce its own cairo_device_t. This
per-Display* device is used to manage the registration of a XCloseDisplay hook
via XAddExtension/XESetCloseDisplay in the same way that the xlib backend does
this. The device is necessary to see if we already registered an extension.

This fixes weird errors when running cairo-test-suite with -a -s. They were
caused because the backend didn't see the XCloseDisplay and the next
XOpenDisplay happened to create a xcb_connection_t with the same address as the
last display. This caused the xcb backend to assume lots of wrongness.

This commit makes use of _cairo_xlib_display_mutex which is otherwise compiled
in but not used anywhere when xlib-xcb is enabled.

Patch v2: Fixed the xcb_device == NULL case and made sure the xcb_device is only
finished on XCloseDisplay, not when all xlib-xcb surfaces are destroyed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Andrea Canciani
05a0b24ecb device: Fix documentation of device types
The documentation of device types incorrectly talks about surfaces and
lacks the new INVALID type.
2011-07-08 11:26:45 +02:00
Andrea Canciani
02a331de13 device: Define the CAIRO_DEVICE_TYPE_INVALID device type
Define a new device type to indicate that the device is not valid.
The -1 value is along the same line as CAIRO_FORMAT_INVALID (and is
likely to have the same issues).
2011-07-08 11:26:45 +02:00
Andrea Canciani
35d8d20635 device: Add CAIRO_STATUS_DEVICE_FINISHED
Instead of abusing CAIRO_STATUS_SURFACE_FINISHED to indicate the use
of a finished device, define and use the new error status
CAIRO_STATUS_DEVICE_FINISHED.
2011-07-08 11:26:45 +02:00
Andrea Canciani
780534cd31 gstate: Remove useless code
gstate->source has been initialized as the static black pattern, so
its status is success.
2011-07-08 11:26:38 +02:00
Andrea Canciani
4679b28e21 color: Remove unused functions
_cairo_color_init() and _cairo_color_init_rgb() are basically unused
(except in some experimantal code, which is trivial to fix).
2011-07-08 11:14:16 +02:00
Andrea Canciani
9374cf0a97 pattern: Implement _rgb functions as wrappers over _rgba functions
cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb()
implement the same logic as cairo_pattern_create_rgba() and
cairo_pattern_add_color_stop_rgba() with an alpha == 1.0.

Instead of duplicating the code, they can simply call into the more
general functions.
2011-07-08 11:14:16 +02:00
Andrea Canciani
d7cc30eb01 Make error contexts static
Dynamically creating error contexts requires locking and failure
handling. The code logic can be simplified by statically defining all
the possible error contexts.
2011-07-05 10:00:14 +02:00
Andrea Canciani
ef659649d3 Clean up context_pool upon static data reset
In commit f46ba56d5b the static context
stash was replaced by a dynamic freed pool, which needs to be cleared
upon resets.

Fixes:
cairo.c:181: warning: ‘context_pool’ defined but not used

Reported-by: Uli Schlachter <psychon@znc.in>
2011-07-05 10:00:14 +02:00
Andrea Canciani
fe3ca9c36f Remove conditional compilation of freed-pools
Conditional compilation was needed to avoid warnings:
cairo-clip.c:51: warning: ‘clip_path_pool’ defined but not used
cairo.c:181: warning: ‘context_pool’ defined but not used

They can be avoided by making sure that _freed_pool_reset(ptr)
actually consumes its argument. This has the pleasant side-effect that
forgetting to properly reset a freed-pool now results in a warning if
atomic ops are disabled/not available.
2011-07-05 10:00:13 +02:00
Uli Schlachter
eea31cc4ee xlib-xcb: Don't call directly into the xcb backend
Instead, this now uses the surface wrapper functions for this job.
These functions make sure that e.g. snapshots are detached and that is_clear is
reset correctly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 23:11:48 +02:00
Uli Schlachter
9e4c73a40d xlib-xcb: Fix some use-after-free
Also, this now sets surface->xcb to NULL after the dereference. Segfaults are
way more prominent anyway. :-)

All the backend callbacks shouldn't need any checks since the public entry point
already checks for finished surfaces. Only the public functions in xlib-xcb need
to do checks for finished surfaces.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 23:00:24 +02:00
Uli Schlachter
880566e14b xcb: Remove an unused function argument
Since commit f1d313e0, the 'force' argument to _copy_to_picture() isn't used
anymore. Said commit should have removed it. Whoops.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 17:40:36 +02:00
Uli Schlachter
7e1a9f1db0 xlib-xcb: Fix cairo_surface_flush()
This function called directly into the xcb's surface flush function. This means
that snapshots for that surface weren't detached since that's normally done in
cairo_surface_flush() before calling into the backend.

Fix this by using surface_flush() instead of calling into the backend directly.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=31931

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 21:58:42 +02:00
Uli Schlachter
26ee41435b xlib-xcb: Verify we really have an xcb surface
If the X11 server doesn't have the RENDER extension, the xcb backend falls back
to the image backend in some cases (e.g. create_similar). xlib-xcb didn't handle
this properly which means it used the result like a xcb surface.

Found while debugging https://bugs.freedesktop.org/show_bug.cgi?id=31931,
firefox died from a BadDrawable error when it tried to use the (bogous) result
from cairo_xlib_surface_get_drawable().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 18:53:18 +02:00
Uli Schlachter
59fadcf7d9 xlib-xcb: Fix api-special-cases test
The functions cairo_xlib_surface_set_size and cairo_xlib_surface_set_drawable
didn't set the expected error when called with a finished surface.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 10:26:28 +02:00
Uli Schlachter
4495e08e9e xlib-xcb: Use slim_hidden_proto correctly
There are debug functions for setting the precision on a xlib device, so
xlib-xcb must redirect that to the xcb backend, too. However this means that
these public functions now are also called internally, thus we have to make them
go through the slim_hidden_* macros.

This commit fixes the following error from "make check":

Checking .libs/libcairo.so for local PLT entries
00000000002bb6d8  000001e300000007 R_X86_64_JUMP_SLOT     000000000006d8a0 cairo_xcb_device_debug_set_precision + 0
00000000002bb750  0000025e00000007 R_X86_64_JUMP_SLOT     000000000006d8b0 cairo_xcb_device_debug_get_precision + 0
FAIL: check-plt.sh

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 10:15:46 +02:00
Søren Sandmann Pedersen
ea645913ba Include pixman.h in cairo-xlib-private.h
Otherwise "make cairo-perf-trace" fails. Reported by Matt Turner on
IRC.
2011-06-27 23:12:51 -04:00
Chris Wilson
8996287d94 xlib: Create an exact match for the image surface if possible using Xrender
In order to defer the pixel conversion till as late in the pipeline as
possible, we want to try and preserve the pixman image format whilst
uploading the pixel data. To do this, we want to create an XRender
surface with a matching PictFormat to the source image. Then we need to
make sure we take the quick path through _draw_image_surface for none
and direct conversions.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-06-25 20:15:18 +01:00
Andrea Canciani
f46ba56d5b Do not open-code freed-pool
Reuse the freed-pool system to reduce allocation pressure of context
creation/destruction.

As a side effect, this removes the use of ffs() on Win32, cleaning up
some MSVC-specific code and fixing a mingw-related build issue.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=30277
2011-06-25 15:35:48 +02:00