Commit graph

47 commits

Author SHA1 Message Date
Chuanbo Weng
91113a9e45 subsurface: Avoid potential crash when subsurface's size is less than 0
When cairo_surface_create_for_rectangle() is given non-integer parameters,
the subsurface's size may be negative(e.g x = 0.2, width = 0.7, the
final width will be -1). This illegal surface may cause crash somewhere
upon later use, and although the fractional subsurface is ill-defined,
we should never crash!
2012-03-13 11:19:23 +00:00
Chris Wilson
c39cb77d64 subsurface: Fix typo in snapshot creation
I need to remember that the translation for the pattern matrix is the
inverse of the translation for drawing.

Fixes: subsurface-modify-parent
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-24 13:51:25 +00:00
Chris Wilson
8028f04a91 debug: Add some TRACE statements for recording surfaces and snapshots
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-24 13:51:25 +00:00
Chris Wilson
2061cd81f2 Replace the ad-hoc surface unwrappers with a function pointer
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-09 13:01:17 +00:00
Chris Wilson
dc80e8328c subsurface: Add guards for creating similar surface
If the target backend doesn't provide the entry points, just return NULL
(unsupported).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-01-11 12:43:44 +00:00
Chris Wilson
f308ba7a44 subsurface: Replace any existing snapshot
Only allow one owner to keep their snapshot on the subsurface, and
so automatically replace any previous snapshot.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-25 12:25:38 +00:00
Chris Wilson
2fb4a0e119 subsurface: Support caching for cloned subsurfaces
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-23 17:35:30 +00:00
Chris Wilson
44a868b552 subsurface: And remove the dead code for releasing complex source
Following the previous commit, we only allocate a simple image when
acquiring the source so we only need to unreference it upon release.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-23 14:28:27 +00:00
Chris Wilson
c52129feb4 subsurface: Simplify acquire_source_image
Remove all of the special casing and simply extract the source. The time
for special casing is to avoid calling the generic acquire in the first
place, so kiss.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-23 14:19:22 +00:00
Chris Wilson
ba855a12e8 xlib-xp 2011-10-14 16:01:27 +01:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
2011-09-12 08:29:48 +01:00
Chris Wilson
6b3d53646e image: peek through a snapshot to the recording surface behind
Fixes record-* after the recent overhaul.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
8a90b22897 subsurface+recording: handle recursion
Ouch, a nasty bug surfaces after rearranging code to fix the others.
Another self-copy loop this time through a subsurface of a recording
surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
7971c678f1 subsurface: call the high-level cairo_surface_flush
And not the backend directly as this bypasses the extra steps taken in
the higher level to do common actions such as detach snapshots.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
9f6428c517 recording: remove the duplicate 'content' field
Just use the member in the base class.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:56 +01:00
Chris Wilson
e849e7c929 image: move surface definition to new header for subclassing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 09:54:28 +01:00
Andrea Canciani
3f9717347e win32: Constify
Silences some compiler warnings.
2011-07-27 09:44:25 +02:00
Chris Wilson
a69335a84e API: map-to-image and create-similar-image
A common requirement is the fast upload of pixel data. In order to
allocate the most appropriate image buffer, we need knowledge of the
destination. The most obvious example is that we could use a
shared-memory region for the image to avoid the transfer cost of
uploading the pixels to the X server. Similarly, gl, win32, quartz...

The other side of the equation is that for manual modification of a
remote surface, it would be more efficient if we can create a similar
image to reduce the transfer costs. This strategy is already followed
for the destination fallbacks and this merely exposes the same
capability for the application fallbacks.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 14:55:58 +01:00
Chris Wilson
69cc802e61 Fix proxying of ->context_create()
Adrian Johnson found that I had broken show_page() and pinpointed the
cause to being that cairo_show_page() was being called on the recording
surface and not the pagination surface after my overhaul for
cairo_backend_t. In fact, the problem was far more severe as the mistake
caused the created context to point to the wrong surface entirely,
bypassing the surface proxy.

What is desired is for the proxy's target surface to choose what manner
of context is should use, but for all calls into the surface backend to
go through the proxy surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-21 13:45:58 +01:00
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
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
Benjamin Otte
61a1835e40 subsurface: Fix acquire_source_surface for out-of-bounds surfaces
See subsurface-outside-target test.
2010-09-01 03:17:12 +02:00
M Joonas Pihlaja
b0f65054b8 subsurface: Add a note to the docs about usage restrictions.
Make our assumptions about constructed subsurfaces explicit
while we work out the correct semantics for the edge cases.
2010-08-29 00:03:07 +03:00
M Joonas Pihlaja
df4b23ff74 subsurface: Fix crash when acquiring a source image.
The code is passing in the extra info received from
the target surface's acquire_source() method to
_cairo_surface_get_extents() rather than the acquired
source surface itself.
2010-08-27 20:26:06 +03:00
Andrea Canciani
2d146867dc subsurface: Correct cloning condition
72644c6df2 was using the wrong (inverted)
condition to check if the subsurface extents are contained in the
target extents.
2010-08-26 14:50:34 +02:00
Andrea Canciani
72644c6df2 subsurface: Avoid invalid accesses
Whenever subsurface extents are not contained in the target extents,
using the source image given by the target (with origin corrected by
using an appropriate offset in the data pointer) is not a valid
operation. Fallback to cloning in that case.
2010-08-26 14:38:34 +02:00
Andrea Canciani
df4465bdd1 subsurface: Silence compiler warnings
Commit d1c35f5e65 introduced two
unused variable warnings.
2010-08-26 14:23:04 +02:00
Benjamin Otte
d1c35f5e65 subsurface: Don't clip size to target size
This clipping would modify the origin of the subsurface and then the
creator has no easy way to figure this out.
2010-08-26 13:55:02 +02:00
Benjamin Otte
e79acf47a5 subsurface: Make CAIRO_SURFACE_TYPE_SUBSURFACE public 2010-08-26 12:55:39 +02:00
Benjamin Otte
40459dacb5 subsurface: Don't crash when the device transform isn't integer
Apply the transform before rounding to integer coordinates, so we can
handle doubles easily.
2010-08-26 11:45:28 +02:00
Benjamin Otte
e19b213e84 subsurface: Make subsurfaces their own type
Do not try to hide being a subsurface.
This would cause confusion when users where calling surface-type
specific getters on subsurfaces.

FIXME: We still need public API to access a subsurface's target though.
2010-08-26 11:20:36 +02:00
Benjamin Otte
e65bf64c4a subsurface: Properly account for device offsets in the target 2010-08-26 11:20:36 +02:00
Chris Wilson
eb85ab998b subsurface: Don't assume we ever own the target.
Andrea pointed out that snapshots can be shared, and so the subsurface
should not be calling finish even on a snapshot.
2010-07-10 11:16:19 +01:00
Benjamin Otte
448653e7b9 Call _cairo_error() when setting the FINISHED error on surfaces 2010-07-05 22:42:08 +02:00
Benjamin Otte
6744b78de1 subsurface: Fail if created from a finished surface
Caught by api-special-cases test
2010-07-05 18:38:33 +02:00
Chris Wilson
97a88c5adb xlib: Compile without fontconfig
Create a cairo-fontconfig-private.h where we can add the missing defines
in a common location rather than in the body of the code.
2010-06-28 17:11:54 +01:00
Chris Wilson
ad8abc0110 subsurface: Don't double apply device offset for deep subsurfaces.
If we have a subsurface of a subsurface then the device offset has
already been applied to the extents that we use to offset the new
subsurface.
2010-05-08 18:24:48 +01:00
Chris Wilson
b9e9ff5934 subsurface: Include device offset in extents
Adjust the subsurface extents so that the user specifies the extents in
world space rather than device space.
2010-05-07 11:25:03 +01:00
Chris Wilson
8ded35fd69 ps: Enable native encoding of subsurface patterns.
Carefully handle subsurfaces of a recording surface through the analysis
and paginated surfaces so that we can generate a native pattern for the
vector backends, demonstrated by the PostScript backend.

Nothing remarkable, just a lot of bookkeeping to track the wrapped
surface types and to apply the correct offsets when generating the
subsurface pattern.
2010-04-30 10:16:24 +01:00
Chris Wilson
3940b0e91c subsurface: s/region/rectangle/
After a renewed discussion, it was pointed out that the API in Cairo was
not restrictive and by using doubles we would be consisted with the rest
of the API. Thus prompting the name change to

  cairo_surface_create_for_rectangle()

similar to cairo_rectangle().

And document the public API.
2010-04-30 10:16:06 +01:00
Chris Wilson
6a99e83c50 subsurface: Mark the image as !clear after copying. 2010-04-28 09:55:20 +01:00
Andrea Canciani
b8a7f8621a Update FSF address
I updated the Free Software Foundation address using the following script.

for i in $(git grep Temple | cut -d: -f1 )
do
  sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
2010-04-27 11:13:38 +02:00
Benjamin Otte
2bffa2467e Use pixman_image_composite32()
Replace all occurences of pixman_image_composite()
2010-04-15 18:31:01 +02:00
Chris Wilson
36e12b1952 subsurface: Ignore return from _cairo_clip_init_copy()
The return is just a hint that the clip is empty, however we are about
to immediately apply the surface clip and so do not care for an
'optimised' path.
2010-03-24 12:14:20 +00:00
Andrea Canciani
a9a73e5df4 Constrain subsurface creation
Force the subsurface extents to be inside the target extents and
compose subsubsurfaces offsets correctly.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-01-24 23:51:09 +01: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
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