diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-28 15:23:49 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-07-02 17:20:46 -0400 |
commit | 38f86f4e3587edd71f656c10705fd64a15d08f8a (patch) | |
tree | 13194f288873e40198018c4f27b464fa82208c8e | |
parent | 552b3441b5bef8f9481b216bd1f2104b260d2f3c (diff) |
wip
-rw-r--r-- | common/Makefile.am | 2 | ||||
-rw-r--r-- | common/canvas_base.c | 74 | ||||
-rw-r--r-- | common/canvas_base.h | 1 | ||||
-rw-r--r-- | common/draw.h | 25 | ||||
-rw-r--r-- | common/messages.h | 5 | ||||
-rw-r--r-- | spice.proto | 21 | ||||
-rw-r--r-- | spice1.proto | 21 |
7 files changed, 148 insertions, 1 deletions
diff --git a/common/Makefile.am b/common/Makefile.am index 08c4b83..749ae96 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -115,7 +115,7 @@ generated_client_marshallers1.c: $(top_srcdir)/spice1.proto $(MARSHALLERS_DEPS) generated_server_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --server --include messages.h $< $@ >/dev/null -STRUCTS = -M String -M Rect -M Point -M DisplayBase -M Fill -M Opaque -M Copy -M Blend -M Blackness -M Whiteness -M Invers -M Rop3 -M Stroke -M Text -M Transparent -M AlphaBlend +STRUCTS = -M String -M Rect -M Point -M DisplayBase -M Fill -M Opaque -M Copy -M Blend -M Blackness -M Whiteness -M Invers -M Rop3 -M Stroke -M Text -M Transparent -M AlphaBlend -M Composite generated_server_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include messages.h $< $@ >/dev/null diff --git a/common/canvas_base.c b/common/canvas_base.c index c60c5cf..24e69b4 100644 --- a/common/canvas_base.c +++ b/common/canvas_base.c @@ -3232,6 +3232,79 @@ static void canvas_draw_rop3(SpiceCanvas *spice_canvas, SpiceRect *bbox, pixman_region32_fini(&dest_region); } +static void transform_to_pixman_transform(SpiceTransform *transform, + pixman_transform_t *p) +{ + p->matrix[0][0] = transform->t00; + p->matrix[0][1] = transform->t01; + p->matrix[0][2] = transform->t02; + p->matrix[1][0] = transform->t10; + p->matrix[1][1] = transform->t11; + p->matrix[1][2] = transform->t12; + p->matrix[2][0] = 0; + p->matrix[2][1] = 0; + p->matrix[2][2] = pixman_fixed_1; +} + +static void canvas_draw_composite(SpiceCanvas *spice_canvas, SpiceRect *bbox, + SpiceClip *clip, SpiceComposite *composite) +{ + CanvasBase *canvas = (CanvasBase *)spice_canvas; + SpiceCanvas *surface_canvas; + pixman_region32_t dest_region; + pixman_image_t *d; + pixman_image_t *s; + pixman_image_t *m; + pixman_transform_t transform; + int width; + int heigth; + + pixman_region32_init_rect(&dest_region, + bbox->left, bbox->top, + bbox->right - bbox->left, + bbox->bottom - bbox->top); + + canvas_clip_pixman(canvas, &dest_region, clip); + + width = bbox->right - bbox->left; + heigth = bbox->bottom - bbox->top; + + d = canvas_get_image_from_self(spice_canvas, bbox->left, bbox->top, width, heigth); + surface_canvas = canvas_get_surface(canvas, composite->src_bitmap); + if (surface_canvas) { + s = surface_canvas->ops->get_image(surface_canvas); + } else { + s = canvas_get_image(canvas, composite->src_bitmap, FALSE); + } + + transform_to_pixman_transform (&composite->src_transform, &transform); + pixman_image_set_transform (s, &transform); + pixman_image_set_repeat (s, (pixman_repeat_t)composite->src_repeat); + pixman_image_set_filter (s, (pixman_filter_t)composite->src_filter, NULL, 0); + + m = NULL; + if (composite->mask_bitmap) { + surface_canvas = canvas_get_surface(canvas, composite->mask_bitmap); + if (surface_canvas) { + m = surface_canvas->ops->get_image(surface_canvas); + } else { + m = canvas_get_image(canvas, composite->mask_bitmap, FALSE); + } + + transform_to_pixman_transform (&composite->mask_transform, &transform); + pixman_image_set_transform (m, &transform); + pixman_image_set_repeat (m, (pixman_repeat_t)composite->mask_repeat); + pixman_image_set_filter (m, (pixman_filter_t)composite->mask_filter, NULL, 0); + pixman_image_set_component_alpha (m, (pixman_bool_t)composite->component_alpha); + } + + pixman_image_unref(s); + pixman_image_unref(m); + pixman_image_unref(d); + + pixman_region32_fini(&dest_region); +} + static void canvas_copy_bits(SpiceCanvas *spice_canvas, SpiceRect *bbox, SpiceClip *clip, SpicePoint *src_pos) { CanvasBase *canvas = (CanvasBase *)spice_canvas; @@ -3319,6 +3392,7 @@ inline static void canvas_base_init_ops(SpiceCanvasOps *ops) ops->draw_alpha_blend = canvas_draw_alpha_blend; ops->draw_stroke = canvas_draw_stroke; ops->draw_rop3 = canvas_draw_rop3; + ops->draw_composite = canvas_draw_composite; ops->group_start = canvas_base_group_start; ops->group_end = canvas_base_group_end; } diff --git a/common/canvas_base.h b/common/canvas_base.h index bdf12a1..4a4b083 100644 --- a/common/canvas_base.h +++ b/common/canvas_base.h @@ -133,6 +133,7 @@ typedef struct { void (*draw_text)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceText *text); void (*draw_stroke)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceStroke *stroke); void (*draw_rop3)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceRop3 *rop3); + void (*draw_composite)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceComposite *composite); void (*draw_blend)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceBlend *blend); void (*draw_blackness)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceBlackness *blackness); void (*draw_whiteness)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceWhiteness *whiteness); diff --git a/common/draw.h b/common/draw.h index 8fad0e5..5ab60c4 100644 --- a/common/draw.h +++ b/common/draw.h @@ -223,6 +223,31 @@ typedef struct SpiceRop3 { SpiceQMask mask; } SpiceRop3; +/* Given in 16.16 fixed point */ +typedef struct SpiceTransform { + uint32_t t00; + uint32_t t01; + uint32_t t02; + uint32_t t10; + uint32_t t11; + uint32_t t12; +} SpiceTransform; + +typedef struct SpiceComposite { + uint8_t op; + uint8_t src_filter; + uint8_t mask_filter; + uint8_t src_repeat; + uint8_t mask_repeat; + uint8_t component_alpha; + SpiceImage *src_bitmap; + SpiceImage *mask_bitmap; + SpiceTransform src_transform; + SpiceTransform mask_transform; + SpicePoint16 src_origin; + SpicePoint16 mask_origin; +} SpiceComposite; + typedef struct SpiceBlackness { SpiceQMask mask; } SpiceBlackness, SpiceInvers, SpiceWhiteness; diff --git a/common/messages.h b/common/messages.h index e3677d1..558685e 100644 --- a/common/messages.h +++ b/common/messages.h @@ -253,6 +253,11 @@ typedef struct SpiceMsgDisplayDrawAlphaBlend { SpiceAlphaBlend data; } SpiceMsgDisplayDrawAlphaBlend; +typedef struct SpiceMsgDisplayDrawComposite { + SpiceMsgDisplayBase base; + SpiceComposite data; +} SpiceMsgDisplayDrawComposite; + typedef struct SpiceMsgDisplayCopyBits { SpiceMsgDisplayBase base; SpicePoint src_pos; diff --git a/spice.proto b/spice.proto index 8dda736..fa4c37b 100644 --- a/spice.proto +++ b/spice.proto @@ -26,6 +26,15 @@ struct Rect { int32 right; }; +struct Transform { + uint32 t00; + uint32 t01; + uint32 t02; + uint32 t10; + uint32 t11; + uint32 t12; +}; + enum32 link_err { OK, ERROR, @@ -736,6 +745,18 @@ channel DisplayChannel : BaseChannel { } draw_rop3; message { + DisplayBase base; + struct Composite { + Image *src_bitmap; + Image *mask_bitmap; + Transform *src_transform; + Transform *mask_transform; + Point16 src_origin; + Point16 mask_origin; + } data; + } draw_composite; + + message { DisplayBase base; struct Stroke { Path *path @marshall @nonnull; diff --git a/spice1.proto b/spice1.proto index 2ed1058..00f4be5 100644 --- a/spice1.proto +++ b/spice1.proto @@ -26,6 +26,15 @@ struct Rect { int32 right; }; +struct Transform { + uint32 t00; + uint32 t01; + uint32 t02; + uint32 t10; + uint32 t11; + uint32 t12; +}; + enum32 link_err { OK, ERROR, @@ -680,6 +689,18 @@ channel DisplayChannel : BaseChannel { } draw_rop3; message { + DisplayBase base; + struct Composite { + Image *src_bitmap; + Image *mask_bitmap; + Transform *src_transform; + Transform *mask_transform; + Point16 src_origin; + Point16 mask_origin; + } data; + } draw_composite; + + message { DisplayBase base; struct Stroke { Path *path; |