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

fix bug when using UIColor presets #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ppaulojr
Copy link
Contributor

@ppaulojr ppaulojr commented May 5, 2016

There was a bug that in some cases could have glClearColor set to undefined value.

The cause of this bug is the method

+ (void)getColorComponentsFromCGColor:(CGColorRef)color
                                  red:(CGFloat *)red
                                green:(CGFloat *)green
                                 blue:(CGFloat *)blue
                                alpha:(CGFloat *)alpha

That supposed the CGColorSpaceRef returned by the UIColor was always kCGColorSpaceGenericRGB (see below)

- (void)setBackgroundColor:(id)backgroundColor
{
    _backgroundColor = backgroundColor;
    if (backgroundColor)
    {
        CGColorRef colorRef = [backgroundColor CGColor];
        CGFloat red; CGFloat green; CGFloat blue; CGFloat alpha;
        [EZAudioUtilities getColorComponentsFromCGColor:colorRef
                                                    red:&red
                                                  green:&green
                                                   blue:&blue
                                                  alpha:&alpha];
        //
        // Note! If you set the alpha to be 0 on mac for a transparent view
        // the EZAudioPlotGL will make the superview layer-backed to make
        // sure there is a surface to display itself on (or else you will get
        // some pretty weird drawing glitches
        //
#if !TARGET_OS_IPHONE
        if (alpha == 0.0f)
        {
            [self.superview setWantsLayer:YES];
        }
#endif
        glClearColor(red, green, blue, alpha);
    }
    else
    {
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    }
}

Notice that's not true when you pass as UIColor things like [UIColor whiteColor]

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.

1 participant