NSWindow and Core Anim - flickering

  • Hello All,

    I have an NSWindow instance that is entirely transparent (background
    color of the window has alpha with 0) which is sitting over another
    NSView that has its content rendered via Core Animation, lets call
    this the 'backdrop'.  The 'backdrop' is rendering arbitrarily complex
    CALayer hierarchies via CAOpenGLLayer.

    On this 'overlay' NSWindow [that is sitting above the 'backdrop'], I
    have placed another NSView - lets call it the 'preview'.

    When the 'preview' view is moved around, there is quite a lot of
    flickering going on, almost for every movement of the mouse (but not
    quite).  The flickering is restricted to the bounds of the 'preview'
    view.

    If I change the code ever so slightly; and tell the 'overlay' that it
    wants a layer, like this:
    overlay.wantsLayer = YES;

    then run the code again - the *entire* overlay window area flickers
    like mad.

    I am more than happy to post snippets of code as required.  Does
    anyone have an idea of what this might be?

    The window is init'd like this:

    - (id)initWithContentRect:(NSRect)contentRect
        styleMask:(unsigned int)styleMask
                     backing:(NSBackingStoreType)bufferingType
        defer:(BOOL)deferCreation
    {
    NSWindow* me = [super initWithContentRect:contentRect
          styleMask:NSBorderlessWindowMask
                                 backing:NSBackingStoreBuffered
            defer:YES];

    NSColor *blackTransparent =
      [NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:0.0];
    [me setBackgroundColor:blackTransparent];

    [me setIsVisible:NO];
    [me setHasShadow:NO];
    [me setAcceptsMouseMovedEvents:YES];
    [me setExcludedFromWindowsMenu:YES];
    [me setIgnoresMouseEvents:NO];
    [me setMovableByWindowBackground:NO];
    [me setHidesOnDeactivate:NO];
    [me setOpaque:NO];

    // add a single view as the 'contentView', which is the same size as
    the window and stretches
    // appropriately to fit the content size
    NSRect viewFrame = contentRect;
    viewFrame.origin.x = 0;
    viewFrame.origin.y = 0;
    NSView* content = [[NSView alloc] initWithFrame:viewFrame];
    [content setAutoresizesSubviews:YES];
    [content setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
    [self setContentView:content];

      // if I enable this line below; flickering is seen across the
    entire NSWindow frame when the 'preview'
    // view is moved across it (this whole window is sitting on top of a
    layer-backed view)
    // content.wantsLayer = YES;

    return me;
    }
  • On Nov 20, 2007, at 4:11 AM, John Clayton wrote:

    > NSWindow* me = [super initWithContentRect:contentRect

    Why are you creating a new window instead of initializing self as one
    would expect in any normal -init... method?

    -jcr

    John C. Randolph,
    VP, Engineering
    Stealth Imaging, LLC. <jcr...>
  • On Nov 21, 2007 7:17 AM, John C. Randolph <jcr...> wrote:
    >
    > On Nov 20, 2007, at 4:11 AM, John Clayton wrote:
    >
    >> NSWindow* me = [super initWithContentRect:contentRect
    >
    > Why are you creating a new window instead of initializing self as one
    > would expect in any normal -init... method?

    He is initializing himself using his super classes init method,
    granted his naming scheme is a little unusual... just replace "me"
    with "self" and do away with the NSWindow* me local var.

    -Shawn
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today