_cairo_win32_display_surface_map_to_image issue

Fred bca21 <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAKTSDKacDOWw0_Sj9zQJ0+UyFO7rJJP-UUkfRf6Vt7f4FwqTfw@mail.gmail.com>
Hi,

while trying to fix a cairo crash on win32 (already posted on this
list), I am trying to understand the function below, and I can't
figure out how it works regarding coordinates (it looks inconsistent
to me):

- The first call to  _cairo_win32_display_surface_create_for_dc
creates a surface with the appropriate with and height regarding the
extent rectangle.
- then why does the BitBlt call uses 0.0 as the origin for the source
surface and not the origin of the extent since the newly created
surface is supposed to represent the extent rectangle?
- Also, why does the _cairo_image_surface_map_to_image using our newly
created image does not use (0,0) as the origin, since our newly
created image's origin corresponds to (extents.x,extents.y) in the
original surface?

There is probaby something that I am missing, but this seems to be the
origin of the crash that I am chasing (this functions returns a
pointer outside of the image boundaries due to a wrong offset).

Thanks for your help.

(If it is not the right list to discuss such implementation details,
please forgive me and tell me where I should post)

Fred.


-----------
static cairo_surface_t *
_cairo_win32_display_surface_map_to_image (void
*abstract_surface,
					   const cairo_rectangle_int_t   *extents)
{
    cairo_win32_display_surface_t *surface = abstract_surface;
    cairo_status_t status;

    TRACE ((stderr, "%s (surface=%d)\n",
	    __FUNCTION__, surface->win32.base.unique_id));

    if (surface->image)
	goto done;

    if (surface->fallback == NULL) {
	surface->fallback =
	    _cairo_win32_display_surface_create_for_dc (surface->win32.dc,
							surface->win32.format,
							surface->win32.extents.width,
							surface->win32.extents.height);
	if (unlikely (status = surface->fallback->status))
	    goto err;

	if (!BitBlt (to_win32_surface(surface->fallback)->dc,
		     0, 0,
		     surface->win32.extents.width,
		     surface->win32.extents.height,
		     surface->win32.dc,
		     0, 0,
		     SRCCOPY)) {
	    status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
	    goto err;
	}
    }

    surface = to_win32_display_surface (surface->fallback);
done:
    GdiFlush();
    return _cairo_image_surface_map_to_image (surface->image, extents);
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.