• 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
My line numbers view, drawAtPoint: is slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

My line numbers view, drawAtPoint: is slow


  • Subject: My line numbers view, drawAtPoint: is slow
  • From: Bertrand Mansion <email@hidden>
  • Date: Sun, 25 May 2003 23:50:36 +0200

Hi,

I am trying to get my line number view to work as fast as possible and
unfortunately, it's very slow, even when there isn't a lot of lines in it :(

I have made a NSView that holds a NSScrollView subclass for my text and a
NSView subclass for my numbers. This architecture seems to work.

But when I draw the line numbers using drawAtPoint: withAttributes:, it
slows the scrolling incredibly. When I comment drawAtPoint:, the scrolling
scrolls at normal speed.

I have read in the list archives that when the view is flipped, drawAtPoint
is supposed to be faster. I have also read that it could be even faster to
draw in an NSImage and just display the image.

I don't know which solution is better for me, knowing that drawRect: is
called very often and it can be intensive.

Do you have any clues ?

Here is the code with the drawAtPoint that slows things down:

// Line number counting and drawing loop
for (i = 0, lines = 1; i < numberOfGlyphs; lines++) {
r = [self convertRect:[lm lineFragmentRectForGlyphAtIndex:I
effectiveRange:&lineRange]
fromView:[_mainView textView]];

if (NSPointInRect(r.origin, rect)) {
s = [NSString stringWithFormat:@"%d", lines, nil];
reqWidth = [s sizeWithAttributes:attr].width;
p = NSMakePoint((leftMarginWidth - reqWidth), r.origin.y);
[s drawAtPoint:p withAttributes:attr]; // <-- VERY SLOW
}

i = NSMaxRange(lineRange);
}

Thanks in advance,

Bertrand Mansion
Mamasam
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Picture parameters
  • Next by Date: Re: Recommendations for scripting/extension languages for Cocoa
  • Previous by thread: highlightSelectionInClipRect
  • Next by thread: Re: Recommendations for scripting/extension languages for Cocoa
  • Index(es):
    • Date
    • Thread