Nikolay Sivov : d2d1/commandlist: Implement DrawBitmap() command.
Alexandre Julliard
julliard at winehq.org
Wed Aug 3 15:30:40 CDT 2022
Module: wine
Branch: master
Commit: da9eabd64d758c98f22a9d6299291bdce50adfbb
URL: https://gitlab.winehq.org/wine/wine/-/commit/da9eabd64d758c98f22a9d6299291bdce50adfbb
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Aug 3 00:07:12 2022 +0300
d2d1/commandlist: Implement DrawBitmap() command.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d2d1/command_list.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
dlls/d2d1/d2d1_private.h | 3 +++
dlls/d2d1/device.c | 24 ++++++++++++++----------
dlls/d2d1/tests/d2d1.c | 1 -
4 files changed, 64 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/command_list.c b/dlls/d2d1/command_list.c
index 59059f21f44..a8faeb01eb8 100644
--- a/dlls/d2d1/command_list.c
+++ b/dlls/d2d1/command_list.c
@@ -34,6 +34,7 @@ enum d2d_command_type
D2D_COMMAND_DRAW_LINE,
D2D_COMMAND_DRAW_GEOMETRY,
D2D_COMMAND_DRAW_RECTANGLE,
+ D2D_COMMAND_DRAW_BITMAP,
D2D_COMMAND_FILL_GEOMETRY,
D2D_COMMAND_FILL_RECTANGLE,
D2D_COMMAND_PUSH_CLIP,
@@ -153,6 +154,17 @@ struct d2d_command_draw_glyph_run
DWRITE_GLYPH_RUN_DESCRIPTION *run_desc;
};
+struct d2d_command_draw_bitmap
+{
+ struct d2d_command c;
+ float opacity;
+ D2D1_INTERPOLATION_MODE interpolation_mode;
+ ID2D1Bitmap *bitmap;
+ D2D1_RECT_F *dst_rect;
+ D2D1_RECT_F *src_rect;
+ D2D1_MATRIX_4X4_F *perspective_transform;
+};
+
static inline struct d2d_command_list *impl_from_ID2D1CommandList(ID2D1CommandList *iface)
{
return CONTAINING_RECORD(iface, struct d2d_command_list, ID2D1CommandList_iface);
@@ -314,6 +326,13 @@ static HRESULT STDMETHODCALLTYPE d2d_command_list_Stream(ID2D1CommandList *iface
c->stroke_style);
break;
}
+ case D2D_COMMAND_DRAW_BITMAP:
+ {
+ const struct d2d_command_draw_bitmap *c = data;
+ hr = ID2D1CommandSink_DrawBitmap(sink, c->bitmap, c->dst_rect, c->opacity,
+ c->interpolation_mode, c->src_rect, c->perspective_transform);
+ break;
+ }
case D2D_COMMAND_FILL_GEOMETRY:
{
const struct d2d_command_fill_geometry *c = data;
@@ -819,3 +838,31 @@ void d2d_command_list_draw_glyph_run(struct d2d_command_list *command_list,
command->origin = origin;
command->measuring_mode = measuring_mode;
}
+
+void d2d_command_list_draw_bitmap(struct d2d_command_list *command_list, ID2D1Bitmap *bitmap,
+ const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
+ const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform)
+{
+ struct d2d_command_draw_bitmap *command;
+ size_t size;
+ BYTE *data;
+
+ size = sizeof(*command);
+ if (dst_rect) size += sizeof(*dst_rect);
+ if (src_rect) size += sizeof(*src_rect);
+ if (perspective_transform) size += sizeof(*perspective_transform);
+
+ d2d_command_list_reference_object(command_list, bitmap);
+
+ command = d2d_command_list_require_space(command_list, size);
+ command->c.op = D2D_COMMAND_DRAW_BITMAP;
+ command->bitmap = bitmap;
+ command->opacity = opacity;
+ command->interpolation_mode = interpolation_mode;
+
+ data = (BYTE *)(command + 1);
+
+ d2d_command_list_write_field(&data, &command->dst_rect, dst_rect, sizeof(*dst_rect));
+ d2d_command_list_write_field(&data, &command->src_rect, src_rect, sizeof(*src_rect));
+ d2d_command_list_write_field(&data, &command->perspective_transform, perspective_transform, sizeof(*perspective_transform));
+}
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index df25ebfa5b6..5675509d520 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -765,6 +765,9 @@ void d2d_command_list_draw_glyph_run(struct d2d_command_list *command_list,
const struct d2d_device_context *context, D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run,
const DWRITE_GLYPH_RUN_DESCRIPTION *run_desc, ID2D1Brush *orig_brush,
DWRITE_MEASURING_MODE measuring_mode) DECLSPEC_HIDDEN;
+void d2d_command_list_draw_bitmap(struct d2d_command_list *command_list, ID2D1Bitmap *bitmap,
+ const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
+ const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
{
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 95d044be7df..64a4cae9d1b 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1181,12 +1181,14 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext1
if (context->target.type == D2D_TARGET_COMMAND_LIST)
{
- FIXME("Unimplemented for command list target.\n");
- return;
+ d2d_command_list_draw_bitmap(context->target.command_list, bitmap, dst_rect, opacity,
+ d2d1_1_interp_mode_from_d2d1(interpolation_mode), src_rect, NULL);
+ }
+ else
+ {
+ d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity,
+ d2d1_1_interp_mode_from_d2d1(interpolation_mode), src_rect, NULL, NULL);
}
-
- d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, d2d1_1_interp_mode_from_d2d1(interpolation_mode),
- src_rect, NULL, NULL);
}
static void STDMETHODCALLTYPE d2d_device_context_DrawText(ID2D1DeviceContext1 *iface,
@@ -2498,12 +2500,14 @@ static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(I
if (context->target.type == D2D_TARGET_COMMAND_LIST)
{
- FIXME("Unimplemented for command list target.\n");
- return;
+ d2d_command_list_draw_bitmap(context->target.command_list, bitmap, dst_rect, opacity, interpolation_mode,
+ src_rect, perspective_transform);
+ }
+ else
+ {
+ d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect,
+ NULL, perspective_transform);
}
-
- d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect,
- NULL, perspective_transform);
}
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_PushLayer(ID2D1DeviceContext1 *iface,
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index f66f3389d3c..665c3200e21 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -9501,7 +9501,6 @@ static void test_command_list(BOOL d3d11)
ID2D1RenderTarget_DrawBitmap(rt, bitmap, NULL, 0.25f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL);
refcount = ID2D1Bitmap_Release(bitmap);
- todo_wine
ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
/* Solid color brush. */
More information about the wine-cvs
mailing list