Commit graph

28 commits

Author SHA1 Message Date
Chris Wilson
fb8881e84b win32: Prevent double-free of similar images
Based on a patch and analysis by Michael Henning.

When we create a similar-image surface for win32, we set up a couple of
back references from the image to the win32 surface, and vice versa. We
need to be careful when decoupling the reference cycle to avoid chasing
around the loop upon destruction. Currently we handled destroying the
similar-image via the parent win32 surface, but similar precaution is
required when destroying the surface via the similar-image.

Reported-by: Michael Henning <drawoc@darkrefraction.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63787
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-23 12:53:27 +01:00
Marc-André Lureau
e66e9ac12e win32: fix corrupted drawing
Fix src bitmap coordinates, which origin is bottom-left. This is
apparently a bug in StretchDIBits(), according to some comments on
MSDN API documentation.

The backend used to have this coordinate change in the past:

            if (!StretchDIBits (dst->dc,
                                /* dst x,y,w,h */
                                dst_r.x, dst_r.y + dst_r.height - 1,
                                dst_r.width, - (int) dst_r.height,
                                /* src x,y,w,h */
                                src_r.x, src_extents.height - src_r.y + 1,
                                src_r.width, - (int) src_r.height,
                                src_image->data,
                                &bi,
                                DIB_RGB_COLORS,
                                SRCCOPY))

https://bugs.freedesktop.org/show_bug.cgi?id=61876
2013-04-02 08:39:05 +01:00
Chris Wilson
fb1abbc4bc win32: Free the fallback upon finish
Zozó Teki pointed out that we leak the fallback surface upon finish in
case it was active at the time as the preceding flush would only clear
the damage and not decouple the fallback surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-15 14:08:11 +00:00
Chris Wilson
d4651676e1 win32: Clear the similar-image before returning to the user
Our userspace API mandates that surfaces created for the user are
cleared before they are returned. Make it so for the win32 similar image
constructor.

Reported-by: Michael Henning <drawoc@darkrefraction.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60519
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-08 22:17:13 +00:00
Chris Wilson
4b6b28b5e8 win32: Fix is_win98()
Since the translation into a separate function, its condition was
reversed: that is almost everybody thought they were on a win98 machine
and so had no working AlphaBlend().

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-07 10:02:31 +00:00
Chris Wilson
e29bb5f295 win32: Use the image surface below the fallback when unmapping an HDC
As for a native window, the surface does not have an image delegate
itself but instead installs a fallback surface during map_to_image. So
during unmap_image, we then need to unmap from the fallback surface
instead.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-10-06 18:53:41 +01:00
Chris Wilson
6c6a697610 win32: Compile fix for mismatched surface types
win32/cairo-win32-display-surface.c:472: error: structure has no member
named 'base'

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-10-05 14:55:28 +01:00
Chris Wilson
0bfd2acd35 xlib: Implement SHM fallbacks and fast upload paths
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-17 13:58:09 +01:00
Andrea Canciani
df7829e2cc surface: Make map_to_image return cairo_image_surface_t*
This makes it easier to check that the funciton is returning the
correct type of surfaces.
2012-05-26 16:06:26 +02:00
Dimiter Stanev
1ca8c049ca win32: compilation fix for recent private/inline header separation 2012-04-23 19:10:44 +01:00
Chris Wilson
8653c2692e Split cairo-recording-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:46:34 +01:00
Chris Wilson
f3623cf022 Split cairo-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:27:44 +01:00
Chris Wilson
0770dda52b Split cairo-clip-privates into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:19:19 +01:00
Andrea Canciani
1d3d64469f doc: Add "since" tag to documentation
The following Python script was used to compute "Since: 1.X" tags,
based on the first version where a symbol became officially supported.

This script requires a concatenation of the the cairo public headers
for the officially supported beckends to be available as
"../../includes/1.X.0.h".

from sys import argv
import re

syms = {}

def stripcomments(text):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(
        r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
        re.DOTALL | re.MULTILINE
    )
    return re.sub(pattern, replacer, text)

for minor in range(12,-2,-2):
    version = "1.%d" % minor
    names = re.split('([A-Za-z0-9_]+)', stripcomments(open("../../includes/%s.0.h" % version).read()))
    for s in names: syms[s] = version

for filename in argv[1:]:
    is_public = False
    lines = open(filename, "r").read().split("\n")
    newlines = []
    for i in range(len(lines)):
        if lines[i] == "/**":
            last_sym = lines[i+1][2:].strip().replace(":", "")
            is_public = last_sym.lower().startswith("cairo")
        elif is_public and lines[i] == " **/":
            if last_sym in syms:
                v = syms[last_sym]
                if re.search("Since", newlines[-1]): newlines = newlines[:-1]
                if newlines[-1].strip() != "*": newlines.append(" *")
                newlines.append(" * Since: %s" % v)
            else:
                print "%s (%d): Cannot determine the version in which '%s' was introduced" % (filename, i, last_sym)
        newlines.append(lines[i])

    out = open(filename, "w")
    out.write("\n".join(newlines))
    out.close()
2012-03-29 11:03:18 +02:00
Andrea Canciani
7f635e4ead doc: Make doc ids more consistent my always putting ':' after them
This makes the documentations comments more consistent and fixes many
reports of 'invalid doc id'.
2012-03-29 11:03:18 +02:00
Andrea Canciani
f717341ab9 doc: Make documentation comments symmetric
Documentation comments should always start with "/**" and end with
"**/". This is not required by gtk-doc, but it makes the
documentations formatting more consistent and simplifies the checking
of documentation comments.

The following Python script tries to enforce this.

from sys import argv
from sre import search

for filename in argv[1:]:
    in_doc = False
    lines = open(filename, "r").read().split("\n")
    for i in range(len(lines)):
        ls = lines[i].strip()
        if ls == "/**":
            in_doc = True
        elif in_doc and ls == "*/":
            lines[i] = " **/"
        if ls.endswith("*/"):
            in_doc = False

    out = open(filename, "w")
    out.write("\n".join(lines))
    out.close()

This fixes most 'documentation comment not closed with **/' warnings
by check-doc-syntax.awk.
2012-03-29 11:03:18 +02:00
Chris Wilson
8416b40f43 win32: mark-dirty cannot assume the fallback has been discarded
Flushing only releases the fallback if we flush twice with no
intervening damage (the theory is to try and reduce readbacks). So it is
possible for a correctly behaving application to call mark-dirty and there
still be a fallback.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-23 18:09:19 +00:00
Chris Wilson
60549f7a56 win32: Copy back the fallback damage to the right location
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-23 13:06:28 +00:00
Chris Wilson
be8a5f13b7 win32: Remove obsolete font rendering routines
These are now done by cairo-win32-gdi-compositor.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-22 12:28:46 +00:00
Chris Wilson
28b3831223 win32: Hook up glyph creation again
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-22 12:28:46 +00:00
Chris Wilson
9bb5b02694 win32: Fix damage flushing
The damage wasn't being created on the right surface, so the damage to
the fallback image surface was not being tracked. Perform a little bit
of juggling so that we track dirty regions on the fallback surface itself.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-21 20:09:52 +00:00
Chris Wilson
86a89a8c1d win32: Check for damage before blitting
During the surface flush, we reduce any pending damage and then blit. If
no damage had been accrued then the damage->region would be NULL leading
to a segfault.

Patch suggested by Szuromi Gábor.

Reported-by: Szuromi Gábor <kukkerman@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=47605
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-20 19:16:36 +00:00
Nis Martensen
002a3d8b95 doc: fix broken link
cairo_win32_scaled_font_create_for_logfontw() does not exist. Probably
cairo_win32_font_face_create_for_logfontw() was meant instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-03-10 10:20:30 +01:00
Nis Martensen
77da76ac6c doc: fix a few typos found by codespell
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-03-10 10:20:28 +01:00
Chris Wilson
83af31f0f3 win32: Cast the surface to an image-surface to find its parent (compile fix)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-15 19:48:07 +00:00
Chris Wilson
df608e0fab win32: Fix lifetime tracking of create_similar_image()
As we return the child image to the user and so perform the reference
tracking on it and not the parent win32 display surface, we need to add
a call to destroy the parent from the image surface. This of course
complicates the normal scenario of destroying the parent first, and so
in that case we need to unhook the image->parent before freeing the
surface->image.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-15 18:29:26 +00:00
Chris Wilson
ae3319890e win32: Rebase on the new compositor infrastructure
Try and undo all the damage that has acrued over the years by plugging
into the compositor pipeline.

References: https://bugs.freedesktop.org/show_bug.cgi?id=42739
References: https://bugs.freedesktop.org/show_bug.cgi?id=42821
References: https://bugs.freedesktop.org/show_bug.cgi?id=33081
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-15 14:37:11 +00:00
Chris Wilson
92c0b37d04 win32: Move to separate directoy
I suspect I may split the win32 code into a few more files, so move it
to its own directory to reduce the clutter.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-15 14:21:01 +00:00