Skip to content

Commit

Permalink
win32: Rebase on the new compositor infrastructure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Wilson committed Feb 15, 2012
1 parent 92c0b37 commit ae33198
Show file tree
Hide file tree
Showing 20 changed files with 2,534 additions and 2,131 deletions.
6 changes: 5 additions & 1 deletion src/Makefile.sources
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ cairo_sources = \
cairo-surface-snapshot.c \
cairo-surface-subsurface.c \
cairo-surface-wrapper.c \
cairo-system.c \
cairo-time.c \
cairo-tor-scan-converter.c \
cairo-tor22-scan-converter.c \
Expand Down Expand Up @@ -336,7 +335,12 @@ cairo_quartz_font_sources = cairo-quartz-font.c
cairo_win32_headers = cairo-win32.h
cairo_win32_private = win32/cairo-win32-private.h
cairo_win32_sources = \
win32/cairo-win32-debug.c \
win32/cairo-win32-device.c \
win32/cairo-win32-gdi-compositor.c \
win32/cairo-win32-system.c \
win32/cairo-win32-surface.c \
win32/cairo-win32-display-surface.c \
win32/cairo-win32-printing-surface.c \
$(NULL)
cairo_win32_font_sources = \
Expand Down
39 changes: 39 additions & 0 deletions src/cairo-image-compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ draw_image_boxes (void *_dst,
struct _cairo_boxes_chunk *chunk;
int i;

TRACE ((stderr, "%s\n", __FUNCTION__));

for (chunk = &boxes->chunks; chunk; chunk = chunk->next) {
for (i = 0; i < chunk->count; i++) {
cairo_box_t *b = &chunk->base[i];
Expand Down Expand Up @@ -279,6 +281,8 @@ fill_rectangles (void *_dst,
uint32_t pixel;
int i;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (fill_reduces_to_source (op, color, dst) &&
color_to_pixel (color, dst->pixman_format, &pixel))
{
Expand Down Expand Up @@ -321,6 +325,8 @@ fill_boxes (void *_dst,
uint32_t pixel;
int i;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (fill_reduces_to_source (op, color, dst) &&
color_to_pixel (color, dst->pixman_format, &pixel))
{
Expand Down Expand Up @@ -379,6 +385,9 @@ composite (void *_dst,
{
cairo_image_source_t *src = (cairo_image_source_t *)abstract_src;
cairo_image_source_t *mask = (cairo_image_source_t *)abstract_mask;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (mask) {
pixman_image_composite32 (_pixman_operator (op),
src->pixman_image, mask->pixman_image, to_pixman_image (_dst),
Expand Down Expand Up @@ -415,6 +424,8 @@ lerp (void *_dst,
cairo_image_source_t *src = (cairo_image_source_t *)abstract_src;
cairo_image_source_t *mask = (cairo_image_source_t *)abstract_mask;

TRACE ((stderr, "%s\n", __FUNCTION__));

#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
src->pixman_image, mask->pixman_image, dst->pixman_image,
Expand All @@ -424,6 +435,10 @@ lerp (void *_dst,
width, height);
#else
/* Punch the clip out of the destination */
TRACE ((stderr, "%s - OUT_REVERSE (mask=%d/%p, dst=%d/%p)\n",
__FUNCTION__,
mask->base.unique_id, mask->pixman_image,
dst->base.unique_id, dst->pixman_image));
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
mask->pixman_image, NULL, dst->pixman_image,
mask_x, mask_y,
Expand All @@ -432,6 +447,11 @@ lerp (void *_dst,
width, height);

/* Now add the two results together */
TRACE ((stderr, "%s - ADD (src=%d/%p, mask=%d/%p, dst=%d/%p)\n",
__FUNCTION__,
src->base.unique_id, src->pixman_image,
mask->base.unique_id, mask->pixman_image,
dst->base.unique_id, dst->pixman_image));
pixman_image_composite32 (PIXMAN_OP_ADD,
src->pixman_image, mask->pixman_image, dst->pixman_image,
src_x, src_y,
Expand Down Expand Up @@ -464,6 +484,7 @@ composite_boxes (void *_dst,
int i;

/* XXX consider using a region? saves multiple prepare-composite */
TRACE ((stderr, "%s\n", __FUNCTION__));

if (((cairo_surface_t *)_dst)->is_clear &&
(op == CAIRO_OPERATOR_SOURCE ||
Expand Down Expand Up @@ -612,6 +633,8 @@ composite_traps (void *_dst,
pixman_image_t *mask;
pixman_format_code_t format;

TRACE ((stderr, "%s\n", __FUNCTION__));

/* Special case adding trapezoids onto a mask surface; we want to avoid
* creating an intermediate temporary mask unnecessarily.
*
Expand Down Expand Up @@ -690,6 +713,8 @@ composite_tristrip (void *_dst,
pixman_image_t *mask;
pixman_format_code_t format;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (strip->num_points < 3)
return CAIRO_STATUS_SUCCESS;

Expand Down Expand Up @@ -745,6 +770,8 @@ composite_one_glyph (void *_dst,
cairo_status_t status;
int x, y;

TRACE ((stderr, "%s\n", __FUNCTION__));

status = _cairo_scaled_glyph_lookup (info->font,
info->glyphs[0].index,
CAIRO_SCALED_GLYPH_INFO_SURFACE,
Expand Down Expand Up @@ -794,6 +821,8 @@ composite_glyphs_via_mask (void *_dst,
cairo_status_t status;
int i;

TRACE ((stderr, "%s\n", __FUNCTION__));

/* XXX convert the glyphs to common formats a8/a8r8g8b8 to hit
* optimised paths through pixman. Should we increase the bit
* depth of the target surface, we should reconsider the appropriate
Expand Down Expand Up @@ -916,6 +945,8 @@ composite_glyphs (void *_dst,
cairo_status_t status;
int i;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (info->num_glyphs == 1)
return composite_one_glyph(_dst, op, _src, src_x, src_y, dst_x, dst_y, info);

Expand Down Expand Up @@ -1196,6 +1227,8 @@ span_renderer_init (cairo_abstract_span_renderer_t *_r,
int src_x, src_y;
int mask_x, mask_y;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (op == CAIRO_OPERATOR_CLEAR) {
op = PIXMAN_OP_LERP_CLEAR;
} else if (dst->base.is_clear &&
Expand Down Expand Up @@ -1281,6 +1314,8 @@ span_renderer_fini (cairo_abstract_span_renderer_t *_r,
{
cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) _r;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (status == CAIRO_INT_STATUS_SUCCESS && r->base.finish)
r->base.finish (r);

Expand Down Expand Up @@ -1426,6 +1461,8 @@ span_renderer_init (cairo_abstract_span_renderer_t *_r,
const cairo_pattern_t *source = &composite->source_pattern.base;
cairo_operator_t op = composite->op;

TRACE ((stderr, "%s\n", __FUNCTION__));

r->composite = composite;
r->mask = NULL;
r->src = NULL;
Expand Down Expand Up @@ -1531,6 +1568,8 @@ span_renderer_fini (cairo_abstract_span_renderer_t *_r,
{
cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) _r;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
const cairo_composite_rectangles_t *composite = r->composite;

Expand Down
25 changes: 25 additions & 0 deletions src/cairo-image-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ _pixman_transparent_image (void)
{
pixman_image_t *image;

TRACE ((stderr, "%s\n", __FUNCTION__));

image = __pixman_transparent_image;
if (unlikely (image == NULL)) {
pixman_color_t color;
Expand Down Expand Up @@ -101,6 +103,8 @@ _pixman_black_image (void)
{
pixman_image_t *image;

TRACE ((stderr, "%s\n", __FUNCTION__));

image = __pixman_black_image;
if (unlikely (image == NULL)) {
pixman_color_t color;
Expand Down Expand Up @@ -131,6 +135,8 @@ _pixman_white_image (void)
{
pixman_image_t *image;

TRACE ((stderr, "%s\n", __FUNCTION__));

image = __pixman_white_image;
if (unlikely (image == NULL)) {
pixman_color_t color;
Expand Down Expand Up @@ -175,18 +181,21 @@ static int n_cached;
static pixman_image_t *
_pixman_transparent_image (void)
{
TRACE ((stderr, "%s\n", __FUNCTION__));
return _pixman_image_for_color (CAIRO_COLOR_TRANSPARENT);
}

static pixman_image_t *
_pixman_black_image (void)
{
TRACE ((stderr, "%s\n", __FUNCTION__));
return _pixman_image_for_color (CAIRO_COLOR_BLACK);
}

static pixman_image_t *
_pixman_white_image (void)
{
TRACE ((stderr, "%s\n", __FUNCTION__));
return _pixman_image_for_color (CAIRO_COLOR_WHITE);
}
#endif /* !PIXMAN_HAS_ATOMIC_OPS */
Expand Down Expand Up @@ -294,6 +303,8 @@ _pixman_image_for_gradient (const cairo_gradient_pattern_t *pattern,
unsigned int i;
cairo_int_status_t status;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (pattern->n_stops > ARRAY_LENGTH(pixman_stops_static)) {
pixman_stops = _cairo_malloc_ab (pattern->n_stops,
sizeof(pixman_gradient_stop_t));
Expand Down Expand Up @@ -384,6 +395,8 @@ _pixman_image_for_mesh (const cairo_mesh_pattern_t *pattern,
pixman_image_t *image;
int width, height;

TRACE ((stderr, "%s\n", __FUNCTION__));

*tx = -extents->x;
*ty = -extents->y;
width = extents->width;
Expand Down Expand Up @@ -437,6 +450,8 @@ _pixel_to_solid (cairo_image_surface_t *image, int x, int y)
uint32_t pixel;
pixman_color_t color;

TRACE ((stderr, "%s\n", __FUNCTION__));

switch (image->format) {
default:
case CAIRO_FORMAT_INVALID:
Expand Down Expand Up @@ -607,6 +622,8 @@ _pixman_image_for_recording (cairo_image_surface_t *dst,
cairo_matrix_t *m, matrix;
int tx = 0, ty = 0;

TRACE ((stderr, "%s\n", __FUNCTION__));

*ix = *iy = 0;

source = _cairo_pattern_get_source (pattern, &limit);
Expand Down Expand Up @@ -707,6 +724,8 @@ _pixman_image_for_surface (cairo_image_surface_t *dst,
cairo_extend_t extend = pattern->base.extend;
pixman_image_t *pixman_image;

TRACE ((stderr, "%s\n", __FUNCTION__));

*ix = *iy = 0;
pixman_image = NULL;
if (pattern->surface->type == CAIRO_SURFACE_TYPE_RECORDING)
Expand Down Expand Up @@ -915,6 +934,8 @@ _pixman_image_for_raster (cairo_image_surface_t *dst,
cairo_status_t status;
cairo_surface_t *surface;

TRACE ((stderr, "%s\n", __FUNCTION__));

*ix = *iy = 0;

surface = _cairo_raster_source_pattern_acquire (&pattern->base,
Expand Down Expand Up @@ -977,6 +998,8 @@ _pixman_image_for_pattern (cairo_image_surface_t *dst,
{
*tx = *ty = 0;

TRACE ((stderr, "%s\n", __FUNCTION__));

if (pattern == NULL)
return _pixman_white_image ();

Expand Down Expand Up @@ -1034,6 +1057,8 @@ _cairo_image_source_create_for_pattern (cairo_surface_t *dst,
{
cairo_image_source_t *source;

TRACE ((stderr, "%s\n", __FUNCTION__));

source = malloc (sizeof (cairo_image_source_t));
if (unlikely (source == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
Expand Down
9 changes: 9 additions & 0 deletions src/cairo-image-surface-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct _cairo_image_surface {

pixman_image_t *pixman_image;
const cairo_compositor_t *compositor;
cairo_surface_t *parent;

pixman_format_code_t pixman_format;
cairo_format_t format;
Expand All @@ -64,6 +65,7 @@ struct _cairo_image_surface {
unsigned transparency : 2;
unsigned color : 2;
};
#define to_image_surface(S) ((cairo_image_surface_t *)(S))

/* A wrapper for holding pixman images returned by create_for_pattern */
typedef struct _cairo_image_source {
Expand Down Expand Up @@ -201,6 +203,13 @@ _pixman_image_add_tristrip (pixman_image_t *image,
int dst_x, int dst_y,
cairo_tristrip_t *strip);

static inline void
_cairo_image_surface_set_parent (cairo_image_surface_t *image,
cairo_surface_t *parent)
{
image->parent = parent;
}

/**
* _cairo_surface_is_image:
* @surface: a #cairo_surface_t
Expand Down
Loading

0 comments on commit ae33198

Please sign in to comment.