d2d1/commandlist: Implement clipping commands recording.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2022-08-01 16:05:26 +03:00 committed by Alexandre Julliard
parent 94c51a83f2
commit eba21e7502
3 changed files with 42 additions and 8 deletions

View file

@ -28,6 +28,8 @@ enum d2d_command_type
D2D_COMMAND_SET_TRANSFORM,
D2D_COMMAND_SET_PRIMITIVE_BLEND,
D2D_COMMAND_SET_UNIT_MODE,
D2D_COMMAND_PUSH_CLIP,
D2D_COMMAND_POP_CLIP,
};
struct d2d_command
@ -72,6 +74,13 @@ struct d2d_command_set_unit_mode
D2D1_UNIT_MODE mode;
};
struct d2d_command_push_clip
{
struct d2d_command c;
D2D1_RECT_F rect;
D2D1_ANTIALIAS_MODE mode;
};
static inline struct d2d_command_list *impl_from_ID2D1CommandList(ID2D1CommandList *iface)
{
return CONTAINING_RECORD(iface, struct d2d_command_list, ID2D1CommandList_iface);
@ -190,6 +199,15 @@ static HRESULT STDMETHODCALLTYPE d2d_command_list_Stream(ID2D1CommandList *iface
hr = ID2D1CommandSink_SetUnitMode(sink, c->mode);
break;
}
case D2D_COMMAND_PUSH_CLIP:
{
const struct d2d_command_push_clip *c = data;
hr = ID2D1CommandSink_PushAxisAlignedClip(sink, &c->rect, c->mode);
break;
}
case D2D_COMMAND_POP_CLIP:
hr = ID2D1CommandSink_PopAxisAlignedClip(sink);
break;
default:
FIXME("Unhandled command %u.\n", command->op);
hr = E_UNEXPECTED;
@ -343,3 +361,22 @@ void d2d_command_list_begin_draw(struct d2d_command_list *command_list,
command_list->state = D2D_COMMAND_LIST_STATE_OPEN;
}
void d2d_command_list_push_clip(struct d2d_command_list *command_list, const D2D1_RECT_F *rect,
D2D1_ANTIALIAS_MODE mode)
{
struct d2d_command_push_clip *command;
command = d2d_command_list_require_space(command_list, sizeof(*command));
command->c.op = D2D_COMMAND_PUSH_CLIP;
command->rect = *rect;
command->mode = mode;
}
void d2d_command_list_pop_clip(struct d2d_command_list *command_list)
{
struct d2d_command *command;
command = d2d_command_list_require_space(command_list, sizeof(*command));
command->op = D2D_COMMAND_POP_CLIP;
}

View file

@ -738,6 +738,9 @@ void d2d_command_list_set_text_antialias_mode(struct d2d_command_list *command_l
void d2d_command_list_set_tags(struct d2d_command_list *command_list, D2D1_TAG tag1, D2D1_TAG tag2) DECLSPEC_HIDDEN;
void d2d_command_list_set_transform(struct d2d_command_list *command_list,
const D2D1_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
void d2d_command_list_push_clip(struct d2d_command_list *command_list, const D2D1_RECT_F *rect,
D2D1_ANTIALIAS_MODE antialias_mode) DECLSPEC_HIDDEN;
void d2d_command_list_pop_clip(struct d2d_command_list *command_list) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
{

View file

@ -1653,10 +1653,7 @@ static void STDMETHODCALLTYPE d2d_device_context_PushAxisAlignedClip(ID2D1Device
TRACE("iface %p, clip_rect %s, antialias_mode %#x.\n", iface, debug_d2d_rect_f(clip_rect), antialias_mode);
if (context->target.type == D2D_TARGET_COMMAND_LIST)
{
FIXME("Unimplemented for command list target.\n");
return;
}
d2d_command_list_push_clip(context->target.command_list, clip_rect, antialias_mode);
if (antialias_mode != D2D1_ANTIALIAS_MODE_ALIASED)
FIXME("Ignoring antialias_mode %#x.\n", antialias_mode);
@ -1687,10 +1684,7 @@ static void STDMETHODCALLTYPE d2d_device_context_PopAxisAlignedClip(ID2D1DeviceC
TRACE("iface %p.\n", iface);
if (context->target.type == D2D_TARGET_COMMAND_LIST)
{
FIXME("Unimplemented for command list target.\n");
return;
}
d2d_command_list_pop_clip(context->target.command_list);
d2d_clip_stack_pop(&context->clip_stack);
}