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

Adding support for ClearRect with clipping geometry #2053

Merged
merged 3 commits into from
Feb 24, 2017

Conversation

msft-Jeyaram
Copy link
Contributor

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.

There are some test files named 2001 and 2002 as well; I can't find the tests that created them!


HRESULT __CGContext::ClearRect(CGRect rect) {
PushBeginDraw();
auto endDraw = wil::ScopeExit([this]() { PopEndDraw(); });
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

This will ignore the antialias modes set in @MSFTFox's change #Resolved

auto endDraw = wil::ScopeExit([this]() { PopEndDraw(); });

ComPtr<ID2D1RectangleGeometry> rectangle;
RETURN_IF_FAILED(Factory()->CreateRectangleGeometry(__CGRectToD2D_F(rect), &rectangle));
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

Consider caching the ID2D1Factory. #Resolved

RETURN_IF_FAILED(deviceContext->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 0.0f), &brush));

deviceContext->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_COPY);
deviceContext->FillGeometry(CurrentGState().clippingGeometry.Get(), brush.Get());
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

I wonder how this works in combination with transparency layers. Can you do a test on our platform and the reference platform where you draw red, begin a transparency layer, draw blue, clear a sub-region, and end the layer? I'd expect the blue to have a "hole" in it where the red is visible. #Resolved

}
};

TEST_P(CGClearRect, Transformed) {
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

These must be DRAW_TEST_P for TAEF. #Resolved


return CFStringCreateWithFormat(nullptr,
nullptr,
CFSTR("TestImage.CGContext.ClearRect.rect.(%0.0f.%0.0f)%0.0fx%0.0f.transformationAffine.[%0.1f,%0."
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

nit: filename doesn't need the word rect or transformationAffine in it. #Resolved

Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

@msft-Jeyaram we are running up against Windows' relatively short MAX_PATH. Please reduce these filenames. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we haven't :D but fine :)


In reply to: 102779346 [](ancestors = 102779346)


CGContextAddRect(context, CGRectMake(0, 0, 250, 250));
CGContextConcatCTM(context, transformation);
CGContextClip(context);
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

Is this a test for two different clipping regions? #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i would of made both of them parameterized but then we would end up with a spew of files.


In reply to: 102640945 [](ancestors = 102640945)

}

static CGRect rects[] = { CGRectMake(0, 0, 100, 100), CGRectMake(0, 0, 50, 250), CGRectMake(100, 100, 125, 250) };
static CGAffineTransform transformation[] = { CGAffineTransformMakeRotation(0.4),
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

include an identity test! #Resolved

CGClearRect,
::testing::Combine(::testing::ValuesIn(rects), ::testing::ValuesIn(transformation)));

DRAW_TEST_F(CGContextRectClear, ClearRect, WhiteBackgroundTest<>) {
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

you can remove RectClear from this test name; it's implied and it's part of CGContext. #Resolved

CGContextClearRect(context, borderRect);
}

DISABLED_DRAW_TEST_F(CGContextRectClear, ClearRectRam, WhiteBackgroundTest<>) {
Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

Disabled?

This one is named Ram; perhaps Arc is better!

Also, why is it disabled? #ByDesign

CGRect bounds = GetDrawingBounds();

CGRect cirleRect = CGRectMake(0, 0, 100, 100);
CGContextAddArc(context, 50, 50, 50, 0.0, 2 * M_PI, 0);
Copy link
Contributor Author

@msft-Jeyaram msft-Jeyaram Feb 23, 2017

Choose a reason for hiding this comment

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

when we attempt to fill the geometry with an arc.
The fill is a success but the rendering doesn't show any signs of being filled.
I tried with a custom circle geometry of the same size and it works.
investigating, it looks like some issues with the arc geometry. #ByDesign

Copy link

@DHowett-MSFT DHowett-MSFT Feb 23, 2017

Choose a reason for hiding this comment

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

that's not good. please file an issue and tag this code with that issue. #Resolved

PushBeginDraw();
auto endDraw = wil::ScopeExit([this]() { PopEndDraw(); });

auto factory = Factory();
Copy link
Contributor

@aballway aballway Feb 23, 2017

Choose a reason for hiding this comment

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

nit: shouldn't use auto for this since type isn't specified on right/unrepresentable #Resolved

RETURN_IF_FAILED(CurrentGState().IntersectClippingGeometry(transformedRectangle.Get(), kCGPathEOFill));

ComPtr<ID2D1SolidColorBrush> brush;
RETURN_IF_FAILED(deviceContext->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 0.0f), &brush));
Copy link
Contributor

@rajsesh rajsesh Feb 23, 2017

Choose a reason for hiding this comment

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

Nit: this should be in the gstate as a clear brush, we are likely creating too many brushes. #Resolved

@msft-Jeyaram
Copy link
Contributor Author

@DHowett-MSFT @rajsesh-msft Ping

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.

5 participants