• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Redraw Problem with Layer-Backed View in Scroll View
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redraw Problem with Layer-Backed View in Scroll View


  • Subject: Re: Redraw Problem with Layer-Backed View in Scroll View
  • From: Troy Stephens <email@hidden>
  • Date: Thu, 8 Nov 2007 10:34:21 -0800

On Nov 8, 2007, at 7:34 AM, Drew Mccormack wrote:
I have a strange redraw problem for a layer-backed view that I have nested in an NSScrollView. The problem persists regardless of whether I also make the scroll view layer-backed.

The problem is this: When the layer-backed view redraws, it seems to fade in. Without the scroll view, everything draws as expected, but with the scroll view, it looks like the view is flashing. I have put a video online showing the effect:

http://tb.chem.vu.nl/~cormack/Public/Cocoa/CoreAnimationScrollViewProblem.mov

Some other facts:

- Subviews of the layer-backed view seem to redraw fine, and do not fade in (see video)
- Scrolling the scroll view also works fine, with no drawing issues
- I have not set any CA effects for the view, such as transitions etc.


Has anyone else seen this and/or know a workaround?


Hi Drew,

The fade-in is due to NSScrollView's use of a tiled backing layer for its document view, to allow accommodating document views that exceed the maximum size for an ordinary CALayer (which is effectively the maximum texture size supported by the graphics hardware).

This is pointed out in the Leopard AppKit release notes -- relevant section excerpted below. If choosing an appropriate backgroundColor for your NSScrollView (as suggested in the relnotes) isn't sufficient to acceptably minimize the fade-in effect, you might consider using an ordinary empty NSView as your ScrollView's "document" view, and placing your actual document view in that view as a subview. That will prevent your actual document view from being assigned a tiled backing layer. You will need to be careful, however, that your document view does not exceed the 2046x2046 pixel size limit. If it does, you will need to break it up into contiguous sibling views of that size or less (i.e. do the tiling yourself) to make it possible to render your document content in layer-backed mode.


Excerpt from the Release Notes: (http://developer.apple.com/releasenotes/Cocoa/AppKit.html)

Layer Size Limits and Tiled Layers (New since WWDC 2007 Seed)

One inherent limitation of rendering view content into a Core Animation layer is that the size of ordinary CALayers is constrained by the maximum OpenGL texture size supported by the host system's graphics hardware. On most current graphics hardware the effective limit is 2046x2046 pixels, beyond which size layer creation will fail. Care should therefore be taken to insure that layer-backed views do not exceed this size limit.

To get around this limitation for potentially larger document views, AppKit employs CATiledLayers to serve as the backing layers for the document views of NSScrollViews. This specialized layer type caches its content in a grid of "tiles" (of default size 256x256 pixels) that are drawn as they become visible, and can be garbage-collected when they go out of view. From the user's perspective, the tiles are added asynchronously as they are revealed during scrolling. The visual appearance of the tile addition can be minimized by enabling the "drawsBackground" property for the enclosing NSScrollView (or, equivalently, its NSClipView), and choosing a background color that most closely matches the document view content being drawn.

Note that when using layer-backed mode for an NSScrollView's document view, it's necessary for the enclosing NSScrollView, or at least its NSClipView ("content view"), to also be layer-backed in order for scrolling to function correctly.



-- Troy Stephens Cocoa Frameworks Apple, Inc.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Redraw Problem with Layer-Backed View in Scroll View
      • From: Drew Mccormack <email@hidden>
References: 
 >Redraw Problem with Layer-Backed View in Scroll View (From: Drew Mccormack <email@hidden>)

  • Prev by Date: Re: Interface Builder "layout" versus "frame"
  • Next by Date: Re: Best pattern to follow for scheduling an event
  • Previous by thread: Redraw Problem with Layer-Backed View in Scroll View
  • Next by thread: Re: Redraw Problem with Layer-Backed View in Scroll View
  • Index(es):
    • Date
    • Thread