Re: Threading synchronization: does a primitive exists?
On May 7, 2011, at 6:00 PM, Chris Hanson wrote: > The thing to remember about NSConditionLock is that it's a lock that can only > be acquired when it's in the specified condition. That sentence is a bit confusing. It can be read two ways, one of which is correct, the other incorrect. If one chooses, one can request to lock an NSConditionLock only when it's in a specified condition. However, one can also unconditionally lock it, too. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing onto CVPixelBuffer
Have you taken a look at the CaptureAndCompressIPBMovie sample code? That code does something very similar to what you appear to be in need of. On May 6, 2011, at 5:30 PM, Jean-Daniel Dupas wrote: > > > Le 6 mai 2011 à 22:22, eveningnick eveningnick a écrit : > >> Hi >> I have a CVPixelBuffer with some background picture. >> I need to draw on this background some foreground image. I don't need >> to preserve the initial CVPixelBuffer's content - i just need to add a >> small foreground watermark onto that buffer. >> >> CIImage does allow to create an image from CVPixelBuffer and paint >> something on top of it (using Core Image filters), but CIImage is >> "read only" - it takes a source image and generates a brand new image >> in a new buffer. >> I can't afford one more copying, that greatly slows things down, >> because the CVPixelBuffer itself is kind of big. And there are a lot >> of them per second (they are generated as frames from a movie). >> >> Is there any way i could draw without such a copy? Maybe there is any >> other imaging framework that allows me to work with CVPixelBufferRef? >> Or should i just 'CVPixelBufferLock' the buffer, and copy raw bytes >> onto the buffer from my source NSImage (that contains the foreground >> image) directly using a loop? This doesn't seem the right way though. >> Could you please help me, what is better to do here? > > > If your pixel buffer has a format supported by the CGBitmapContext API, you > can use the later to draw into it. > > Create a CGBitmapContext using the memory from you CVPixelBuffer, and draw > using the CGContext API. > > -- Jean-Daniel > > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/douglas_welton%40earthlink.net > > This email sent to douglas_wel...@earthlink.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView and NSTextContainer size & clipping area
We need to see your code. In general, any drawing code after the call to super in the textView's drawRect method will draw. But maybe you are trying to do something different. On May 7, 2011, at 3:13 AM, Дмитрий Николаев wrote: > But when i try draw a line in NSTextView, it limited to frame of text > container too. > > 06.05.2011, в 22:56, Ross Carter написал(а): > >> On May 6, 2011, at 2:40 AM, Дмитрий Николаев wrote: >> >>> If there are any possibility to draw inside text view but outside of text >>> container ? >> >> It depends on who is doing the drawing. NSTextView is an NSView subclass and >> you can override drawRect: just like any NSView. The Cocoa text system, >> however, draws inside the area specified by a NSTextContainer. > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting NSWindow's contentBorderThickness working on a transparent window
Hello, When an NSWindow's backgroundColor is set to clear (and it is non-opaque), setting the bottom contentBorderThickness seems to have no effect, other than changing the resize-indicator's metrics. Is there any way to get this working without relying on drawing the border myself? Thank you, Dimitri Bouniol___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Threading synchronization: does a primitive exists?
The thing to remember about NSConditionLock is that it's a lock that can only be acquired when it's in the specified condition. So for example, the lock can start in condition 0. Thread B can lock when in condition 0 while thread A can simultaneously lock when the condition is 1. This means thread B acquires the lock, and thread A blocks on a change in the lock's condition. Thread B then unlocks with condition 1, so thread A can then acquire the lock. - (void)threadA:(id)object { // a lock for coordination between multiple threads NSConditionLock *lock = [[NSConditionLock alloc] initWithCondition:0]; // start thread B [NSThread detachNewThreadSelector:@selector(threadB:) toTarget:self withObject:lock]; // wait for thread B to do something [lock lockWhenCondition:1]; // be sure lock is unlocked before releasing it (on thread which created it) [lock unlockWithCondition:0]; [lock release]; // do whatever } - (void)threadB:(id)object { NSConditionLock *lock = object; [lock retain]; // acquire lock immediately [lock lockWhenCondition:0]; // do whatever thread A needs to wait for // unlock in a state that allows thread A to run [lock unlockWithCondition:1]; [lock release]; } Hope this helps! -- Chris On May 5, 2011, at 12:08 PM, eveningnick eveningnick wrote: > Ken, > Thanks for a detailed response > Still not sure how would it be possible to do using NSConditionLock, > but i managed to do it using NSCondition :) > > > 2011/5/5 Ken Thomases : >> On May 5, 2011, at 8:51 AM, eveningnick eveningnick wrote: >> >>> 2011/5/5 Heath Borders : Try NSConditionLock. Its documentation should be pretty self-explanatory. >>> >>> Health, >>> thanks for the response. >>> However, i can't see how can i use NSConditionLock in my situation. >>> For every lock (or mutex/semaphore - which essentially is the same) i >>> need to acquire it 1 time at least to stop the the thread when a >>> second attempt to acquire it from a different thread is made. >>> What i need - is to stop the thread A immediately after the thread B >>> has been spawned by a thread A. I am afraid if i acquire the lock from >>> A, and then acquire it as soon as B starts (in B routine), the thread >>> A may even finish before the thread B _actually_ starts (or rather B's >>> threadfunction starts executing). >>> Am i wrong somewhere here? >> >> NSConditionLock allows one to lock waiting for specific conditions. The >> lock can be created in an initial condition, say THREAD_B_NOT_RUNNING. >> Then, Thread A can spawn B and lock waiting for condition THREAD_B_RUNNING. >> Thread B can take the lock unconditionally and, when it's ready, unlock it >> with condition THREAD_B_RUNNING. Or whatever. >> >> Other possible techniques include using a pipe to send a signal byte from >> one thread to the other. So, thread A would do a blocking read from the >> pipe. Thread B would write a single byte to the pipe to signal whatever >> condition. >> >> There are all sorts of other approaches. >> >> Regards, >> Ken >> >> > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/cmh%40me.com > > This email sent to c...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Communicate Between CocoaAsyncSocket and Java Socket
On May 7, 2011, at 1:50 PM, Bing Li wrote: > I attempt to use CocoaAsyncSocket to communicate with Java server/client. Is > it possible to achieve the goal? Yes, at least in the abstract; TCP is TCP. You don't need to use CocoaAsyncSocket if you don't want to - you can just use the BSD-level socket(2) API if you like. Or you can use NSFileHandle or CFSocket. Or any of a number of other wrappers. -- Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: No current point for control point bounds
On 6 May 2011, at 7:24 PM, Indragie Karunaratne wrote: > I'm hesitant on filing a bug for this because it appears that there is no > such check on *later* versions of OS X ;-) Always file. It won't hurt their feelings. If, hypothetically, you don't find a diagnostic in prerelease software, it may be because it hasn't been put back yet. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UISegmentedControl and Table View
Ok, so I have the segmented control working in terms of changing the views. But then issue I am having is getting the the table views to load with their own data based on the selected seg (like the view on Apple's iPhone Apple Store app after you've search for a store. I have a Tab Bar too.). I already have the model (using Core Data) for the view but I'm having some issues trying to figure out how to connect the dots. I found a few different ways online but nothing really works. Does anybody have any ideas how to do this? Thanks, -T.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Table view with NSImageCell scrolls A LOT slower with bindings than with dataSource
Hi all, I have a table view with all columns bound to keys of an NSArrayController. The array controller implements some data source methods, mainly for drag and drop support. One of the columns uses an NSImageCell to display 32 x 32 icons. Scrolling the table view vertically gets very slow if the icons's column is within the table view's visible portion. Surprisingly, it gets a lot faster if I implement - tableView:objectValueForTableColumn:row: in the data source (= the array controller). - tableView:objectValueForTableColumn:row: returns the value for the corresponding key, which is exactly the same key as used by the bindings. The table view doesn't show this behaviour for its other columns which use the default data cell (NSTextFieldCell). Any ideas what might be going on here? Nice weekend to everybody, Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Communicate Between CocoaAsyncSocket and Java Socket
Dear all, I attempt to use CocoaAsyncSocket to communicate with Java server/client. Is it possible to achieve the goal? Thanks so much! Bing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting mouse cursor position
On May 7, 2011, at 13:28, Nick wrote: > 2011/5/7 Gregory Weston : >> eveningnick wrote: >> >>> Hello >>> I am searching for the way to find a cursor's position on the screen. >>> >>> I tried to use method -hotSpot of NSCursor, but it returns sc x=-2057825613, y=0 >>> >>> >>> -(IBAction)timeHandler:(id)timer { >>>//NSCursor *sc = [NSCursor currentSystemCursor]; >>> NSCursor *sc = [NSCursor currentCursor]; >>> NSLog(@"sc x=%d, y=%d", [sc hotSpot].x, [sc hotSpot].y); >>> } >>> >>> What may be wrong here? >>> I can successfully retrieve cursor's image though. But not the position. >>> Why? >> >> Aside from the fact that you're treating it as the wrong data type, as has >> been pointed out, this is not the right method for your goal. The hotSpot >> method returns the location of the point within the cursor image that >> represents where the mouse is onscreen. Effectively it controls where the 2D >> image of the cursor is drawn relative to the point that is the mouse's >> current location. >> >> What you want is NSWindow's mouseLocationOutsideOfEventStream. Or >> preferably, if you have an event, then NSEvent's mouseLocation. > > Gregory, > what do you mean by "if you have an event"? Could you elaborate on it please? Well, part of what you should take away from that is that I've been operating on too little sleep this week and got two different NSEvent methods confused as a result. You don't need to have an NSEvent instance for mouseLocation. You do for locationInWindow. Greg ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: A Simple and Complete RunLoop Example
On May 7, 2011, at 11:56 AM, Bing Li wrote: > Can someone give me a hand? Could you provide me with a simple and complete > RunLoop example? Thanks so much! If you look at the reference for the NSRunLoop class or the CFRunLoop API, many of the methods and functions list Related Sample Code. You might take a look at those sample projects. There's not much point to demonstrating a run loop in isolation, without having a specific purpose that you're using the run loop for. You can also just ask about whatever is confusing you. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting mouse cursor position
On May 7, 2011, at 1:28 PM, Nick wrote: > Gregory, > what do you mean by "if you have an event"? Could you elaborate on it please? He means if you have an instance of NSEvent. Some methods, such as -[NSResponder mouseDown:], -[NSResponder keyDown:], -[NSWindow currentEvent], and -[NSApplication currentEvent], provide you with an instance of NSEvent. If you're overriding or calling one of those methods you may want to use the associated event instance. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting mouse cursor position
2011/5/7 Gregory Weston : > eveningnick wrote: > >> Hello >> I am searching for the way to find a cursor's position on the screen. >> >> I tried to use method -hotSpot of NSCursor, but it returns >>> sc x=-2057825613, y=0 >> >> >> -(IBAction)timeHandler:(id)timer { >> //NSCursor *sc = [NSCursor currentSystemCursor]; >> NSCursor *sc = [NSCursor currentCursor]; >> NSLog(@"sc x=%d, y=%d", [sc hotSpot].x, [sc hotSpot].y); >> } >> >> What may be wrong here? >> I can successfully retrieve cursor's image though. But not the position. Why? > > Aside from the fact that you're treating it as the wrong data type, as has > been pointed out, this is not the right method for your goal. The hotSpot > method returns the location of the point within the cursor image that > represents where the mouse is onscreen. Effectively it controls where the 2D > image of the cursor is drawn relative to the point that is the mouse's > current location. > > What you want is NSWindow's mouseLocationOutsideOfEventStream. Or preferably, > if you have an event, then NSEvent's mouseLocation. Gregory, what do you mean by "if you have an event"? Could you elaborate on it please? > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/eveningnick%40gmail.com > > This email sent to eveningn...@gmail.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
A Simple and Complete RunLoop Example
Dear all, I am reading the Thread Programming Guide from apple.com. To be honest, I don't think the guide is suitable for a new Apple developer like me. Although I have a lot of programming experiences in concurrent programming, I cannot follow the guide conveniently, especially for the section about RunLoop. There is no a simple and complete example to utilize the techniques. It is not easy to use them quickly. I also searched the Web. Some ones also complain that. Can someone give me a hand? Could you provide me with a simple and complete RunLoop example? Thanks so much! Best regards, Bing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing onto CVPixelBuffer
On May 6, 2011, at 5:00 PM, Jean-Daniel Dupas wrote: > Le 6 mai 2011 à 23:30, eveningnick eveningnick a écrit : > >> the pixel format of the CVPixelBufferRef is k32BGRAPixelFormat > > It should work. The list of supported format is here: > > “Supported Pixel Formats.” If you set the kCVPixelBufferCGBitmapContextCompatibilityKey attribute to true when creating it, then you're guaranteed of compatibility. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting mouse cursor position
On 7 May 2011, at 0:29 , Nick wrote: > > May this is just a wrong function to retrieve the cursor's position? > Or it doesnt work for some older builds of OX X 10.6.x ? -hotSpot returns a point within in the cursor image, used to determine which part of the cursor is it's 'main point'. From the docs: "The point describing the position of the hot spot, specified according to the cursor’s flipped coordinate system." If you want to get the onscreen position look at -[NSWindow mouseLocationOutsideOfEventStream] or +[NSEvent mouseLocation] Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: when to save user-data to disk?
On 07.05.2011, at 05:51, Kyle Sluder wrote: > Question one: iOS or Mac? > > --Kyle Sluder > (Sent from the road) > > Mac OS. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView and NSTextContainer size & clipping area
But when i try draw a line in NSTextView, it limited to frame of text container too. 06.05.2011, в 22:56, Ross Carter написал(а): > On May 6, 2011, at 2:40 AM, Дмитрий Николаев wrote: > >> If there are any possibility to draw inside text view but outside of text >> container ? > > It depends on who is doing the drawing. NSTextView is an NSView subclass and > you can override drawRect: just like any NSView. The Cocoa text system, > however, draws inside the area specified by a NSTextContainer. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com