Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/d2d1_1.idl | 124 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-)
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl index c6cd9c7398..4a644ffd4c 100644 --- a/include/d2d1_1.idl +++ b/include/d2d1_1.idl @@ -32,7 +32,6 @@ interface ID2D1Effect; interface ID2D1GradientStopCollection1; interface ID2D1ImageBrush; interface ID2D1BitmapBrush1; -interface ID2D1CommandList;
cpp_quote("#ifndef __dwrite_h__") /* already defined in dwrite.h but needed for WIDL */ @@ -429,6 +428,129 @@ interface ID2D1Device : ID2D1Resource ); }
+[ + object, + uuid(54d7898a-a061-40a7-bec7-e465bcba2c4f), + local, +] +interface ID2D1CommandSink : IUnknown +{ + HRESULT BeginDraw(); + HRESULT EndDraw(); + HRESULT SetAntialiasMode( + [in] D2D1_ANTIALIAS_MODE antialias_mode + ); + HRESULT SetTags( + [in] D2D1_TAG tag1, + [in] D2D1_TAG tag2 + ); + HRESULT SetTextAntialiasMode( + [in] D2D1_TEXT_ANTIALIAS_MODE antialias_mode + ); + HRESULT SetTextRenderingParams( + [in] IDWriteRenderingParams *text_rendering_params + ); + HRESULT SetTransform( + [in] D2D1_MATRIX_3X2_F *transform + ); + HRESULT SetPrimitiveBlend( + [in] D2D1_PRIMITIVE_BLEND primitive_blend + ); + HRESULT SetUnitMode( + [in] D2D1_UNIT_MODE unit_mode + ); + HRESULT Clear( + [in] const D2D1_COLOR_F *color + ); + HRESULT DrawGlyphRun( + [in] D2D1_POINT_2F baseline_origin, + [in] const DWRITE_GLYPH_RUN *glyph_run, + [in] const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, + [in] ID2D1Brush *brush, + [in] DWRITE_MEASURING_MODE measuring_mode + ); + HRESULT DrawLine( + [in] D2D1_POINT_2F p0, + [in] D2D1_POINT_2F p1, + [in] ID2D1Brush *brush, + [in] float stroke_width, + [in] ID2D1StrokeStyle *stroke_style + ); + HRESULT DrawGeometry( + [in] ID2D1Geometry *geometry, + [in] ID2D1Brush *brush, + [in] float stroke_width, + [in] ID2D1StrokeStyle *stroke_style + ); + HRESULT DrawRectangle( + [in] const D2D1_RECT_F *rect, + [in] ID2D1Brush *brush, + [in] float stroke_width, + [in] ID2D1StrokeStyle *stroke_style + ); + HRESULT DrawBitmap( + [in] ID2D1Bitmap *bitmap, + [in] const D2D1_RECT_F *dst_rect, + [in] float opacity, + [in] D2D1_INTERPOLATION_MODE interpolation_mode, + [in] const D2D1_RECT_F *src_rect, + [in] const D2D1_MATRIX_4X4_F *perspective_transform + ); + HRESULT DrawImage( + [in] ID2D1Image *image, + [in] const D2D1_POINT_2F *target_offset, + [in] const D2D1_POINT_2F *image_rect, + [in] D2D1_INTERPOLATION_MODE interpolation_mode, + [in] D2D1_COMPOSITE_MODE composite_mode + ); + HRESULT DrawGdiMetafile( + [in] ID2D1GdiMetafile *metafile, + [in] const D2D1_POINT_2F *target_offset + ); + HRESULT FillMesh( + [in] ID2D1Mesh *mesh, + [in] ID2D1Brush *brush + ); + HRESULT FillOpacityMask( + [in] ID2D1Bitmap *bitmap, + [in] ID2D1Brush *brush, + [in] const D2D1_RECT_F *dst_rect, + [in] const D2D1_RECT_F *src_rect + ); + HRESULT FillGeometry( + [in] ID2D1Geometry *geometry, + [in] ID2D1Brush *brush, + [in] ID2D1Brush *opacity_brush + ); + HRESULT FillRectangle( + [in] const D2D1_RECT_F *rect, + [in] ID2D1Brush *brush + ); + HRESULT PushAxisAlignedClip( + [in] const D2D1_RECT_F *clip_rect, + [in] D2D1_ANTIALIAS_MODE antialias_mode + ); + HRESULT PushLayer( + [in] const D2D1_LAYER_PARAMETERS1 *layer_parameters, + [in] ID2D1Layer *layer + ); + HRESULT PopAxisAlignedClip(); + HRESULT PopLayer(); +} + +[ + object, + uuid(b4f34a19-2383-4d76-94f6-ec343657c3dc), + local, +] +interface ID2D1CommandList : ID2D1Image +{ + HRESULT Stream( + [in] ID2D1CommandSink *sink + ); + HRESULT Close(); +} + [ object, uuid(e8f7fe7a-191c-466d-ad95-975678bda998),
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index feebeff8d0..d00fba1b41 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -6599,7 +6599,17 @@ todo_wine ok(hr == WINCODEC_ERR_ALREADYLOCKED, "Expected bitmap to be locked, hr %#x.\n", hr); if (SUCCEEDED(hr)) IWICBitmapLock_Release(wic_lock); - ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "EndDraw() failed, hr %#x.\n", hr); + + /* Lock before BeginDraw(). */ + hr = IWICBitmap_Lock(wic_bitmap, NULL, WICBitmapLockRead, &wic_lock); + ok(SUCCEEDED(hr), "Expected bitmap to be unlocked, hr %#x.\n", hr); + ID2D1RenderTarget_BeginDraw(rt); + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); +todo_wine + ok(hr == WINCODEC_ERR_ALREADYLOCKED, "Unexpected hr %#x.\n", hr); + IWICBitmapLock_Release(wic_lock);
ID2D1GdiInteropRenderTarget_Release(interop); ID2D1RenderTarget_Release(rt);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/device.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 967b90d038..45b22584cb 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1804,9 +1804,16 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBit ID2D1DeviceContext *iface, IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap) { - FIXME("iface %p, bitmap_source %p, desc %p, bitmap %p stub!\n", iface, bitmap_source, desc, bitmap); + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + struct d2d_bitmap *object; + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n", iface, bitmap_source, desc, bitmap); + + if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc, &object))) + *bitmap = &object->ID2D1Bitmap1_iface; + + return hr; }
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContext(ID2D1DeviceContext *iface,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/d2d1.spec | 2 +- dlls/d2d1/factory.c | 18 ++++++++++++++++++ dlls/d2d1/tests/d2d1.c | 39 +++++++++++++++++++++++++++++++++++++++ include/d2d1.idl | 1 + 4 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/d2d1.spec b/dlls/d2d1/d2d1.spec index 3443b29505..fff6f1c9c8 100644 --- a/dlls/d2d1/d2d1.spec +++ b/dlls/d2d1/d2d1.spec @@ -1,6 +1,6 @@ @ stdcall D2D1CreateFactory(long ptr ptr ptr) @ stdcall D2D1MakeRotateMatrix(float float float ptr) -@ stub D2D1MakeSkewMatrix +@ stdcall D2D1MakeSkewMatrix(float float float float ptr) @ stdcall D2D1IsMatrixInvertible(ptr) @ stdcall D2D1InvertMatrix(ptr) @ stub D2D1ConvertColorSpace diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index 2459b58c03..8d9d8c324b 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -592,6 +592,24 @@ void WINAPI D2D1MakeRotateMatrix(float angle, D2D1_POINT_2F center, D2D1_MATRIX_ matrix->_32 = center.y - center.x * sin_theta - center.y * cos_theta; }
+void WINAPI D2D1MakeSkewMatrix(float angle_x, float angle_y, D2D1_POINT_2F center, D2D1_MATRIX_3X2_F *matrix) +{ + float tan_x, tan_y; + + TRACE("angle_x %.8e, angle_y %.8e, center %s, matrix %p.\n", angle_x, angle_y, debug_d2d_point_2f(¢er), matrix); + + tan_x = tan(angle_x * (M_PI / 180.0f)); + tan_y = tan(angle_y * (M_PI / 180.0f)); + + /* translate(-center) * skew() * translate(center) */ + matrix->_11 = 1.0f; + matrix->_12 = tan_y; + matrix->_21 = tan_x; + matrix->_22 = 1.0f; + matrix->_31 = -tan_x * center.y; + matrix->_32 = -tan_y * center.x; +} + BOOL WINAPI D2D1IsMatrixInvertible(const D2D1_MATRIX_3X2_F *matrix) { TRACE("matrix %p.\n", matrix); diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d00fba1b41..0bea1c80a8 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -7601,6 +7601,44 @@ static void test_invert_matrix(void) } }
+static void test_skew_matrix(void) +{ + static const struct + { + float angle_x; + float angle_y; + D2D1_POINT_2F center; + D2D1_MATRIX_3X2_F matrix; + } + skew_tests[] = + { + { 0.0f, 0.0f, { 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } }, + { 45.0f, 0.0f, { 0.0f, 0.0f }, { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f } }, + { 0.0f, 0.0f, { 10.0f, -3.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } }, + { -45.0f, 45.0f, { 0.1f, 0.5f }, { 1.0f, 1.0f, -1.0f, 1.0f, 0.5f, -0.1f } }, + { -45.0f, 45.0f, { 1.0f, 2.0f }, { 1.0f, 1.0f, -1.0f, 1.0f, 2.0f, -1.0f } }, + { 45.0f, -45.0f, { 1.0f, 2.0f }, { 1.0f, -1.0f, 1.0f, 1.0f, -2.0f, 1.0f } }, + { 30.0f, -60.0f, { 12.0f, -5.0f }, { 1.0f, -1.7320509f, 0.577350259f, 1.0f, 2.88675117f, 20.7846107f } }, + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(skew_tests); ++i) + { + const D2D1_MATRIX_3X2_F *expected = &skew_tests[i].matrix; + D2D1_MATRIX_3X2_F m; + BOOL ret; + + D2D1MakeSkewMatrix(skew_tests[i].angle_x, skew_tests[i].angle_y, skew_tests[i].center, &m); + ret = compare_float(m._11, expected->_11, 3) && compare_float(m._12, expected->_12, 3) + && compare_float(m._21, expected->_21, 3) && compare_float(m._22, expected->_22, 3) + && compare_float(m._31, expected->_31, 3) && compare_float(m._32, expected->_32, 3); + + ok(ret, "%u: unexpected matrix value {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, expected " + "{%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", i, m._11, m._12, m._21, m._22, m._31, m._32, + expected->_11, expected->_12, expected->_21, expected->_22, expected->_31, expected->_32); + } +} + START_TEST(d2d1) { unsigned int argc, i; @@ -7643,6 +7681,7 @@ START_TEST(d2d1) queue_test(test_bitmap_surface); queue_test(test_device_context); queue_test(test_invert_matrix); + queue_test(test_skew_matrix);
run_queued_tests(); } diff --git a/include/d2d1.idl b/include/d2d1.idl index ff2dc03cfd..c9fb8f0b6b 100644 --- a/include/d2d1.idl +++ b/include/d2d1.idl @@ -1257,3 +1257,4 @@ interface ID2D1Factory : IUnknown [local] BOOL __stdcall D2D1InvertMatrix(D2D1_MATRIX_3X2_F *matrix); [local] BOOL __stdcall D2D1IsMatrixInvertible(const D2D1_MATRIX_3X2_F *matrix); [local] void __stdcall D2D1MakeRotateMatrix(float angle, D2D1_POINT_2F center, D2D1_MATRIX_3X2_F *matrix); +[local] void __stdcall D2D1MakeSkewMatrix(float angle_x, float angle_y, D2D1_POINT_2F center, D2D1_MATRIX_3X2_F *matrix);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Wed, 3 Oct 2018 at 09:24, Nikolay Sivov nsivov@codeweavers.com wrote:
- static const struct
- {
float angle_x;
float angle_y;
D2D1_POINT_2F center;
D2D1_MATRIX_3X2_F matrix;
- }
- skew_tests[] =
- {
{ 0.0f, 0.0f, { 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } },
{ 45.0f, 0.0f, { 0.0f, 0.0f }, { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f } },
{ 0.0f, 0.0f, { 10.0f, -3.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } },
{ -45.0f, 45.0f, { 0.1f, 0.5f }, { 1.0f, 1.0f, -1.0f, 1.0f, 0.5f, -0.1f } },
{ -45.0f, 45.0f, { 1.0f, 2.0f }, { 1.0f, 1.0f, -1.0f, 1.0f, 2.0f, -1.0f } },
{ 45.0f, -45.0f, { 1.0f, 2.0f }, { 1.0f, -1.0f, 1.0f, 1.0f, -2.0f, 1.0f } },
{ 30.0f, -60.0f, { 12.0f, -5.0f }, { 1.0f, -1.7320509f, 0.577350259f, 1.0f, 2.88675117f, 20.7846107f } },
- };
What happens for angle_x/angle_y 90.0f?