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

Merged
merged 9 commits into from
Aug 19, 2024

Conversation

Softwaretom007
Copy link
Contributor

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
Contributor 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
Contributor 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
Contributor 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.

/// The font weight enumeration describes common values for degree of blackness or thickness of strokes of characters in a font.
/// Font weight values less than 1 or greater than 999 are considered to be invalid, and they are rejected by font API functions.
/// </summary>
public enum DWRITE_FONT_WEIGHT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Other enums in this file have names like DWriteFontWeight, with members like FontWeightThin (ie. not all-caps with underscores).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit 6470087. Thanks

Copy link
Collaborator

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me. @jingwood please take a look.

@jingwood jingwood merged commit ba73454 into jingwood:master Aug 19, 2024
@jingwood
Copy link
Owner

Very appreciate it!

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.

4 participants