Create drawing tests for Core Text#1503
Conversation
| #include <memory> | ||
|
|
||
| #include <CoreFoundation/CoreFoundation.h> | ||
| #include <UIKit/UIKit.h> |
There was a problem hiding this comment.
#ifdef WINOBJC
// NOTE or whatever
#import <UIKit/UIKit.h>
static void anchorUIKit() { [UIView class]; }
#endifThis change set introduces DRAW_TEST and DRAW_TEST_F, as well as a handful of image drawing test fixtures. Commands rendered to a test's context as part of its test body will be rasterized and saved in a file named TestImage.$TESTCASE.$TESTNAME.png The test driver's ideal interface is multi-modal; it needs to be able to generate a corpus of reference images on disk, and it needs to be able to diff them. For this, it needs a custom EntryPoint (included), and the ability to parse command-line arguments. The ideal default mode will be one that loads reference images from disk and fails tests if a number of pixels differ. That work is not yet complete. Hopefully, the draw tests here will be able to be plugged into another module that can perhaps render them to screen, or display them as part of a UI-driven flow for comparison and demoing purposes. Refs microsoft#1271.
…t failure. (microsoft#1438) CoreGraphics.Drawing.UnitTests can now be invoked in one of two modes, mediated by command line flags: * `--compare[=/path/to/reference/folder]` (_default mode_) compare all rendered images against their baselines, failing the test if any images differ by even a single pixel. * `--generate [--out=/path/to/output/directory]` generate output images only (do not run comparisons.) A failing test will emit a brightly-colored diff image to `Greenlines.TestImage.CASE.TEST.png` in the _output directory_, and attach attributes to the gtest output XML data specifying where to find the images. A compatible test runner can load these images and display them side-by-side. **Open Questions/Concerns** * I do not like the design of `rgba/bgraPixels`. * I do not take stride into account; if the image is width-padded, the tests will ikely fail. * The reference platform loads images in RGBA, and we load them in BGRA. This is not an incompatibility, but it does make manual buffer manipulation dicey. * The fix here is to render the image into a NEW context, but that presents a few issues of its own: * We must trust our DrawImage function * We must further validate bitmap context, and trust our bitmap context as an integral part of test execution. * All tests will be disabled as of the merge of microsoft#1434. We can re-enable them and reintroduce reference images after build validation. Closes microsoft#1271.
|
Updated tests with custom font, squashed into two commits, and rebased on top of develop |
|
When you merge this, please make sure to use the [Merge] Option. This will make conflict resolution in the CGD2D branch easier, as the commits have been cherry-picked. |
|
The Rebase option may work as well. |
|
Updated to disable tests on build machines, which seem to have minor differences in text drawing. Not sure if this is worth investigating. Tests can be run by enabling disabled tests |
| </ProjectReference> | ||
| <ProjectReference Include="..\..\..\WinObjCRT\dll\WinObjCRT.vcxproj"> | ||
| <Project>{585b4870-0d6b-43a6-8e7e-ad08f7f507b6}</Project> | ||
| </ProjectReference> |
There was a problem hiding this comment.
haven't gotten to the rest of the review yet but right now i'm skeptical that you need this? #Closed
There was a problem hiding this comment.
The vcxproj or this reference? #ByDesign
There was a problem hiding this comment.
There was a problem hiding this comment.
Apparently required for SmartTypes #ByDesign
In reply to: 91159703 [](ancestors = 91159703,91159582)
| uint32_t unusedIndex; | ||
| RETURN_IF_FAILED(_userCreatedFontCollection->FindFamilyName(fontFamilyName, &unusedIndex, &userCreatedFont)); | ||
| if (userCreatedFont) { | ||
| return dwriteFactory->CreateTextFormat(fontFamilyName, |
There was a problem hiding this comment.
ah geez i need to think about this in the context of my CR, but, is this actually needed? shouldn't usercreatedfontcollection have been registered to the factory?
There was a problem hiding this comment.
It's registered but this only uses the given font collection, or system font collection if nullptr
There was a problem hiding this comment.
| CGContextScaleCTM(ctx, 1.0f, -1.0f); | ||
|
|
||
| for (size_t i = 0; i < frame->_lineOrigins.size(); ++i) { | ||
| for (size_t i = 0; i < frame->_lineOrigins.size() && frame->_lineOrigins[i].y < frame->_frameRect.size.height; ++i) { |
| // Forces run breaks without interfering with any layout features | ||
| // Necessary for attributes which DWrite does not support during layout (e.g. Color) | ||
| RETURN_NULL_IF_FAILED(typography->AddFontFeature({ DWRITE_FONT_FEATURE_TAG_KERNING, ++incompatibleAttributeFlag })); | ||
| } |
There was a problem hiding this comment.
note to self to incorporate this for my CR if this gets in first
| #endif | ||
|
|
||
| #ifndef MAX_PATH | ||
| #define MAX_PATH PATH_MAX |
There was a problem hiding this comment.
er, any reason why we can't just standardize on the underscore version?
There was a problem hiding this comment.
I believe @DHowett-MSFT said underscoreless is standard?
There was a problem hiding this comment.
Yeah: MAX_PATH lives in minwindef standalone and _MAX_PATH lives in stdlib with proximity to the standard library path functions.
| CGBlendMode blendMode; | ||
| }; | ||
|
|
||
| CGNamedBlendMode porterDuffBlendModes[] = |
There was a problem hiding this comment.
static const, c_
same for your other constants below #WontFix
There was a problem hiding this comment.
Will leave the CG* tests for @DHowett-MSFT to clean up :D
| @@ -0,0 +1,105 @@ | |||
| //****************************************************************************** | |||
There was a problem hiding this comment.
This file has a lot of duplicated code. Can you refactor it into reusable functions or parameterized tests?
There was a problem hiding this comment.
I'll take this on as I wrote this code. I'm hoping to reduce merge conflicts from develop in the meantime.
| @@ -0,0 +1,52 @@ | |||
| //****************************************************************************** | |||
There was a problem hiding this comment.
same with this file, to a lesser extent
| CFStringRef keys[2] = { kCTFontAttributeName, kCTParagraphStyleAttributeName }; | ||
| CFTypeRef values[2] = { myCFFont.get(), paragraphStyle.get() }; | ||
|
|
||
| woc::unique_cf<CFDictionaryRef> dict{ CFDictionaryCreate(nullptr, |
There was a problem hiding this comment.
can probably refactor 389-403 here to a separate function, possibly 403-416 as well (would exclude CTRun, BasicDrawingTest, WhiteBackgroundTest though)
| } | ||
|
|
||
| CFStringRef _CFStringCreateAbsolutePath(CFStringRef relativePath) { | ||
| std::unique_ptr<char[]> owningFilenamePtr; |
There was a problem hiding this comment.
85-101 here is repeated from above
|
nit: CoreGraphics.Drawing > CoreGraphics.drawing, probably |
|
🕐 |
|
|
ms-jihua
left a comment
There was a problem hiding this comment.
Discussed offline - in the interest of ease of merging with CGD2D, code quality-related comments will be taken care of separately at a later time by @DHowett-MSFT
|
Updated with changes to CTDrawingTests |
|
|
Cherry picks @DHowett-MSFT's framework for image comparison tests and adds several tests for supported Core Text draw methods and options. Fixes small issues found when comparing against reference platform results and when using custom fonts, but now compares against images generated by our platform for pixel comparison. All differences between our platform and the reference platform are documented in #1502.
This change is