From ecb002af4a359d4e791524c79e2b2bafae0cf792 Mon Sep 17 00:00:00 2001 From: zhangjipeng Date: Thu, 25 Apr 2024 17:43:05 +0800 Subject: [PATCH] change device clip to scissor --- include/picasso.h | 6 +++--- src/picasso_api.cpp | 17 ++--------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/picasso.h b/include/picasso.h index e7e9fc7..72d6c87 100644 --- a/include/picasso.h +++ b/include/picasso.h @@ -1820,12 +1820,12 @@ PEXPORT void PICAPI ps_clip_path(ps_context* ctx, const ps_path* path, ps_fill_r * \param ctx Pointer to an existing context object. * \param rect The rectangle which will be clipped. * - * \sa ps_clip, ps_clip_path, ps_clip_rects, ps_reset_clip, ps_clip_device_rect + * \sa ps_clip, ps_clip_path, ps_clip_rects, ps_reset_clip, ps_scissor_rect */ PEXPORT void PICAPI ps_clip_rect(ps_context* ctx, const ps_rect* rect); /** - * \fn void ps_clip_device_rect(ps_context* ctx, const ps_rect* rect) + * \fn void ps_scissor_rect(ps_context* ctx, const ps_rect* rect) * \brief The fast way to clipping specified rectangle, the clip rect can not be rotated * by world matrix. (Deprecated) * @@ -1836,7 +1836,7 @@ PEXPORT void PICAPI ps_clip_rect(ps_context* ctx, const ps_rect* rect); * * \sa ps_clip, ps_clip_path, ps_clip_rects, ps_reset_clip, ps_clip_rect */ -PEXPORT void PICAPI ps_clip_device_rect(ps_context* ctx, const ps_rect* rect); +PEXPORT void PICAPI ps_scissor_rect(ps_context* ctx, const ps_rect* rect); /** * \fn void ps_clip_rects(ps_context* ctx, const ps_rect* rects, unsigned int num_rects) diff --git a/src/picasso_api.cpp b/src/picasso_api.cpp index 55132d7..ab4cd2c 100644 --- a/src/picasso_api.cpp +++ b/src/picasso_api.cpp @@ -1453,7 +1453,7 @@ void PICAPI ps_clip_path(ps_context* ctx, const ps_path* p, ps_fill_rule r) global_status = STATUS_SUCCEED; } -void PICAPI ps_clip_device_rect(ps_context* ctx, const ps_rect* r) +void PICAPI ps_scissor_rect(ps_context* ctx, const ps_rect* r) { if (!picasso::is_valid_system_device()) { global_status = STATUS_DEVICE_ERROR; @@ -1470,21 +1470,8 @@ void PICAPI ps_clip_device_rect(ps_context* ctx, const ps_rect* r) FLT_TO_SCALAR(r->x + r->w), FLT_TO_SCALAR(r->y + r->h)); - picasso::trans_affine mtx = ctx->state->world_matrix; - scalar rotate = mtx.rotation(); - mtx.rotate(-rotate); //not support rotation - mtx.transform(&(tr.x1), &(tr.y1)); - mtx.transform(&(tr.x2), &(tr.y2)); - - if (ctx->state->clip.type == picasso::clip_device) { //clip device rect. - picasso::rect_s cr = ctx->state->clip.rect; - if (cr.clip(tr)) { - ctx->state->clip.rect = cr; - } - } else { - ctx->state->clip.rect = tr; - } ctx->state->clip.type = picasso::clip_device; + ctx->state->clip.rect = tr; ctx->canvas->p->render_clip(ctx->state, true); global_status = STATUS_SUCCEED; }