Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached TextBrush and FontFormat for Measure & Draw Text #108

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Softwaretom007
Copy link

Add D2DSolidColorTextBrush object and interface + extend MeasureText with D2DFontFormat fontFormat and D2DTextLayout textLayout + update Sample/MeasureAndDrawString + update FPS meter algorithm

MeasureAndDrawString yield 2x performance gain using cached SolidColorTextBrush and FontFormat.

gilsonwang and others added 4 commits October 24, 2020 17:26
…lsonwang-master

# Conflicts:
#	binary/x86-build/d2dlibexport.dll
#	binary/x86-build/d2dwinform.dll
#	src/D2DLibExport/D2DDevice.cs
#	src/D2DLibExport/D2DLibExport.csproj
#	src/Examples/SampleCode/MeasureAndDrawStringForm.cs
#	src/d2dlib/Text.cpp
#	src/d2dlib/Text.h
+ bugfixes & refactoring
…with D2DFontFormat fontFormat and D2DTextLayout textLayout + update Sample/MeasureAndDrawString
Add D2DSolidColorTextBrush object and interface + extend MeasureText with D2DFontFormat fontFormat and D2DTextLayout textLayout +  update Sample/MeasureAndDrawString + update FPS meter algorithm
@jingwood
Copy link
Owner

jingwood commented Feb 8, 2023

@Softwaretom007 Thank you very much!

Add Drawing Unconnected lines
Add fill & draw rectangle single call
Add DrawStringLayout call
@Softwaretom007
Copy link
Author

Added more functionality (string layout, text antialiasing setup, optimized draw & fill rectangle and drawing unconnected lines - from array of points).

/// Render text aliased.
/// </summary>
ALIASED = 3,
FORCE_DWORD = 0xffffffff
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed in C#? Isn't the uint specifier adequate to ensure the type's size?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I don't understand your question.
This is enum for setup only possible antialias modes.
Value 0xFFFFFFFF is indeed maximum value for uint, but is correct value for "FORCE_DWORD" mode.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed (perhaps incorrectly) this enum member was ported from a native library where it was forcing the compiler to treat the enum as being 32 bits rather than something smaller. If that's the case then it's not needed in C#, where the base type of the enum is explicit.

But if this value is for something else then you can ignore my comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey,
now I understand 😄
There is no additional info for constant:
D2D1_TEXT_ANTIALIAS_MODE_FORCE_DWORD = 0xffffffff
So if this is only for "messing with compiler optimizations" in C/C++, as you say force to be 32bit.
Then yes, this don't belong to C# port.
First I thought that FORCE_DWORD is some "super" mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants