summaryrefslogtreecommitdiff
path: root/src/cairo-xcb-surface.c
AgeCommit message (Collapse)AuthorFilesLines
2010-01-25xcb: Fix linking with xcb-drmChris Wilson1-0/+2
2010-01-25xcb: Make shm optionalChris Wilson1-0/+14
Trying to build xcb on a system without SHM wrapped by xcb. The right answer would be to build libxcb-shm. The quick answer is to compile out shm support.
2010-01-22xcb: Refresh.Chris Wilson1-2423/+921
Still an experimental backend, it's now a little too late to stabilise for 1.10, but this should represent a major step forward in its feature set and an attempt to catch up with all the bug fixes that have been performed on xlib. Notably not tested yet (and expected to be broken) are mixed-endian connections and low bitdepth servers (the dithering support has not been copied over for instance). However, it seems robust enough for daily use... Of particular note in this update is that the xcb surface is now capable of subverting the xlib surface through the ./configure --enable-xlib-xcb option. This replaces the xlib surface with a proxy that forwards all operations to an equivalent xcb surface whilst preserving the cairo-xlib API that is required for compatibility with the existing applications, for instance GTK+ and Mozilla. Also you can experiment with enabling a DRM bypass, though you need to be extremely foolhardy to do so.
2010-01-22image: Implement high level interface.Chris Wilson1-8/+2
Write a dedicated compositor for pixman so that we avoid the middle-layer syndrome of surface-fallback. The major upshot of this rewrite is that the image surface is now several times quicker for glyph compositing, which dramatically improves performance for text rendering by firefox and friends. It also uses a couple of the new scan convertors, such as the rectangular scan converter for rectilinear paths. Speedups ======== image-rgba firefox-talos-gfx-0 342050.17 (342155.88 0.02%) -> 69412.44 (69702.90 0.21%): 4.93x speedup ███▉ image-rgba vim-0 97518.13 (97696.23 1.21%) -> 30712.63 (31238.65 0.85%): 3.18x speedup ██▏ image-rgba evolution-0 69927.77 (110261.08 19.84%) -> 24430.05 (25368.85 1.89%): 2.86x speedup █▉ image-rgba poppler-0 41452.61 (41547.03 2.51%) -> 21195.52 (21656.85 1.08%): 1.96x speedup █ image-rgba firefox-planet-gnome-0 217512.61 (217636.80 0.06%) -> 123341.02 (123641.94 0.12%): 1.76x speedup ▊ image-rgba swfdec-youtube-0 41302.71 (41373.60 0.11%) -> 31343.93 (31488.87 0.23%): 1.32x speedup ▍ image-rgba swfdec-giant-steps-0 20699.54 (20739.52 0.10%) -> 17360.19 (17375.51 0.04%): 1.19x speedup ▎ image-rgba gvim-0 167837.47 (168027.68 0.51%) -> 151105.94 (151635.85 0.18%): 1.11x speedup ▏ image-rgba firefox-talos-svg-0 375273.43 (388250.94 1.60%) -> 356846.09 (370370.08 1.86%): 1.05x speedup
2010-01-22pattern: Add convenience patterns for stock coloursChris Wilson1-6/+1
By preallocating in our data segment a couple of solid patterns for the stock colours, it becomes more convenient when using those in surface operations, such as when clearing.
2010-01-22Add cairo_device_tChris Wilson1-1/+3
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-22Move _cairo_error() to a standalone headerChris Wilson1-1/+2
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.
2009-11-09Add new operator-alpha-alpha testAndrea Canciani1-4/+0
Compositing of alpha-only sources is not throughly tested and as a consequence the misbehaviour of some backends is not shown by the test suite. [ickle: Added XFAILs for pdf, ps, svg.]
2009-09-30[xcb] Deferred error checking.Chris Wilson1-246/+466
XCB avoids the dreaded abort on XError mechanism by forcing the client to perform deferred error checking. So do so. This allows us to combine the fire-and-forget rendering model with accurate error checking, without killing the client or mixing our errors with theirs. XCB for the win!
2009-07-28[gl] Fallback for overlapping glyphs.Chris Wilson1-1/+2
2009-07-23Remove clip handling from generic surface layer.Chris Wilson1-114/+134
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-06-11[xcb] Trivial compile fix.Chris Wilson1-5/+6
Update show_glyphs() interface.
2009-06-05xlib, xcb: Hand off EXTEND_PAD/EXTEND_REFLECT to RenderThomas Jaeger1-2/+13
Most drivers and the X server used to have incorrect RepeatPad/RepeatReflect implementations, forcing cairo to fall back to client-side software rendering, which is painfully slow due to pixmaps being transfered over the wire. These issues are mostly fixed in the drivers (with the exception of radeonhd, whose developers didn't respond) and the RepeatPad software fallback is implemented correctly as of pixman-0.15.0, so this patch will hand off composite operations with EXTEND_PAD/EXTEND_REFLECT source patterns to XRender. There is no way to detect whether the X server or the drivers use a broken Render implementation, we make a guess based on the server version: It's probably safe to assume that 1.7 X servers will use fixed drivers and a recent enough version of pixman.
2009-06-02Add more surface snapshots providersPaolo Bonzini1-1/+16
This patch adds more implementation of the snapshot method. For surface types where acquire_source_image is already making a copy of the bits, doing another one as is the case for the fallback implementation is a waste.
2009-06-02[pattern] Pass flags to _cairo_pattern_acquire_surface()Chris Wilson1-0/+4
Allow the caller to choose whether or not various conversions take place. The first flag is used to disable the expansion of reflected patterns into a repeating surface.
2009-05-15[xlib] Use minimal depth for similar clones.Chris Wilson1-0/+5
Damian Frank noted [http://lists.cairographics.org/archives/cairo/2009-May/017095.html] a performance problem with an older XServer with an unaccelerated composite - similar problems will be seen with non-XRender servers which will trigger extraneous fallbacks. The problem he found was that painting an ARGB32 image onto an RGB24 destination window (using SOURCE) was going via the RENDER protocol and not core. He was able to demonstrate that this could be worked around by declaring the pixel data as an RGB24 image. The issue is that the image is uploaded into a temporary pixmap of matching depth (i.e. 32 bit for ARGB32 and 24 bit for RGB23 data), however the core protocol can only blit between Drawables of matching depth - so without the work-around the Drawables are mismatched and we either need to use RENDER or fallback. This patch adds a content mask to _cairo_surface_clone_similar() to provide the extra bit of information to the backends for when it is possible for them to drop channels from the clone. This is used by the xlib backend to only create a 24 bit source when blitting to a Window.
2009-03-28[region] Remove underscores from _cairo_region_*Søren Sandmann1-2/+2
2009-03-28[region] Consistently use rectangles in the API of regionsSøren Sandmann Pedersen1-12/+12
Usually, rectangles are more useful than boxes, so regions should only expose rectangles in their public API. Specifically, _cairo_region_num_boxes becomes _cairo_region_num_rectangles _cairo_region_get_box becomes _cairo_region_get_rectangle Remove the cairo_box_int_t type
2009-02-15Delete _cairo_region_get_boxes() in favor of _cairo_region_get_box()Søren Sandmann1-15/+11
The _cairo_region_get_boxes() interface was difficult to use and often caused unnecessary memory allocation. With _cairo_region_get_box() it is possible to access the boxes of a region without allocating a big temporary array.
2008-12-12[xcb] check for render extension presenceJulien Danjou1-2/+6
Otherwise this may leads to an invalid memory access to r. Fixes: Bug 18588 - XCB backend fails with missing render. https://bugs.freedesktop.org/show_bug.cgi?id=18588 Signed-off-by: Julien Danjou <julien@danjou.info> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2008-12-06[cairo-spans] Add a check/create_span_renderer backend methods.M Joonas Pihlaja1-0/+2
A surface will have the chance to use span rendering at cairo_fill() time by creating a renderer for a specific combination of pattern/dst/op before the path is scan converted. The protocol is to first call check_span_renderer() to see if the surface wants to render with spans and then later call create_span_renderer() to create the renderer for real once the extents of the path are known. No backends have an implementation yet.
2008-11-21[region] Use the caller supplied array for extracting boxes.Chris Wilson1-0/+1
Allow the user to pass in a pre-allocated array and use it if the number of boxes permits. This eliminates the frequent allocations during clipping by toolkits.
2008-11-08cairo-xcb: avoid leaking memoryMaarten Maathuis1-0/+3
2008-10-30[pattern] Avoid needless copying of patterns.Chris Wilson1-21/+21
Only copy the pattern if we need to modify it, e.g. preserve a copy in a snapshot or a soft-mask, or to modify the matrix. Otherwise we can continue to use the original pattern and mark it as const in order to generate compiler warnings if we do attempt to write to it.
2008-10-30Review users of cairo_rectangle_int_t for incorrect unsigned promotion.Chris Wilson1-38/+18
Adrian Johnson discovered cases where we mistakenly compared the result of unsigned arithmetic where we need signed quantities. Look for similar cases in the users of cairo_rectangle_int_t.
2008-10-22Ensure that the scaled font is frozen for the lifetime of the scaled glyph.Chris Wilson1-88/+128
After discussing the scaled font locking with Behdad, it transpired that it is not sufficient for a font to be locked for the lifetime of a scaled glyph, but that the scaled font's glyph cache must be frozen for the glyph' lifetime. If the cache is not frozen, then there is a possibility that the glyph may be evicted before the reference goes out of scope i.e. the glyph becomes invalid whilst we are trying to use it. Since the freezing of the cache is the stronger barrier, we remove the locking/unlocking of the mutex from the backends and instead move the mutex acquisition into the freeze/thaw routines. Then update the rule on acquiring glyphs to enforce that the cache is frozen and review the usage of freeze/thaw by all the backends to ensure that the cache is frozen for the lifetime of the glyph.
2008-10-19Review backend->create_similar()Chris Wilson1-0/+2
Avoid masking fatal errors by enforcing any error to be returned via an error surface, so that the NULL return only means UNSUPPORTED. A few backends called their create_similar() directly, without correctly checking for a potential NULL (for example, the directfb backend was a timebomb, since it used NULL to indicate out-of-memory).
2008-10-04[xcb] Return false from _cairo_xcb_surface_is_similar().Chris Wilson1-0/+6
_cairo_xcb_surface_is_similar() is currently only used by the pattern cache to determine whether to keep the surface in the solid color cache. This is fundamentally broken without hooking into Display closure as it keeps a reference to an expired picture. So in order to prevent spurious application crashes, disable the caching for xcb.
2008-10-04[xcb] Compile fix.Chris Wilson1-17/+24
Must compile xcb more often. Especially after copying code over from xlib.
2008-09-28[xlib] _surfaces_compatible() can return true for different picture formatsKarl Tomlinson1-1/+3
_surfaces_compatible in cairo-xlib-surface returns true for surfaces with different xrender_format when each has the same depth and no (NULL) visual. Common picture formats will not have the same depth, but it is possible to create a surface with a non-standard xrender_format having the same depth as another xrender_format with cairo_xlib_surface_create_with_xrender_format. Both cairo_xlib_surface_create_with_xrender_format and _cairo_xlib_surface_create_similar_with_format create surfaces with no visual. The same issue exists in the xcb backend. Fixes bug https://bugs.freedesktop.org/show_bug.cgi?id=16564.
2008-09-27clone_similar(): s/device_offset/clone_offset/Chris Wilson1-6/+6
A little bit of sleep and reflection suggested that the use of device_offset_[xy] was confusing and clone_offset_[xy] more consistent with the function naming.
2008-09-27Allow cloning sub-regions of similar surfaces.Chris Wilson1-4/+14
Previously the rule for clone_similar() was that the returned surface had exactly the same size as the original, but only the contents within the region of interest needed to be copied. This caused failures for very large images in the xlib-backend (see test/large-source). The obvious solution to allow cloning only the region of interest seemed to be to simply set the device offset on the cloned surface. However, this fails as a) nothing respects the device offset on the surface at that layer in the compositing stack and b) possibly returning references to the original source surface provides further confusion by mixing in another source of device offset. The second method was to add extra out parameters so that the device offset could be returned separately and, for example, mixed into the pattern matrix. Not as elegant, a couple of extra warts to the interface, but it works - one less XFAIL...
2008-06-13Allocate the correct pattern type on the stack.Chris Wilson1-2/+2
Instead of allocating the union of all possible pattern types, just allocate the specific pattern as used by the function in order to trim the stack space consumption and flag potential misuse.
2008-06-01Fix now-detected doc formatting issuesBehdad Esfahbod1-2/+2
2008-05-30[cairo-xcb] Oops. Fix build.Behdad Esfahbod1-1/+1
2008-05-28Fix two more compile errorsBehdad Esfahbod1-1/+2
When adding remaining_glyphs argument to show_glyphs(), I missed a few places.
2008-05-23[cairo-xlib] Fix show_glyphs when failing to upload a glyphBehdad Esfahbod1-1/+2
Originally reported here: http://lists.cairographics.org/archives/cairo/2008-May/014032.html and analyized later in the thread. Change (font and surface) backend show_glyphs() API to take a int *remaining_glyphs argument. It's used to communicate to the caller, by way of setting remaining_glyphs and returning INT_STATUS_UNSUPPORTED, that some of the glyphs were shown but not the others. The xlib backend now correctly uses this to handle failure to upload a glyph to the server. So the large-font test passes now. An alternative approach could be to add some public value for glyphs indices that are not shown. -1 perhaps (the xlib backend already uses that value internally). Then instead of remaining_glyphs, a backend could simply set glyph indices of glyphs shown to that -1 value.
2008-01-28[doc] Replace 'NOTE' by 'Note' and add it to testBehdad Esfahbod1-2/+2
2008-01-28[doc] Make sure all macro names in docs are prefixed by %Behdad Esfahbod1-1/+1
2008-01-22Fix usage of cairo_rectangle_int16_t leading to memory corruptionVladimir Vukicevic1-2/+2
cairo_rectangle_int16_t was being used in a number of places instead of cairo_rectangle_int_t, which led to memory corruption when cairo was using a fixed point format with a bigger space than 16.16 (such as 24.8).
2008-01-16[cairo-surface] Introduce _cairo_surface_create_in_error().Chris Wilson1-12/+6
Unexport all the static error surfaces and use a function to select the appropriate error surface for the status.
2007-10-04[cairo-error] Clean up all the warnings and missing _cairo_error() calls.Chris Wilson1-29/+21
Every time we assign or return a hard-coded error status wrap that value with a call to _cairo_error(). So the idiom becomes: status = _cairo_error (CAIRO_STATUS_NO_MEMORY); or return _cairo_error (CAIRO_STATUS_INVALID_DASH); This ensures that a breakpoint placed on _cairo_error() will trigger immediately cairo detects the error.
2007-10-04[malloc/error] Add call to _cairo_error() after a failed malloc.Chris Wilson1-5/+18
Blitz all allocations to ensure that they raise a _cairo_error(CAIRO_STATUS_NO_MEMORY) on failure.
2007-08-31Revert "[cairo-gstate] Avoid copying untransformed glyphs."Chris Wilson1-10/+10
This reverts commit 919bea6dbb32746f11781cd3a94eb44f5c4a32e6. Sadly as Behdad points out some backends do modify the glyph array and, for example cairo-xlib-surface, hide this from the compiler with some evil casts.
2007-08-31[cairo-gstate] Avoid copying untransformed glyphs.Chris Wilson1-10/+10
Skip the memory duplication of the incoming glyphs if we do not need to transform them into the backend coordinate system. As a consequence we need to constify the glyphs passed to the backend functions.
2007-08-20Fix device_offset misuse in all glyph surface usesBehdad Esfahbod1-38/+2
Seems like all over the code, we have been using negated device_offset values for glyph surfaces. Here is all the math(!): A device_transform converts from device space (a conceptual space) to surface space. For simple cases of translation only, it's called a device_offset and is public API (cairo_surface_[gs]et_device_offset). A possibly better name for those functions could have been cairo_surface_[gs]et_origing. So, that's what they do: they set where the device-space origin (0,0) is in the surface. If the origin is inside the surface, device_offset values are positive. It may look like this: Device space: (-x,-y) <-- negative numbers +----------------+ | . | | . | |......(0,0) <---|-- device-space origin | | | | +----------------+ (width-x,height-y) Surface space: (0,0) <-- surface-space origin +---------------+ | . | | . | |......(x,y) <--|-- device_offset | | | | +---------------+ (width,height) In other words: device_offset is the coordinates of the device-space origin relative to the top-left of the surface. We use device offsets in a couple of places: - Public API: To let toolkits like Gtk+ give user a surface that only represents part of the final destination (say, the expose area), but has the same device space as the destination. In these cases device_offset is typically negative. Example: application window +---------------+ | . | | (x,y). | |......+---+ | | | | <--|-- expose area | +---+ | +---------------+ In this case, the user of cairo API can set the device_space on the expose area to (-x,-y) to move the device space origin to that of the application window, such that drawing in the expose area surface and painting it in the application window has the same effect as drawing in the application window directly. Gtk+ has been using this feature. - Glyph surfaces: In most font rendering systems, glyph surfaces have an origin at (0,0) and a bounding box that is typically represented as (x_bearing,y_bearing,width,height). Depending on which way y progresses in the system, y_bearing may typically be negative (for systems similar to cairo, with origin at top left), or be positive (in systems like PDF with origin at bottom left). No matter which is the case, it is important to note that (x_bearing,y_bearing) is the coordinates of top-left of the glyph relative to the glyph origin. That is, for example: Scaled-glyph space: (x_bearing,y_bearing) <-- negative numbers +----------------+ | . | | . | |......(0,0) <---|-- glyph origin | | | | +----------------+ (width+x_bearing,height+y_bearing) Note the similarity of the origin to the device space. That is exactly how we use the device_offset to represent scaled glyphs: to use the device-space origin as the glyph origin. Now compare the scaled-glyph space to device-space and surface-space and convince yourself that: (x_bearing,y_bearing) = (-x,-y) = - device_offset That's right. If you are not convinced yet, contrast the definition of the two: "(x_bearing,y_bearing) is the coordinates of top-left of the glyph relative to the glyph origin." "In other words: device_offset is the coordinates of the device-space origin relative to the top-left of the surface." and note that glyph origin = device-space origin. So, that was the bug. Fixing it removed lots of wonders and magic negation signs. The way I discovered the bug was that in the user-font API, to make rendering the glyph from meta-surface to an image-surface work I had to do: cairo_surface_set_device_offset (surface, -x_bearing, -y_bearing); _cairo_meta_surface_replay (meta_surface, surface); cairo_surface_set_device_offset (surface, x_bearing, y_bearing); This suggested that the use of device_offset for glyph origin is different from its use for rendering with meta-surface. This reminded me of the large comment in the xlib backend blaming XRender for having weird glyph space, and of a similar problem I had in the PS backend for bitmap glyph positioning (see d47388ad759b0a1a0869655a87d9b5eb6ae2445d) ...those are all fixed now.
2007-07-18[fixpt] Fixup malloc usage to use _cairo_malloc_*Vladimir Vukicevic1-2/+2
Fix some introduced mallocs as a result of the fixed point patches.
2007-07-18[fixpt] Create cairo_region wrapper around pixman_region16_tVladimir Vukicevic1-11/+15
Insulate region-using code from implementation details; at some point we'll want to switch to using 32-bit regions.
2007-07-18[fixpt] Fix xcb surface to handle conversion to 16.16Vladimir Vukicevic1-21/+66
2007-07-18[fixpt] Replace cairo_rectangle_int16_t with cairo_rectangle_int_tVladimir Vukicevic1-9/+9
Mostly s/cairo_rectangle_int16_t/cairo_rectangle_int_t/, as well as definitions to pick cairo_rectangle_int_t.