Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: some questions about CGWindowListCreateImage()



On Mar 27, 2008, at 10:16 AM, vade wrote:
I am wondering/speculating if this is due to some sort of readback off the GPU when calling CGWindowListCreateImage(). Ive checked OpenGL Driver Monitor but am not certain what to look for to indicate readback is happening or that it is indeed causing a large bottleneck.

So, is it possible to keep the CGImageRef from CGWindowListCreateImage() on the GPU (from what I understand a CGIImageRef can live anywhere in main memory or in vram - is this assumption incorrect?), and if so, how do I do it!

The bits of a CGImageRef live in main memory. Any association with GPU resources is an implementation detail that you have no control over.

The code I am using to pull in the window image and that is called at my timer is as follows:

-(void) windowToImage
{
if(currentWindowImage && currentWindowImage != nil)
{
CGImageRelease(currentWindowImage);
}

currentWindowImage = CGWindowListCreateImage(imageBoundssingleWindowListOptionswindowIDimageOptions);

CGImageRetain(currentWindowImage);
}

This code will leak a CGImageRef every time its called. You get the image from a "Create" call, therefore you own it, no need to retain it yourself. You are likely not noticing the leak at the moment because the image bits haven't been created yet (they aren't created until they are queried).

Does it make sense to use CGWindowListCreateImage, or should I be looking at the OpenGL Screen Capture example? I quite like CGWindowListCreateImage as it lets me capture obscured windows, and only the window, which im not certain I can do based on a sampling of the OpenGL Screen to Movie code. I have no problems being 10.5 only.


If you need the bits on the GPU, then the OpenGL samples are better. They have their own caveats of course (that you can't get the contents of an arbitrary window) but thats the tradeoff in this case...

--

Reality is what, when you stop believing in it, doesn't go away.

Failure is not an option. It is a privilege reserved for those who try.


David Duncan


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden

References: 
 >some questions about CGWindowListCreateImage() (From: vade <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.