-
Notifications
You must be signed in to change notification settings - Fork 806
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
Use _CGContextPushBegin/PopEndDraw for Drawing Tests #1870
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ | |
#include <Starboard/SmartTypes.h> | ||
#include <memory> | ||
|
||
#if WINOBJC // Test with _CGContextPushBegin/PopEndDraw | ||
#import "CGContextInternal.h" | ||
#endif | ||
|
||
static const CGSize g_defaultCanvasSize{ 512.f, 256.f }; | ||
|
||
template <typename TComparator> | ||
|
@@ -34,10 +38,14 @@ void testing::DrawTest<TComparator>::SetUp() { | |
CGSize size = CanvasSize(); | ||
|
||
auto deviceColorSpace = woc::MakeStrongCF<CGColorSpaceRef>(CGColorSpaceCreateDeviceRGB()); | ||
_context.reset(CGBitmapContextCreate( | ||
nullptr, size.width, size.height, 8, size.width * 4, deviceColorSpace, kCGImageAlphaPremultipliedFirst)); | ||
_context.reset( | ||
CGBitmapContextCreate(nullptr, size.width, size.height, 8, size.width * 4, deviceColorSpace, kCGImageAlphaPremultipliedFirst)); | ||
ASSERT_NE(nullptr, _context); | ||
|
||
#if WINOBJC // Validate that the results are correct even under batched drawing from _CGContextPushBegin/PopEndDraw | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why I didn't think of doing this earlier, sorry everyone! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might even be more correct to do this in CGBitmapContext. Here's what we can potentially do: If the user passes That way, people using This opens up some testing avenues that don't require internal implementation details (pass data, do not pass data, etc.). I do, however, think this is the right thing to do here until we normalize on a strategy for bitmap contexts. #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I'm not sure what you're envisioning for how we know if we control the data (will eventually call Create/GetImage). Leaving as-is for now. In reply to: 98318678 [](ancestors = 98318678) |
||
_CGContextPushBeginDraw(_context); | ||
#endif | ||
|
||
_bounds = { CGPointZero, size }; | ||
|
||
SetUpContext(); | ||
|
@@ -66,6 +74,10 @@ template <typename TComparator> | |
void testing::DrawTest<TComparator>::TearDown() { | ||
CGContextRef context = GetDrawingContext(); | ||
|
||
#if WINOBJC // Validate that the results are correct even under batched drawing from _CGContextPushBegin/PopEndDraw | ||
_CGContextPopEndDraw(_context); | ||
#endif | ||
|
||
// Generate image from context. | ||
woc::unique_cf<CGImageRef> image{ CGBitmapContextCreateImage(context) }; | ||
ASSERT_NE(nullptr, image); | ||
|
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.
saddest comment. can you reflow this so clang-format doesn't? 😄 #Resolved