From: buliabyak Date: Sun, 31 Aug 2008 20:04:13 +0000 (+0000) Subject: properly transform clippath: transform of the item using the clippath must also be... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf7069a487ba218c4542e4adc5497ebd746ab929;p=inkscape.git properly transform clippath: transform of the item using the clippath must also be applied --- diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index e92418085..d3d4ddd56 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -55,6 +55,7 @@ struct CairoRenderState { unsigned int parent_has_userspace : 1; // whether the parent's ctm should be applied float opacity; bool has_filtereffect; + Geom::Matrix item_transform; // this item's item->transform, for correct clipping SPClipPath *clip_path; SPMask* mask; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 8d4b95f85..be9953ae1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -586,6 +586,7 @@ CairoRenderer::setStateForItem(CairoRenderContext *ctx, SPItem const *item) CairoRenderState *state = ctx->getCurrentState(); state->clip_path = item->clip_ref->getObject(); state->mask = item->mask_ref->getObject(); + state->item_transform = Geom::Matrix (item->transform); // If parent_has_userspace is true the parent state's transform // has to be used for the mask's/clippath's context. @@ -696,7 +697,17 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { SPItem *item = SP_ITEM(child); - renderItem(ctx, item); + + // combine transform of the item in clippath and the item using clippath: + Geom::Matrix tempmat (item->transform); + tempmat = tempmat * (ctx->getCurrentState()->item_transform); + + // render this item in clippath + ctx->pushState(); + ctx->transform(&tempmat); + setStateForItem(ctx, item); + sp_item_invoke_render(item, ctx); + ctx->popState(); } } TRACE(("END clip\n"));