Commit Graph

96 Commits

Author SHA1 Message Date
Artur Wieczorek
008a162241 Fixed appending circle/ellipse to wxGraphicsPath with Direct2D renderer.
Circle/ellipse should be appended as a closed sub-path and the current point after the operation should be moved to "the rightmost point" of the figure ((x+r,y) and (x+w,y+h/2) respectively).

See #17520
2016-05-05 13:49:36 +02:00
Maarten Bent
7c16c93807 Fix for PCH-less build for wxD2DContext.
It is required for FLT_MAX in Direct2D graphics context.

Closes https://github.com/wxWidgets/wxWidgets/pull/276
2016-05-01 19:03:58 +02:00
Artur Wieczorek
1e6cf64a2a Fixed creating wxGraphicsPath with Direct2D renderer.
When current endpoint is moved to a new position with MoveToPoint() then current sub-path should be ended without closing the figure (no line from the current point to the beginning of the sub-path should be added).

Closes #17516
2016-05-01 19:02:58 +02:00
Artur Wieczorek
6243e0e507 Use wxList instead of std::list in Direct2D renderer.
This would remove explicit dependency on STL.
2016-04-22 21:17:01 +02:00
Artur Wieczorek
e962172cd9 Don't call std::sin, std::cos functions.
This is for the sake of consistency because everywhere else there are used trigonometric functions from standard C library (only <math.h> is included).
2016-04-22 21:15:41 +02:00
Artur Wieczorek
8a7374e5ca Fixed drawing with wxGraphicsContext and Direct2D renderer.
When render target to draw to a DC (created with ID2D1Factory::CreateDCRenderTarget method) is bound to the device context with ID2D1DCRenderTarget::BindDC method then the size of the area of drawing has to be a logical size of a DC (with its scaling factor taken int account). This can be determined directly using GetClipBox API and there is no need to pass it as a parameter of wxD2DDCRenderTargetResourceHolder ctor.

Closes #17504.
2016-04-21 20:24:43 +02:00
Artur Wieczorek
deb162fc5a Fixes for PCH-less build for Direct2D graphics context.
Include the required headers inside "#ifndef WX_PRECOMP" block.

See #17502.
2016-04-20 22:03:38 +02:00
Artur Wieczorek
4b0732269d Fixed determining Direct2D graphics context size (wxMSW).
Determine actual size of wxD2DContext instance and initialize respective data members to report proper size of wxGraphicsContext created by wxGraphicsRenderer::CreateContextFromNativeContext / CreateContextFromNativeWindow.

Closes #17502.
2016-04-20 20:54:48 +02:00
Václav Slavík
7c709be652 Silence VC14 warning in d2d1helper.h system header 2016-03-29 18:54:58 +02:00
Artur Wieczorek
95e63ed062 Pass D2D1_ALPHA_MODE value instead of Boolean flag to wxD2DContext.
Using non-Boolean argument should be more clear.

See #17465.
2016-03-28 21:47:09 +02:00
Artur Wieczorek
e07aa294a4 Fixed drawing on wxMemoryDC with Direct2DRenderer.
32bpp wxBitmaps selected into wxMemoryDC can represent either 0RGB or ARGB bitmaps and hence there is necessary to instruct renderer how to interpret 32bpp contents while creating a wxGraphicsContext. wxBitmap::HasAlpha() flag is used for these purposes and its value is passed to wxD2DContext ctor (wxD2DContext is used internally as a backend D2D component) and next used to configure physical renderer created with ID2D1Factory::CreateDCRenderTarget.

Closes #17465.
2016-03-28 21:22:06 +02:00
Artur Wieczorek
8e1c85109c Use wxMax instead of std::max.
Use wxMax for the sake of uniformity and maintainability - it is used everywhere else in the code base.
2016-03-24 22:24:56 +01:00
Artur Wieczorek
2ea39a23e7 Fix wxD2DContext compilation when wxUSE_IMAGE==0 2016-02-25 23:46:50 +01:00
Vadim Zeitlin
a7d31701ab Work around a crash in wxD2DContext when using gcc
Don't call GetSize() method as gcc can't handle aggregates returned by value
from D2D libraries currently and the code just crashes if this method is
called.

See #17171.
2016-01-30 04:43:46 +01:00
Maarten Bent
600bfed6c5 Use correct order in wxD2DPathData ctor initializer list
Resolve (harmless) -Wreorder warning introduced in 602fe6cb.

Closes https://github.com/wxWidgets/wxWidgets/pull/172
2016-01-18 14:44:09 +01:00
Artur Wieczorek
ca52d09a03 Optimize converting internal Direct2D renderer bitmap to wxImage.
Get access to bitmap bits with IWICBitmap::Lock instead of IWICBitmapSource::CopyPixels because in-place processing is more effective in terms of speed and memory consumption (see IWICBitmap interface description in MSDN).

See #17311.
2016-01-04 22:35:57 +01:00
Artur Wieczorek
6498776b52 Initialize internal bitmap when creating D2D graphics context from wxImage.
Internal D2D WIC bitmap should be initialized with source wxImage contents in wxD2DRenderer::CreateContextFromImage.

Closes #17314.
2016-01-04 18:30:39 +01:00
Artur Wieczorek
4a3f3f4ed7 Store alpha channel values when converting internal D2D bitmap to wxImage.
Save alpha channel retrieved from internal bitmap if target wxImage is capable to store it. Also undo premultiplication of RGB values if bitmap contains alpha channel values.

Closes #17311.
2016-01-03 21:48:29 +01:00
Artur Wieczorek
450019dc21 Ensure COM is still active when Direct2D renderer is in use
Some internal D2D operations need active COM library so ensure it is properly
initialized and released in wxDirect2DModule.

Closes #17308.
2016-01-02 17:09:30 +01:00
Artur Wieczorek
602fe6cb83 Set initial point of the path in wxD2DPathData::wxD2DPathData ctor.
Set initial point to (0,0) for newly created Direct2D wxGraphicsPath path.
2015-12-28 00:08:24 +01:00
Artur Wieczorek
846dde3b36 Fixed drawing ellipse/circle in Direct2D wxGraphicsPath.
Instead of drawing an ellipse as a filled figure draw it as a curve (concatenation of two elliptical arcs).

Closes #17306.
2015-12-28 00:07:00 +01:00
Artur Wieczorek
537519a8ed Fixed initialization of Direct2D path geometry in wxD2DPathData ctor.
To properly initialize path geometry there is also necessary to open at least once its geometry sink.

Closes #16970.
2015-12-26 16:24:26 +01:00
Maarten Bent
5cfaf2f898 Fix harmless gcc warning advising braces around empty "if" body
Add them just to silence the compiler.
2015-10-16 17:12:59 +02:00
Maarten Bent
0b1bc6b0b1 Fix harmless signed/unsigned comparison warning in Direct2D code
Cast D2DERR_RECREATE_TARGET, which is not of HRESULT type, to it to avoid gcc
warnings.
2015-10-16 17:12:58 +02:00
Maarten Bent
99573ecddd Add more error checks to Direct2D wxGraphics code
Check the result of the operations instead of just assigning them to "hr"
variable which is then never used.
2015-10-16 17:12:57 +02:00
Vadim Zeitlin
d1dfcd1497 Fix some g++ warnings in D2D graphics code
Avoid warnings about a class with virtual methods having non-virtual dtor and
not handling an enum value in a switch.

See #16625.
2015-09-29 00:54:25 +02:00
Vadim Zeitlin
2a9a42fd23 Don't pretend that we implement IWICBitmapSource::CopyPalette()
We don't and it's unclear how to do it, so just return
WINCODEC_ERR_PALETTEUNAVAILABLE instead of pretending that we copied the
palette when we didn't.

See #16625.
2015-09-29 00:49:37 +02:00
Vadim Zeitlin
576b0033c0 Fix wrong use of wxCHECK2_MSG in D2D graphics code
This was supposed to be wxCHECK_MSG().

See #16625.
2015-09-29 00:46:27 +02:00
Vadim Zeitlin
db415ad04d Compilation fixes for C++98 compilers in D2D graphics code
Don't use ">>" token in nested templates, this is not allowed in C++98 but
only C++11.

Also don't use "= NULL" on pure virtual functions.

See #16625.
2015-09-29 00:44:08 +02:00
Vadim Zeitlin
827e3d455a Build fixes for PCH-less build for D2D graphics context
Include the required headers in all cases currently, ideal would be to include
them only inside "#ifndef WX_PRECOMP" but it's probably not a big problem to
just do it always.

See #16625.
2015-09-29 00:42:26 +02:00
Paul Cornett
2dfbb810a4 avoid shadowed variable warning with VS2015, see #17112 2015-08-19 11:21:44 -07:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Vadim Zeitlin
da41c5d9bb Don't leak global objects in Direct2D code.
Ensure that all globals are freed on library shutdown by using a module just
to perform this cleanup.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-21 01:41:14 +00:00
Vadim Zeitlin
db73e480ef Don't call CoInitializeEx() from Direct2D code.
This is unnecessary, COM is already initialized on the application startup and
Direct2D can't be used before that anyhow.

This also fixes lack of matching CoUninitialize() call.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77752 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-21 01:41:10 +00:00
Stefan Csomor
f5d6be6d86 fixing memory leak
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-14 18:11:38 +00:00
Vadim Zeitlin
4d16d86821 Fix memory leak when creating new Direct2D-based wxGraphicsContext.
ID2D1DCRenderTarget was leaked every time a wxD2DContext was created because a
raw pointer was given to wxCOMPtr<> which didn't take its ownership.

Use wxCOMPtr instead of the raw pointer to fix this and also fix more rare but
still possible leak in case of error.

This fixes out of memory errors and crashes in the drawing sample after a few
seconds of constant window resizing/repainting.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-14 01:00:11 +00:00
Vadim Zeitlin
c8e27bcaf7 Simplify Direct2D DLLs loading code a little.
Bail out earlier: if d2d1.dll is not there, it doesn't make sense to try to
load dwrite.dll.

Also use Load() return value directly instead of ignoring it and then checking
for IsLoaded().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77684 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-11 20:33:27 +00:00
Vadim Zeitlin
7dec99c0a8 Suppress error messages when checking for Direct2D availability.
Use wxDL_QUIET flag when loading Direct2D DLLs as we're prepared to handle
their absence and don't need to show error messages if they're not available.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-11 20:33:24 +00:00
Vadim Zeitlin
b59176869a Fix Direct2D code compilation in non-Unicode build.
DirectWrite GDI interop only works with Unicode LOGFONTW, so use it explicitly
instead of LOGFONT which is LOGFONTA in non-Unicode build.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77680 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-11 11:37:10 +00:00
Vadim Zeitlin
c2d70a0340 Convert Direct2D source file to Unix EOL format.
No other changes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77668 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-10 16:52:24 +00:00
Vadim Zeitlin
1643a7dd51 Use ID2D1Bitmap instead of ID2D1Image.
ID2D1Image is not defined in v7.0A platform SDK used by VC10 and doesn't seem
to be needed here as we are only working with ID2D1Bitmaps (deriving from
ID2D1Image) anyhow.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-10 16:52:16 +00:00
Vadim Zeitlin
8734eb3732 Don't use enum name for qualifying enum element.
This is a non-standard MSVC extension and can't be done in standard C++.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-10 16:52:13 +00:00
Vadim Zeitlin
ab3977ddc3 Remove PI definition from Direct2D wxGraphicsContext code.
The line defining PI didn't compile with VC10 because atan(1) is ambiguous
(argument could be float, double or long double). And it was not needed anyhow
as PI was not used anywhere (and if it were, we should be just using M_PI from
wx/math.h anyhow), so simply remove it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-10 16:52:10 +00:00
Stefan Csomor
bba268b379 fixing initialization order, fixes #16542
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-09 13:53:28 +00:00
Stefan Csomor
fd36509e51 fixing implicit narrowing conversions, silencing ICC warnings, fixes #16542
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-09 09:58:39 +00:00
Stefan Csomor
0c69d619dc direct2d GSOC2014 add addtional file
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-06 14:59:53 +00:00