Core Animation: Layer vs NSTextView

  • Is the Layer mode of Core Animation compatible with NSTextView?

    I'm seeing the following issues when I enable setWantsLayer: for a
    hierarchy that includes a NSTextView:

    - while my NSTextView is supposed to have a transparent background
    (thanks to a subclass of NSScrollView), it is no more transparent with
    the layer mode.

    - when I fill the NSTextView with the content of a medium size text
    file (24 KB) using the readFromURL... NSTextStorage API, it takes 8
    seconds to display the file in the text view. It's instantaneous
    without the layer view mode enabled.

    I'm also seeing strange animation when I run a fade in/fade out
    animation to hide a NSScrollView (that includes a NSTextView) and
    display a simple NSView with a NSTextField. The verticall scroller of
    the NSScrollView does not seem to be aware there is fading effect until
    the animation is completed.

    Are there some tricks to use to deal with Core Animation and NSTextView?
  • that should work.

    Although it's possible that there is a bug.

    From the release notes

    Most of the standard views and controls that AppKit and Mac OS X's
    other Cocoa frameworks provide are able to function in layer-backed
    mode in Leopard, with the exception of certain specialized views such
    as WebKit WebViews and Quartz Composer QCViews, whose use in layer-
    backed mode is not presently supported.

    On Nov 1, 2007, at 1:21 PM, Stéphane Sudre wrote:

    > Is the Layer mode of Core Animation compatible with NSTextView?
    >
    > I'm seeing the following issues when I enable setWantsLayer: for a
    > hierarchy that includes a NSTextView:
    >
    > - while my NSTextView is supposed to have a transparent background
    > (thanks to a subclass of NSScrollView), it is no more transparent
    > with the layer mode.

    I'd file this one (send me the number please)

    >
    >
    > - when I fill the NSTextView with the content of a medium size text
    > file (24 KB) using the readFromURL... NSTextStorage API, it takes 8
    > seconds to display the file in the text view. It's instantaneous
    > without the layer view mode enabled.
    >

    When a layer is created and cached it does allocate memory for
    storage.. but that seems a bit to long.  Have you sampled it?

    > I'm also seeing strange animation when I run a fade in/fade out
    > animation to hide a NSScrollView (that includes a NSTextView) and
    > display a simple NSView with a NSTextField. The verticall scroller
    > of the NSScrollView does not seem to be aware there is fading effect
    > until the animation is completed.

    Can you define how you are running a fade in/fade out animation?  And
    why you want the views to be layer-backed anyways?

    >
    >
    > Are there some tricks to use to deal with Core Animation and
    > NSTextView?
    >
    >

    It seems like perhaps, yes.
  • Hi Stéphane,

    8 seconds seems anomalously long; I don't know what would cause that.
    But the fade-in behavior is an essentially unavoidable artifact of the
    need to use CATiledLayers to back the document views of NSScrollViews,
    to allow them to potentially exceed the 2046x2046 texture size limit.

    For the transparency issue: Can you describe the containing view
    hierarchy and specify which other views (ancestors of the NSTextView
    in particular) have "wantsLayer" enabled for them?  This sounds worthy
    of a bug report.

    As high-level guidance, I would say that single-line NSTextFields
    should be expected to be be fully functional and behave reasonably in
    layer-backed mode, but the tiling behavior used by multi-line
    NSTextViews as currently implemented probably makes them less
    desirable to use in layer-backed mode.  We'd like to pursue a better
    solution for layer backing of NSTextViews in the future, but that's
    where things currently stand for 10.5.

    Hope this helps,
    Troy

    On Nov 1, 2007, at 10:21 AM, Stéphane Sudre wrote:
    > Is the Layer mode of Core Animation compatible with NSTextView?
    >
    > I'm seeing the following issues when I enable setWantsLayer: for a
    > hierarchy that includes a NSTextView:
    >
    > - while my NSTextView is supposed to have a transparent background
    > (thanks to a subclass of NSScrollView), it is no more transparent
    > with the layer mode.
    >
    > - when I fill the NSTextView with the content of a medium size text
    > file (24 KB) using the readFromURL... NSTextStorage API, it takes 8
    > seconds to display the file in the text view. It's instantaneous
    > without the layer view mode enabled.
    >
    > I'm also seeing strange animation when I run a fade in/fade out
    > animation to hide a NSScrollView (that includes a NSTextView) and
    > display a simple NSView with a NSTextField. The verticall scroller
    > of the NSScrollView does not seem to be aware there is fading effect
    > until the animation is completed.
    >
    > Are there some tricks to use to deal with Core Animation and
    > NSTextView?
  • On jeudi, novembre 1, 2007, at 11:16  PM, Troy Stephens wrote:

    > Hi Stéphane,
    >
    > 8 seconds seems anomalously long; I don't know what would cause that.
    > But the fade-in behavior is an essentially unavoidable artifact of the
    > need to use CATiledLayers to back the document views of NSScrollViews,
    > to allow them to potentially exceed the 2046x2046 texture size limit.

    I think I will avoid the animation then (BTW, it's not a power of 2)

    > For the transparency issue: Can you describe the containing view
    > hierarchy and specify which other views (ancestors of the NSTextView
    > in particular) have "wantsLayer" enabled for them?  This sounds worthy
    > of a bug report.

    The hierarchy is as "simple" as this:

    NSWindow
      |
      +- ContentView (NSView?)
          |
          +- NSSplitView (thin separator used)
                |
                +- Custom View (Opaque subclass of NSView)
                    |
                    +- NSView
                          |
                          +- Custom View (Opaque subclass of NSView)
                                |
                                +- Custom View (subclass of NSView) (A)
                                      |
                                      +- ICBackgroundImageView  (subclass of
    NSImageView) (B)
                                            |
                                            +- Custom View (subclass of
    NSView)
                                                  |
                                                  +- ICScrollView (non
    opaque subclass of NSScrollView)
                                                        |
                                                        +-
    ICPresentationTextView (subclass of NSTextView)

    The problem appears when I call setWantsLayer: on A or B for instance.
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