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

Support for Pattern transformation. #2263

Merged

Conversation

msft-Jeyaram
Copy link
Contributor

fixes #2108


// Draw it in device space, so transformation is not applied to the render target.
coordinateMode = _kCGCoordinateModeDeviceSpace;
geometry.Attach(transformedGeometry.Detach());
Copy link
Contributor Author

@msft-Jeyaram msft-Jeyaram Mar 17, 2017

Choose a reason for hiding this comment

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

note: As per D2D DrawGeo.. a transformed geometry will have a thinner line width, than an untransformed geometry + transformation.

Working on a fix in the coming iteration. #Resolved

@DHowett-MSFT
Copy link

DHowett-MSFT commented Mar 17, 2017

Do we have any tests for stroking with a pattern brush? #Resolved

@msft-Jeyaram
Copy link
Contributor Author

msft-Jeyaram commented Mar 17, 2017

@DHowett-MSFT TEST_P(CGPatternColoredRectBasedStroke, PatternStrokeRegion) {
Cover the stroke #Resolved

CGContextFillRect(context, bounds);
}

DRAW_TEST_F(CGPatternTests, PatternFillTransformationWindowsLogoTranslate, UIKitMimicTest<>) {
Copy link

@DHowett-MSFT DHowett-MSFT Mar 17, 2017

Choose a reason for hiding this comment

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

these can be parameterized on CGAffineTransform #ByDesign

Copy link

@DHowett-MSFT DHowett-MSFT Mar 17, 2017

Choose a reason for hiding this comment

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

also, we don't know what happens to stroke pattern brushes under transformation #Resolved

Copy link

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

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

I cannot review this in time for my vacation, but I am not going to leave it with an ❌

I recuse myself from review.

@msft-Jeyaram msft-Jeyaram force-pushed the FixRotationPatternBrush_3 branch 2 times, most recently from bab9b92 to 859f25f Compare March 22, 2017 21:55
@@ -144,15 +143,23 @@ inline void ComputeStrokeStyle(ID2D1DeviceContext* deviceContext) {
ComPtr<ID2D1Factory> factory;
deviceContext->GetFactory(&factory);

ComPtr<ID2D1Factory1> factory1;
Copy link
Contributor

@rajsesh rajsesh Mar 23, 2017

Choose a reason for hiding this comment

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

factory1 [](start = 30, length = 8)

factory.As(&factory1)? also no need for fail fasts here, we will crash right afterwards anyway. #Resolved

…ion, scaling or translation.

Thus any transformation that is done to the context, should only be applied to the context and not the CGPattern image.
CGPattern image, which is drawn via the callback should be treated like an image.
Adding image scaling and proper sizing to the user drawn CGPattern image.
…to the render target.

Thus this way, any transformation to the context is applied to the geometry before being drawn (vs. applying the geometry to the render target the drawing).
This will allow sub-mechanism (e.g brushes) to keep their proper orientation while being drawn.

This is funneled through Draw() function, thus since the geometry is already transformed, the coordinate mode is set to _kCGCoordinateModeDeviceSpace to ensure
that transform is not applied to the render target.
The line width should not subject to transformation (but should respect DPI).
Fixing the Stroke so that it does not apply the transformation to the stroke,
but respect the DPI values (e.g thicker/thinner).
Also including CoreGraphics vs UIKit based tests.
@msft-Jeyaram msft-Jeyaram force-pushed the FixRotationPatternBrush_3 branch from d81e803 to bce05fa Compare March 23, 2017 04:13
- GetBoundingBox
- PathApplyControlPointsQuadCurve
- PathApplyControlPointsArcs
- PathApplyControlPointsArcsSimple

These tests had the wrong reference image, also these are UIKit based tests.
Currently, UIKit mimicking of 2x scaling for strokes is not implemented.
@msft-Jeyaram msft-Jeyaram force-pushed the FixRotationPatternBrush_3 branch from bce05fa to 21fc872 Compare March 23, 2017 05:33
@msft-Jeyaram msft-Jeyaram merged commit 1903d21 into microsoft:develop Mar 23, 2017
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.

CGPattern CTM rotation should not affect the brush
4 participants