2 * Copyright 2014 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define D2D1_INIT_GUID
20 #include "d2d1_private.h"
22 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
23 WINE_DEFAULT_DEBUG_CHANNEL(d2d
);
25 struct d2d_settings d2d_settings
=
27 ~0u, /* No ID2D1Factory version limit by default. */
32 ID2D1Factory2 ID2D1Factory2_iface
;
35 ID3D10Device1
*device
;
41 static inline struct d2d_factory
*impl_from_ID2D1Factory2(ID2D1Factory2
*iface
)
43 return CONTAINING_RECORD(iface
, struct d2d_factory
, ID2D1Factory2_iface
);
46 static HRESULT
d2d_factory_reload_sysmetrics(struct d2d_factory
*factory
)
50 if (!(hdc
= GetDC(NULL
)))
52 factory
->dpi_x
= factory
->dpi_y
= 96.0f
;
56 factory
->dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
57 factory
->dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
64 static HRESULT STDMETHODCALLTYPE
d2d_factory_QueryInterface(ID2D1Factory2
*iface
, REFIID iid
, void **out
)
66 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
68 if ((IsEqualGUID(iid
, &IID_ID2D1Factory2
) && d2d_settings
.max_version_factory
>= 2)
69 || (IsEqualGUID(iid
, &IID_ID2D1Factory1
) && d2d_settings
.max_version_factory
>= 1)
70 || IsEqualGUID(iid
, &IID_ID2D1Factory
)
71 || IsEqualGUID(iid
, &IID_IUnknown
))
73 ID2D1Factory2_AddRef(iface
);
78 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
84 static ULONG STDMETHODCALLTYPE
d2d_factory_AddRef(ID2D1Factory2
*iface
)
86 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
87 ULONG refcount
= InterlockedIncrement(&factory
->refcount
);
89 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
94 static ULONG STDMETHODCALLTYPE
d2d_factory_Release(ID2D1Factory2
*iface
)
96 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
97 ULONG refcount
= InterlockedDecrement(&factory
->refcount
);
99 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
104 ID3D10Device1_Release(factory
->device
);
111 static HRESULT STDMETHODCALLTYPE
d2d_factory_ReloadSystemMetrics(ID2D1Factory2
*iface
)
113 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
115 TRACE("iface %p.\n", iface
);
117 return d2d_factory_reload_sysmetrics(factory
);
120 static void STDMETHODCALLTYPE
d2d_factory_GetDesktopDpi(ID2D1Factory2
*iface
, float *dpi_x
, float *dpi_y
)
122 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
124 TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface
, dpi_x
, dpi_y
);
126 *dpi_x
= factory
->dpi_x
;
127 *dpi_y
= factory
->dpi_y
;
130 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateRectangleGeometry(ID2D1Factory2
*iface
,
131 const D2D1_RECT_F
*rect
, ID2D1RectangleGeometry
**geometry
)
133 struct d2d_geometry
*object
;
136 TRACE("iface %p, rect %s, geometry %p.\n", iface
, debug_d2d_rect_f(rect
), geometry
);
138 if (!(object
= heap_alloc_zero(sizeof(*object
))))
139 return E_OUTOFMEMORY
;
141 if (FAILED(hr
= d2d_rectangle_geometry_init(object
, (ID2D1Factory
*)iface
, rect
)))
143 WARN("Failed to initialize rectangle geometry, hr %#x.\n", hr
);
148 TRACE("Created rectangle geometry %p.\n", object
);
149 *geometry
= (ID2D1RectangleGeometry
*)&object
->ID2D1Geometry_iface
;
154 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateRoundedRectangleGeometry(ID2D1Factory2
*iface
,
155 const D2D1_ROUNDED_RECT
*rect
, ID2D1RoundedRectangleGeometry
**geometry
)
157 FIXME("iface %p, rect %p, geometry %p stub!\n", iface
, rect
, geometry
);
162 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateEllipseGeometry(ID2D1Factory2
*iface
,
163 const D2D1_ELLIPSE
*ellipse
, ID2D1EllipseGeometry
**geometry
)
165 FIXME("iface %p, ellipse %p, geometry %p stub!\n", iface
, ellipse
, geometry
);
170 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateGeometryGroup(ID2D1Factory2
*iface
,
171 D2D1_FILL_MODE fill_mode
, ID2D1Geometry
**geometries
, UINT32 geometry_count
, ID2D1GeometryGroup
**group
)
173 struct d2d_geometry
*object
;
176 TRACE("iface %p, fill_mode %#x, geometries %p, geometry_count %u, group %p.\n",
177 iface
, fill_mode
, geometries
, geometry_count
, group
);
179 if (!(object
= heap_alloc_zero(sizeof(*object
))))
180 return E_OUTOFMEMORY
;
182 if (FAILED(hr
= d2d_geometry_group_init(object
, (ID2D1Factory
*)iface
, fill_mode
, geometries
, geometry_count
)))
184 WARN("Failed to initialize geometry group, hr %#x.\n", hr
);
189 TRACE("Created geometry group %p.\n", object
);
190 *group
= (ID2D1GeometryGroup
*)&object
->ID2D1Geometry_iface
;
195 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateTransformedGeometry(ID2D1Factory2
*iface
,
196 ID2D1Geometry
*src_geometry
, const D2D1_MATRIX_3X2_F
*transform
,
197 ID2D1TransformedGeometry
**transformed_geometry
)
199 struct d2d_geometry
*object
;
201 TRACE("iface %p, src_geometry %p, transform %p, transformed_geometry %p.\n",
202 iface
, src_geometry
, transform
, transformed_geometry
);
204 if (!(object
= heap_alloc_zero(sizeof(*object
))))
205 return E_OUTOFMEMORY
;
207 d2d_transformed_geometry_init(object
, (ID2D1Factory
*)iface
, src_geometry
, transform
);
209 TRACE("Created transformed geometry %p.\n", object
);
210 *transformed_geometry
= (ID2D1TransformedGeometry
*)&object
->ID2D1Geometry_iface
;
215 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreatePathGeometry(ID2D1Factory2
*iface
, ID2D1PathGeometry
**geometry
)
217 struct d2d_geometry
*object
;
219 TRACE("iface %p, geometry %p.\n", iface
, geometry
);
221 if (!(object
= heap_alloc_zero(sizeof(*object
))))
222 return E_OUTOFMEMORY
;
224 d2d_path_geometry_init(object
, (ID2D1Factory
*)iface
);
226 TRACE("Created path geometry %p.\n", object
);
227 *geometry
= (ID2D1PathGeometry
*)&object
->ID2D1Geometry_iface
;
232 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateStrokeStyle(ID2D1Factory2
*iface
,
233 const D2D1_STROKE_STYLE_PROPERTIES
*desc
, const float *dashes
, UINT32 dash_count
,
234 ID2D1StrokeStyle
**stroke_style
)
236 struct d2d_stroke_style
*object
;
239 TRACE("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p.\n",
240 iface
, desc
, dashes
, dash_count
, stroke_style
);
242 if (!(object
= heap_alloc_zero(sizeof(*object
))))
243 return E_OUTOFMEMORY
;
245 if (FAILED(hr
= d2d_stroke_style_init(object
, (ID2D1Factory
*)iface
, desc
, dashes
, dash_count
)))
247 WARN("Failed to initialize stroke style, hr %#x.\n", hr
);
252 TRACE("Created stroke style %p.\n", object
);
253 *stroke_style
= &object
->ID2D1StrokeStyle_iface
;
258 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateDrawingStateBlock(ID2D1Factory2
*iface
,
259 const D2D1_DRAWING_STATE_DESCRIPTION
*desc
, IDWriteRenderingParams
*text_rendering_params
,
260 ID2D1DrawingStateBlock
**state_block
)
262 D2D1_DRAWING_STATE_DESCRIPTION1 state_desc
;
263 struct d2d_state_block
*object
;
265 TRACE("iface %p, desc %p, text_rendering_params %p, state_block %p.\n",
266 iface
, desc
, text_rendering_params
, state_block
);
268 if (!(object
= heap_alloc_zero(sizeof(*object
))))
269 return E_OUTOFMEMORY
;
273 memcpy(&state_desc
, desc
, sizeof(*desc
));
274 state_desc
.primitiveBlend
= D2D1_PRIMITIVE_BLEND_SOURCE_OVER
;
275 state_desc
.unitMode
= D2D1_UNIT_MODE_DIPS
;
278 d2d_state_block_init(object
, (ID2D1Factory
*)iface
, desc
? &state_desc
: NULL
, text_rendering_params
);
280 TRACE("Created state block %p.\n", object
);
281 *state_block
= (ID2D1DrawingStateBlock
*)&object
->ID2D1DrawingStateBlock1_iface
;
286 static HRESULT
d2d_factory_get_device(struct d2d_factory
*factory
, ID3D10Device1
**device
)
290 if (!factory
->device
&& FAILED(hr
= D3D10CreateDevice1(NULL
, D3D10_DRIVER_TYPE_HARDWARE
, NULL
, D3D10_CREATE_DEVICE_BGRA_SUPPORT
,
291 D3D10_FEATURE_LEVEL_10_0
, D3D10_1_SDK_VERSION
, &factory
->device
)))
292 WARN("Failed to create device, hr %#x.\n", hr
);
294 *device
= factory
->device
;
298 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateWicBitmapRenderTarget(ID2D1Factory2
*iface
,
299 IWICBitmap
*target
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
, ID2D1RenderTarget
**render_target
)
301 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
302 struct d2d_wic_render_target
*object
;
303 ID3D10Device1
*device
;
306 TRACE("iface %p, target %p, desc %p, render_target %p.\n", iface
, target
, desc
, render_target
);
308 if (!(object
= heap_alloc_zero(sizeof(*object
))))
309 return E_OUTOFMEMORY
;
311 if (FAILED(hr
= d2d_factory_get_device(factory
, &device
)))
317 if (FAILED(hr
= d2d_wic_render_target_init(object
, (ID2D1Factory1
*)iface
, device
, target
, desc
)))
319 WARN("Failed to initialize render target, hr %#x.\n", hr
);
324 TRACE("Created render target %p.\n", object
);
325 *render_target
= object
->dxgi_target
;
330 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateHwndRenderTarget(ID2D1Factory2
*iface
,
331 const D2D1_RENDER_TARGET_PROPERTIES
*desc
, const D2D1_HWND_RENDER_TARGET_PROPERTIES
*hwnd_rt_desc
,
332 ID2D1HwndRenderTarget
**render_target
)
334 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
335 struct d2d_hwnd_render_target
*object
;
336 ID3D10Device1
*device
;
339 TRACE("iface %p, desc %p, hwnd_rt_desc %p, render_target %p.\n", iface
, desc
, hwnd_rt_desc
, render_target
);
341 if (FAILED(hr
= d2d_factory_get_device(factory
, &device
)))
344 if (!(object
= heap_alloc_zero(sizeof(*object
))))
345 return E_OUTOFMEMORY
;
347 if (FAILED(hr
= d2d_hwnd_render_target_init(object
, (ID2D1Factory1
*)iface
, device
, desc
, hwnd_rt_desc
)))
349 WARN("Failed to initialize render target, hr %#x.\n", hr
);
354 TRACE("Created render target %p.\n", object
);
355 *render_target
= &object
->ID2D1HwndRenderTarget_iface
;
360 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1Factory2
*iface
,
361 IDXGISurface
*surface
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
, ID2D1RenderTarget
**render_target
)
363 IDXGIDevice
*dxgi_device
;
367 TRACE("iface %p, surface %p, desc %p, render_target %p.\n", iface
, surface
, desc
, render_target
);
369 if (FAILED(hr
= IDXGISurface_GetDevice(surface
, &IID_IDXGIDevice
, (void **)&dxgi_device
)))
371 WARN("Failed to get DXGI device, hr %#x.\n", hr
);
375 hr
= ID2D1Factory1_CreateDevice((ID2D1Factory1
*)iface
, dxgi_device
, &device
);
376 IDXGIDevice_Release(dxgi_device
);
379 WARN("Failed to create D2D device, hr %#x.\n", hr
);
383 hr
= d2d_d3d_create_render_target(device
, surface
, NULL
, NULL
, desc
, (void **)render_target
);
384 ID2D1Device_Release(device
);
388 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateDCRenderTarget(ID2D1Factory2
*iface
,
389 const D2D1_RENDER_TARGET_PROPERTIES
*desc
, ID2D1DCRenderTarget
**render_target
)
391 struct d2d_factory
*factory
= impl_from_ID2D1Factory2(iface
);
392 struct d2d_dc_render_target
*object
;
393 ID3D10Device1
*device
;
396 TRACE("iface %p, desc %p, render_target %p.\n", iface
, desc
, render_target
);
398 if (FAILED(hr
= d2d_factory_get_device(factory
, &device
)))
401 if (!(object
= heap_alloc_zero(sizeof(*object
))))
402 return E_OUTOFMEMORY
;
404 if (FAILED(hr
= d2d_dc_render_target_init(object
, (ID2D1Factory1
*)iface
, device
, desc
)))
406 WARN("Failed to initialize render target, hr %#x.\n", hr
);
411 TRACE("Created render target %p.\n", object
);
412 *render_target
= &object
->ID2D1DCRenderTarget_iface
;
417 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateDevice(ID2D1Factory2
*iface
,
418 IDXGIDevice
*dxgi_device
, ID2D1Device
**device
)
420 struct d2d_device
*object
;
422 TRACE("iface %p, dxgi_device %p, device %p.\n", iface
, dxgi_device
, device
);
424 if (!(object
= heap_alloc_zero(sizeof(*object
))))
425 return E_OUTOFMEMORY
;
427 d2d_device_init(object
, (ID2D1Factory1
*)iface
, dxgi_device
);
429 TRACE("Create device %p.\n", object
);
430 *device
= &object
->ID2D1Device_iface
;
435 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateStrokeStyle1(ID2D1Factory2
*iface
,
436 const D2D1_STROKE_STYLE_PROPERTIES1
*desc
, const float *dashes
, UINT32 dash_count
,
437 ID2D1StrokeStyle1
**stroke_style
)
439 FIXME("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p stub!\n",
440 iface
, desc
, dashes
, dash_count
, stroke_style
);
445 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreatePathGeometry1(ID2D1Factory2
*iface
, ID2D1PathGeometry1
**geometry
)
447 FIXME("iface %p, geometry %p stub!\n", iface
, geometry
);
452 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateDrawingStateBlock1(ID2D1Factory2
*iface
,
453 const D2D1_DRAWING_STATE_DESCRIPTION1
*desc
, IDWriteRenderingParams
*text_rendering_params
,
454 ID2D1DrawingStateBlock1
**state_block
)
456 struct d2d_state_block
*object
;
458 TRACE("iface %p, desc %p, text_rendering_params %p, state_block %p.\n",
459 iface
, desc
, text_rendering_params
, state_block
);
461 if (!(object
= heap_alloc_zero(sizeof(*object
))))
462 return E_OUTOFMEMORY
;
464 d2d_state_block_init(object
, (ID2D1Factory
*)iface
, desc
, text_rendering_params
);
466 TRACE("Created state block %p.\n", object
);
467 *state_block
= &object
->ID2D1DrawingStateBlock1_iface
;
472 static HRESULT STDMETHODCALLTYPE
d2d_factory_CreateGdiMetafile(ID2D1Factory2
*iface
,
473 IStream
*stream
, ID2D1GdiMetafile
**metafile
)
475 FIXME("iface %p, stream %p, metafile %p stub!\n", iface
, stream
, metafile
);
480 static HRESULT STDMETHODCALLTYPE
d2d_factory_RegisterEffectFromStream(ID2D1Factory2
*iface
,
481 REFCLSID effect_id
, IStream
*property_xml
, const D2D1_PROPERTY_BINDING
*bindings
,
482 UINT32 binding_count
, PD2D1_EFFECT_FACTORY effect_factory
)
484 FIXME("iface %p, effect_id %s, property_xml %p, bindings %p, binding_count %u, effect_factory %p stub!\n",
485 iface
, debugstr_guid(effect_id
), property_xml
, bindings
, binding_count
, effect_factory
);
490 static HRESULT STDMETHODCALLTYPE
d2d_factory_RegisterEffectFromString(ID2D1Factory2
*iface
,
491 REFCLSID effect_id
, const WCHAR
*property_xml
, const D2D1_PROPERTY_BINDING
*bindings
,
492 UINT32 binding_count
, PD2D1_EFFECT_FACTORY effect_factory
)
494 FIXME("iface %p, effect_id %s, property_xml %s, bindings %p, binding_count %u, effect_factory %p stub!\n",
495 iface
, debugstr_guid(effect_id
), debugstr_w(property_xml
), bindings
, binding_count
, effect_factory
);
500 static HRESULT STDMETHODCALLTYPE
d2d_factory_UnregisterEffect(ID2D1Factory2
*iface
, REFCLSID effect_id
)
502 FIXME("iface %p, effect_id %s stub!\n", iface
, debugstr_guid(effect_id
));
507 static HRESULT STDMETHODCALLTYPE
d2d_factory_GetRegisteredEffects(ID2D1Factory2
*iface
,
508 CLSID
*effects
, UINT32 effect_count
, UINT32
*returned
, UINT32
*registered
)
510 FIXME("iface %p, effects %p, effect_count %u, returned %p, registered %p stub!\n",
511 iface
, effects
, effect_count
, returned
, registered
);
516 static HRESULT STDMETHODCALLTYPE
d2d_factory_GetEffectProperties(ID2D1Factory2
*iface
,
517 REFCLSID effect_id
, ID2D1Properties
**props
)
519 FIXME("iface %p, effect_id %s, props %p stub!\n", iface
, debugstr_guid(effect_id
), props
);
524 static HRESULT STDMETHODCALLTYPE
d2d_factory_ID2D1Factory1_CreateDevice(ID2D1Factory2
*iface
, IDXGIDevice
*dxgi_device
,
525 ID2D1Device1
**device
)
527 FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface
, dxgi_device
, device
);
532 static const struct ID2D1Factory2Vtbl d2d_factory_vtbl
=
534 d2d_factory_QueryInterface
,
537 d2d_factory_ReloadSystemMetrics
,
538 d2d_factory_GetDesktopDpi
,
539 d2d_factory_CreateRectangleGeometry
,
540 d2d_factory_CreateRoundedRectangleGeometry
,
541 d2d_factory_CreateEllipseGeometry
,
542 d2d_factory_CreateGeometryGroup
,
543 d2d_factory_CreateTransformedGeometry
,
544 d2d_factory_CreatePathGeometry
,
545 d2d_factory_CreateStrokeStyle
,
546 d2d_factory_CreateDrawingStateBlock
,
547 d2d_factory_CreateWicBitmapRenderTarget
,
548 d2d_factory_CreateHwndRenderTarget
,
549 d2d_factory_CreateDxgiSurfaceRenderTarget
,
550 d2d_factory_CreateDCRenderTarget
,
551 d2d_factory_CreateDevice
,
552 d2d_factory_CreateStrokeStyle1
,
553 d2d_factory_CreatePathGeometry1
,
554 d2d_factory_CreateDrawingStateBlock1
,
555 d2d_factory_CreateGdiMetafile
,
556 d2d_factory_RegisterEffectFromStream
,
557 d2d_factory_RegisterEffectFromString
,
558 d2d_factory_UnregisterEffect
,
559 d2d_factory_GetRegisteredEffects
,
560 d2d_factory_GetEffectProperties
,
561 d2d_factory_ID2D1Factory1_CreateDevice
,
564 static void d2d_factory_init(struct d2d_factory
*factory
, D2D1_FACTORY_TYPE factory_type
,
565 const D2D1_FACTORY_OPTIONS
*factory_options
)
567 if (factory_type
!= D2D1_FACTORY_TYPE_SINGLE_THREADED
)
568 FIXME("Ignoring factory type %#x.\n", factory_type
);
569 if (factory_options
&& factory_options
->debugLevel
!= D2D1_DEBUG_LEVEL_NONE
)
570 WARN("Ignoring debug level %#x.\n", factory_options
->debugLevel
);
572 factory
->ID2D1Factory2_iface
.lpVtbl
= &d2d_factory_vtbl
;
573 factory
->refcount
= 1;
574 d2d_factory_reload_sysmetrics(factory
);
577 HRESULT WINAPI
D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type
, REFIID iid
,
578 const D2D1_FACTORY_OPTIONS
*factory_options
, void **factory
)
580 struct d2d_factory
*object
;
583 TRACE("factory_type %#x, iid %s, factory_options %p, factory %p.\n",
584 factory_type
, debugstr_guid(iid
), factory_options
, factory
);
586 if (!(object
= heap_alloc_zero(sizeof(*object
))))
587 return E_OUTOFMEMORY
;
589 d2d_factory_init(object
, factory_type
, factory_options
);
591 TRACE("Created factory %p.\n", object
);
593 hr
= ID2D1Factory2_QueryInterface(&object
->ID2D1Factory2_iface
, iid
, factory
);
594 ID2D1Factory2_Release(&object
->ID2D1Factory2_iface
);
599 void WINAPI
D2D1MakeRotateMatrix(float angle
, D2D1_POINT_2F center
, D2D1_MATRIX_3X2_F
*matrix
)
601 float theta
, sin_theta
, cos_theta
;
603 TRACE("angle %.8e, center %s, matrix %p.\n", angle
, debug_d2d_point_2f(¢er
), matrix
);
605 theta
= angle
* (M_PI
/ 180.0f
);
606 sin_theta
= sinf(theta
);
607 cos_theta
= cosf(theta
);
609 /* translate(center) * rotate(theta) * translate(-center) */
610 matrix
->_11
= cos_theta
;
611 matrix
->_12
= sin_theta
;
612 matrix
->_21
= -sin_theta
;
613 matrix
->_22
= cos_theta
;
614 matrix
->_31
= center
.x
- center
.x
* cos_theta
+ center
.y
* sin_theta
;
615 matrix
->_32
= center
.y
- center
.x
* sin_theta
- center
.y
* cos_theta
;
618 void WINAPI
D2D1MakeSkewMatrix(float angle_x
, float angle_y
, D2D1_POINT_2F center
, D2D1_MATRIX_3X2_F
*matrix
)
622 TRACE("angle_x %.8e, angle_y %.8e, center %s, matrix %p.\n", angle_x
, angle_y
, debug_d2d_point_2f(¢er
), matrix
);
624 tan_x
= tan(angle_x
* (M_PI
/ 180.0f
));
625 tan_y
= tan(angle_y
* (M_PI
/ 180.0f
));
627 /* translate(-center) * skew() * translate(center) */
632 matrix
->_31
= -tan_x
* center
.y
;
633 matrix
->_32
= -tan_y
* center
.x
;
636 BOOL WINAPI
D2D1IsMatrixInvertible(const D2D1_MATRIX_3X2_F
*matrix
)
638 TRACE("matrix %p.\n", matrix
);
640 return (matrix
->_11
* matrix
->_22
- matrix
->_21
* matrix
->_12
) != 0.0f
;
643 BOOL WINAPI
D2D1InvertMatrix(D2D1_MATRIX_3X2_F
*matrix
)
645 D2D1_MATRIX_3X2_F m
= *matrix
;
647 TRACE("matrix %p.\n", matrix
);
649 return d2d_matrix_invert(matrix
, &m
);
652 static BOOL
get_config_key_dword(HKEY default_key
, HKEY application_key
, const char *name
, DWORD
*value
)
654 DWORD type
, data
, size
;
657 if (application_key
&& !RegQueryValueExA(application_key
,
658 name
, 0, &type
, (BYTE
*)&data
, &size
) && type
== REG_DWORD
)
662 if (default_key
&& !RegQueryValueExA(default_key
,
663 name
, 0, &type
, (BYTE
*)&data
, &size
) && type
== REG_DWORD
)
673 static void d2d_settings_init(void)
675 HKEY default_key
, tmp_key
, application_key
= NULL
;
676 char buffer
[MAX_PATH
+ 10];
679 if (RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Direct2D", &default_key
))
682 len
= GetModuleFileNameA(0, buffer
, MAX_PATH
);
683 if (len
&& len
< MAX_PATH
)
685 char *p
, *appname
= buffer
;
687 if ((p
= strrchr(appname
, '/')))
689 if ((p
= strrchr(appname
, '\\')))
691 strcat(appname
, "\\Direct2D");
693 if (!RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmp_key
))
695 if (RegOpenKeyA(tmp_key
, appname
, &application_key
))
696 application_key
= NULL
;
697 RegCloseKey(tmp_key
);
701 if (!default_key
&& !application_key
)
704 if (get_config_key_dword(default_key
, application_key
, "max_version_factory", &d2d_settings
.max_version_factory
))
705 ERR_(winediag
)("Limiting maximum Direct2D factory version to %#x.\n", d2d_settings
.max_version_factory
);
708 RegCloseKey(application_key
);
710 RegCloseKey(default_key
);
713 BOOL WINAPI
DllMain(HINSTANCE inst
, DWORD reason
, void *reserved
)
715 if (reason
== DLL_PROCESS_ATTACH
)