Re: Redraw Problem with Layer-Backed View in Scroll View
Re: Redraw Problem with Layer-Backed View in Scroll View
- Subject: Re: Redraw Problem with Layer-Backed View in Scroll View
- From: Drew Mccormack <email@hidden>
- Date: Fri, 9 Nov 2007 14:25:21 +0100
On 8 Nov 2007, at 19:34, Troy Stephens wrote:
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.
Hi Troy,
Thanks for the explanation; I wasn't aware of the issue.
It still seems strange to me though. It's like the tiles have a bad
default set for the order in effect, ie, it is set to fade in instead
of none.
When the tiled layer is used, I would expect that if I scroll too
fast, the tiles would not have time to draw, and that I'd see a bit of
the scroll view's background. But I would think that once the drawing
is complete, it should appear immediately on the screen --- I don't
see why it would fade in.
In case you want another look, the movie demonstrating the problem is
here:
http://tb.chem.vu.nl/~cormack/Public/Cocoa/CoreAnimationScrollViewProblem.mov
Kind regards,
Drew
_______________________________________________
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