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

Colorspace support for CGColor and improvements to the class. #2244

Merged
merged 4 commits into from
Mar 20, 2017

Conversation

msft-Jeyaram
Copy link
Contributor

The CGColor is still a UIColor class [re-implementation is planned], but we have improved the functionality.

fixes #2041

@@ -0,0 +1,850 @@
//******************************************************************************
Copy link
Contributor

@aballway aballway Mar 16, 2017

Choose a reason for hiding this comment

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

.TMP 😆 #Resolved

@@ -226,6 +226,8 @@ @implementation UIColor {
UIImage* _image;
id _pattern;
__CGColorQuad _components;
// Note: This should be part of the CGColor struct
woc::StrongCF<CGColorSpaceRef> _colorSpace;
Copy link
Contributor

@aballway aballway Mar 16, 2017

Choose a reason for hiding this comment

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

I really don't think this is the way to fix this. This change set should be included in the separation of CGColor from UIColor, rather than piling on additional short term fixes in UIColor which will add more things to remove. #ByDesign

Copy link
Contributor Author

@msft-Jeyaram msft-Jeyaram Mar 16, 2017

Choose a reason for hiding this comment

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

Talked to raj regarding this, ideally, the whole thing should be fixed!
but given the load this iteration and the re-write is coming up, this should be sufficient.
as much as I don't like doing this, until the re-write happens this would fix up some stuff for us. #ByDesign

return nullptr;
if (ret) {
auto grayColorSpace = woc::MakeStrongCF<CGColorSpaceRef>(CGColorSpaceCreateDeviceGray());
[static_cast<UIColor*>(ret) setColorSpace:grayColorSpace];
Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

This is only the appropriate fix for black/white/clear! #Resolved

Copy link
Contributor Author

@msft-Jeyaram msft-Jeyaram Mar 16, 2017

Choose a reason for hiding this comment

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

the Caveat indicates it's limited. Should probably move it up so the 'future' is not clouded. #Resolved


RETURN_NULL_IF(!colorSpace);
RETURN_NULL_IF(!components);
CGColorRef ret = static_cast<CGColorRef>(
Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

it might be safe to assert that the #components in the color space is 3-4. Just so that we don't index beyond the end of components. #ByDesign

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.

hmm i don't want to do this, as it's only supporting RGB, not even grayscale.
This is not the main purpose of the CR. The main purpose is to move it to Add CGColorGetColorSpace only.


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

*/
size_t CGColorGetNumberOfComponents(CGColorRef color) {
return 4;
return CGColorSpaceGetNumberOfComponents(CGColorGetColorSpace(color)) + 1;
Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

this +1 is somewhat worrying #ByDesign

Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

specifically: not all colours have alphas #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.

this is based off of the limited support. Again a while fix to the colorspace is needed.


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

- (const __CGColorQuad*)_getColors;
- (BrushType)_type;
@property CGColorSpaceRef colorSpace;
Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

whoa boy, give this a lifetime and an atomicity specifier! #Resolved

#define EXPECT_EQ_COMPONENTS(a, b) \
EXPECT_EQ((a)[0], (b)[0]); \
EXPECT_EQ((a)[1], (b)[1]); \
EXPECT_EQ((a)[2], (b)[2]); \
EXPECT_EQ((a)[3], (b)[3])

DISABLED_TEST(CGColor, CGColorGetComponents) {
TEST(CGColor, CGColorGetComponents) {
Copy link

@DHowett-MSFT DHowett-MSFT Mar 16, 2017

Choose a reason for hiding this comment

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

it doesn't look like this test fixture anchors the UIKit symbols. #Resolved

@msft-Jeyaram
Copy link
Contributor Author

@DHowett @aballway ping!

… the class.

Note: Given CGColor is now implemented via UIColor, the var to hold the colorspace is added
int UIColor (in the Extended Interface). This should move to the CGColor struct when CGColor is implemented via CPPBase.

Implements:
CGColorGetColorSpace

The following Apis were improved:
CGColorGetConstantColor - now supports colorspace for (black,white, and clear)
CGColorCreate, CGColorCreateCopyWithAlpha & CGColorCreateWithPattern - create with an apporiate colorspace
CGColorRelease
CGColorEqualToColor
CGColorGetAlpha
…f the colorspace that is associated with

the CGColor.
Our Color is limited in support, we only support RGB & Grayscale colors.
…onents.

Enabling disabled tests + enhancing existing tests.
…to CGColor is an instance of UIColor (which is lazy loaded).

Thus for CGColorTests to run we need the UIKit DLL to be loaded.
Note: The CGColorTests are appended with [UIColor class] to support the UIKit dll to be part of the test run.
@msft-Jeyaram msft-Jeyaram merged commit f5d89da into microsoft:develop Mar 20, 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.

Implement some colorspace apis (with caveats)
4 participants