Commit Graph

122 Commits

Author SHA1 Message Date
Vadim Zeitlin
893f3a6c00 Add wxDirect2DModule dependency on wxOleInitModule
This avoids the need for calling CoInitializeEx() and CoUninitialize()
in this module itself, it's enough to ensure that wxOleInitModule does
it before, or after, before this one is initialized, or uninitialized,
respectively.

This replaces the earlier fix of 450019dc21 (Ensure COM is still active
when Direct2D renderer is in use, 2015-12-30).

See #17308.
2020-04-19 17:04:36 +02:00
Artur Wieczorek
1dc0c777ae Return value of the proper type
Returned value should be the same type like the memeber variable.
2020-04-05 22:06:00 +02:00
Vadim Zeitlin
13b6b9ef18 Merge branch 'd2d-drawbitmap' of https://github.com/MaartenBent/wxWidgets
Fix DrawBitmap() in Direct2D renderer to resize the bitmap if necessary.

See https://github.com/wxWidgets/wxWidgets/pull/1752
2020-03-11 23:20:56 +01:00
Maarten Bent
c85da7e06f Fix DrawBitmap in Direct2D renderer
When the bitmap is larger than the draw area, it should be resized. Do this by
providing the correct size parameters for ID2D1RenderTarget::DrawBitmap.

Also update DrawBitmap code guarded with wxD2D_DEVICE_CONTEXT_SUPPORTED so it
will compile successfully when enabled. However, the drawing behaviour is,
and was, different from the normal behaviour. It does not resize the bitmap.

Closes #18686
2020-03-10 21:04:15 +01:00
Artur Wieczorek
7c6d816d4a Add support for private fonts in Direct2D renderer
Since it appears it's not possible to create DirectWrite fonts with
IDWriteGdiInterop::CreateFontFromLOGFONT() for fonts registered with
AddFontResourceEx() as private ones (with FR_PRIVATE flag), we need to
maintain a custom DirectWrite font collection and use it as source of
font data if call to CreateFontFromLOGFONT() fails. This collection
consists of IDWriteFontFileEnumerator and IDWriteFontCollectionLoader
objects which are seeded with font data based on the private fonts list
taken from wxGetPrivateFontFileNames().

Closes https://github.com/wxWidgets/wxWidgets/pull/1753

Closes #18687.
2020-03-10 02:43:32 +01:00
Artur Wieczorek
5fb7f89b14 Don't use vestor::data() to get access to the raw vector data
This method is available since C++ 11 so it can't be used currently.
2020-02-09 23:12:08 +01:00
Artur Wieczorek
55daa7103e Implement wxD2DGradientStopsHelper as a wxD2DResourceHolder
There is a dedicated template class wxD2DResourceHolder<T> to support
managing backend D2D resources and wxD2DGradientStopsHelper should be
derived from wxD2DResourceHolder<ID2D1GradientStopCollection> for the
sake of consistency with other D2D resource holders.
2020-02-09 20:46:40 +01:00
Maarten Bent
95d3064a6b Fix reference count in D2D renderer gradient brushes
Closes #18656.
2020-02-02 14:53:16 +01:00
Maarten Bent
8e2f674c0b Remove trailing whitespace 2020-02-02 14:50:57 +01:00
Maarten Bent
8ceadd3029 Improve wxD2DContext::GetDPI and wxGDIPlusContext::GetDPI
If there is a valid wxWindow, use its DPI. Otherwise use a dedicated function
of the context to get the DPI. Don't use the common wxGraphicsContext::GetDPI
because this will return hard-coded 72 when there is no valid wxWindow.
2019-10-09 22:25:08 +02:00
Maarten Bent
c538e8f9d6 Add wxGraphicsRenderer::CreateFontAtDPI to support font with fractional pixel-size 2019-10-09 22:24:28 +02:00
Maarten Bent
64f4963396 Correctly use pixelSize in wxGraphicsContext::CreateFont
It is documented as using pixel size, and this is also used in all other contexts.
For clarity, rename all parameters to sizeInPixels.

This partially reverts d5020362ff
2019-10-07 00:55:00 +02:00
Robin Dunn
1c2e71920a Remove commented-out asserts 2019-09-11 13:09:12 -07:00
Robin Dunn
a8a19e25ee Various typo and coding style fixes 2019-09-05 13:33:15 -07:00
Robin Dunn
f7896d4dff Use new parameter names in the existing CreateRadialGradientBrush methods too 2019-09-04 14:19:24 -07:00
Robin Dunn
80f24d9e74 User more easily understandable names for the radial gradient coordinate parameters in wxGraphicsPenInfo 2019-09-04 14:19:24 -07:00
Robin Dunn
78c1c6ca6d Remove TODO 2019-09-04 14:19:24 -07:00
Robin Dunn
fc35d8b49b Comment out some asserts I think are incorrect. Needs verification. 2019-09-04 14:19:24 -07:00
Robin Dunn
2571f5962c Don't use a wxRect to hold floating point values!! 2019-09-04 14:19:24 -07:00
Robin Dunn
a8eeab3af2 Add support for setting the transform on Direct2D gradient brushes 2019-09-04 14:19:24 -07:00
Robin Dunn
6d85b566ce Create gradient brushes for pens in wxD2DRenderer 2019-09-04 14:19:24 -07:00
Robin Dunn
e2fbcf0650 API updates only, to allow building. 2019-09-04 14:19:24 -07:00
Maarten Bent
d10ed0b991 Implement wxPolygonFillMode in GDI+ and D2D graphics contexts
Honour "fillStyle" parameter, which was previously ignored.

Closes https://github.com/wxWidgets/wxWidgets/pull/1478
2019-08-20 13:32:29 +02:00
Artur Wieczorek
283ac3096d Fix closing sub-path created by MoveToPoint() in Direct2D
Because call to MoveToPoint() opens a new sub-path but doesn't open
a new D2D figure (this is to avoid the situation when multiple consequtive
calls to MoveToPoint() would open a spurious figures/paths, see c8fe811636),
we need to check when sub-path is being closed if we have a sub-patch
without figure and if so, a new figure has to be open to get a required
in this case 1-point figure/path.
2019-08-11 20:07:17 +02:00
Vadim Zeitlin
463deb03c9 Merge branch 'gtk-dpi'
A bunch of improvements for per-monitor DPI support in wxGTK and
wxGraphicsContext more generally.

Closes https://github.com/wxWidgets/wxWidgets/pull/995
2018-11-10 12:15:27 +01:00
Vadim Zeitlin
5e53b22bd4 Add wxGraphicsContext::GetWindow()
This method allows to retrieve the window this context is associated
with, if any.

Add "wxWindow*" argument to wxGraphicsContext ctor and provide the
window pointer to it when available, i.e. when creating the context from
a wxWindow directly or from wxWindowDC, which is also associated with a
window, in platform-specific code.

No real changes yet.
2018-11-06 03:36:53 +01:00
Maarten Bent
9554cb49d8 Fix build when enabling wxD2D_DEVICE_CONTEXT_SUPPORTED
Add missing GUID and function for dynamic linking.
2018-11-04 16:49:14 +01:00
Vadim Zeitlin
5a4d46bf7d Handle fractional point sizes in DirectWrite wxGraphicsFont
Also stop scaling the font size by DPI manually, we don't need to do it
if we use points instead of pixels. This, in turn, made it unnecessary
to pass ID2D1Factory parameter to wxD2DFontData ctor.
2018-09-17 15:24:42 +02:00
Artur Wieczorek
c8fe811636 Fix wxGraphicsPath::MoveToPoint for Direct2D
Calling MoveToPoint() shouldn't automatically open a new D2D figure (which
acts as a subpath) because in case of consecutive calls to MoveToPoint()
every next call would close the figure opened by the previous call and
we would get spurious figure(s) (consisting one point).
Opening a D2D figure (subpath) should be delgated to the functions doing
actual drawing.
2018-07-28 11:46:28 +02:00
Artur Wieczorek
74306708bc Fix retrieving empty bounding box for D2D graphics path
Return "zero rectangle" (0, 0, 0, 0) if bounding box is empty.
2018-07-28 11:43:31 +02:00
Maarten Bent
802c77b964 Fix building without precompiled headers on Windows 2018-05-22 17:04:42 +02:00
Maarten Bent
8577d9ddca Fix build warnings in Direct2D related code
Regressions since df1456e4e2 and
b936bfe85e.

See https://github.com/wxWidgets/wxWidgets/pull/731
2018-02-16 15:55:33 +01:00
Maarten Bent
d3d8778542 Reduce debug warnings of Direct2D Debug Layer 2018-02-02 23:58:52 +01:00
Vadim Zeitlin
7a24cdb861 Merge branch 'cmake-options' of https://github.com/MaartenBent/wxWidgets
See https://github.com/wxWidgets/wxWidgets/pull/694
2018-01-30 13:58:52 +01:00
Maarten Bent
6a2c4abcc1 Define missing GUIDs for Direct2D in MinGW
The GUIDs are copied from wincodec.h in Windows SDK 10.0.16299.0.
Fixed another build error in code that is normally disabled.
2018-01-29 00:45:29 +01:00
Vadim Zeitlin
8d75368a30 Minor formatting and style fixes to the previous commit
Fix indentation and spacing.

Also declare some variables when initializing them and make them const
if they don't change later.
2018-01-25 17:18:27 -06:00
New Pagodi
df1456e4e2 Apply erans patch to allow building with MinGW 2018-01-25 16:08:33 -06:00
New Pagodi
b936bfe85e Add Direct2D support to wxSTC 2018-01-25 16:07:54 -06:00
Vadim Zeitlin
76fd05b147 Leave only wxGraphicsRenderer::CreatePen(wxGraphicsPenInfo) overload
It doesn't make much sense to require all the graphics backends to
create wxGraphicsPen from either wxPen or wxGraphicsPenInfo when the
former can be handled just once in the common code.

So do just this, leaving CreatePen() overload taking wxGraphicsPenInfo
where the real pen construction takes place and implementing
wxGraphicsPen creation from wxPen in the common wxGraphicsContext code.

This is not 100% backwards-compatible as any code inheriting from
wxGraphicsRenderer and overriding its CreatePen() will now be broken,
however this should be extremely rare (there is no good reason to
inherit from this class in the user code) and result in compile errors
if it does happen.
2017-09-10 01:48:30 +02:00
Vadim Zeitlin
cc91a7d6d4 Minor formatting and style changes in wxPenInfo code
Use more standard formatting, wrap some overlong lines.
2017-09-10 01:11:06 +02:00
Adrien Tétar
999c750ca7 Review feedback 2017-09-10 01:02:21 +02:00
Adrien Tétar
2305604565 Introduce wxGraphicsPenInfo class 2017-09-10 01:02:20 +02:00
Oliver Smith
b8f83725ed Fix D2D wxGraphics build with wxUSE_UNICODE==0
Revert one of the changes of 5520702674 which
replaced direct check with a call to lstrlen() which seems to be unneeded and
doesn't compile in non-Unicode build.
2017-06-28 02:53:46 +02:00
Artur Wieczorek
7f9453dfdf Handle unsuccessful creation of graphics font in Direct2D
Apparently, DirectWrite fonts can be created only from TrueType fonts and
therefore only such fonts can be used with Direct2D-based wxGraphicsContext.
When unsuported GDI font is passed to CreateFont() then no graphics font is
created and this unsuccessful attempt is signalled by returning
wxNullGraphicsFont. This null object can be used in e.g. wxGC::SetFont()
to check if font was actually created.

See #17790.
2017-04-17 18:57:02 +02:00
Artur Wieczorek
5520702674 Typeface name of the font must not exceed LF_FACESIZE characters 2017-01-28 21:47:49 +01:00
Artur Wieczorek
f0bf5b6fd7 Add more status checks in Direct2D renderer
See #17790.
2017-01-28 21:46:42 +01:00
Václav Slavík
e71be91ebe Add API to create wxGraphicsContext from win32 HDC
Add wxGraphicsContext::CreateFromNativeHDC() and wxGraphicsRenderer::
CreateContextFromNativeHDC() to allow creation not only from native
renderer object, but also from HDC, which is something universally
supported by win32 implementations.
2017-01-06 14:35:09 +01:00
Paul Cornett
9b19a6e529 use wxOVERRIDE in wxMSW sources 2016-09-23 07:59:11 -07:00
Artur Wieczorek
aa687ec86e Implement wxGraphicsMatrixData::Clone() method for Direct2D renderer 2016-09-18 23:08:49 +02:00
Artur Wieczorek
b6d44d5329 Fix wxGraphicsMatrix concatenation (Direct2D)
1. Elements of resulting matrix are modified directly (in-place) in Matrix3x2F::SetProduct() so none of the multiplied matrices can be the instance of the resulting matrix.
2. The parameter matrix in wxGraphicsMatrixData::Concat() should be a multiplicand, not a multiplier.

See #17670.
2016-09-18 23:06:14 +02:00