-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
…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
@Softwaretom007 Thank you very much! |
Add Drawing Unconnected lines Add fill & draw rectangle single call Add DrawStringLayout call
Added more functionality (string layout, text antialiasing setup, optimized draw & fill rectangle and drawing unconnected lines - from array of points). |
src/D2DLibExport/D2DEnums.cs
Outdated
/// Render text aliased. | ||
/// </summary> | ||
ALIASED = 3, | ||
FORCE_DWORD = 0xffffffff |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/D2DLibExport/D2DEnums.cs
Outdated
/// 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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this 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.
Very appreciate it! |
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.