X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e55f38df79556665b8f6aa1992cf3733ebf4e93..71a09c3579dd5cb4cd8fa7fdc143561cbff74e12:/src/osx/carbon/dcscreen.cpp?ds=sidebyside diff --git a/src/osx/carbon/dcscreen.cpp b/src/osx/carbon/dcscreen.cpp index 9dfcfef870..81761d364d 100644 --- a/src/osx/carbon/dcscreen.cpp +++ b/src/osx/carbon/dcscreen.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,7 +35,7 @@ wxScreenDCImpl::wxScreenDCImpl( wxDC *owner ) : m_width = (wxCoord)cgbounds.size.width; m_height = (wxCoord)cgbounds.size.height; #else - wxDisplaySize( &m_width, &m_height ); + wxDisplaySize( &m_width, &m_height ); #endif #if wxOSX_USE_COCOA_OR_IPHONE SetGraphicsContext( wxGraphicsContext::Create() ); @@ -56,14 +55,18 @@ wxScreenDCImpl::wxScreenDCImpl( wxDC *owner ) : wxScreenDCImpl::~wxScreenDCImpl() { - delete m_graphicContext; - m_graphicContext = NULL; + wxDELETE(m_graphicContext); #if wxOSX_USE_COCOA_OR_IPHONE #else DisposeWindow((WindowRef) m_overlayWindow ); #endif } +#if wxOSX_USE_IPHONE +// Apple has allowed usage of this API as of 15th Dec 2009w +extern CGImageRef UIGetScreenImage(); +#endif + // TODO Switch to CGWindowListCreateImage for 10.5 and above wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const @@ -76,22 +79,37 @@ wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const CGRect srcRect = CGRectMake(rect.x, rect.y, rect.width, rect.height); CGContextRef context = (CGContextRef)bmp.GetHBITMAP(); - + CGContextSaveGState(context); - + CGContextTranslateCTM( context, 0, m_height ); CGContextScaleCTM( context, 1, -1 ); - + if ( subrect ) srcRect = CGRectOffset( srcRect, -subrect->x, -subrect->y ) ; + + CGImageRef image = NULL; - CGImageRef image = grabViaOpenGL(kCGNullDirectDisplay, srcRect); - +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + if ( UMAGetSystemVersion() >= 10.6) + { + image = CGDisplayCreateImage(kCGDirectMainDisplay); + } + else +#endif + { + image = grabViaOpenGL(kCGNullDirectDisplay, srcRect); + } + wxASSERT_MSG(image, wxT("wxScreenDC::GetAsBitmap - unable to get screenshot.")); - + CGContextDrawImage(context, srcRect, image); - + + CGImageRelease(image); + CGContextRestoreGState(context); +#else + // TODO implement using UIGetScreenImage, CGImageCreateWithImageInRect, CGContextDrawImage #endif return bmp; }