From bb0b2744af130d3f03939bd883d7f9fa9d373941 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 29 Mar 2013 00:47:10 +0200 Subject: Draw the frame virtual device bitmaps directly to the destination CGContext Much faster. No need for the pixelBuffer inbetween. Change-Id: I6493faca6da3a3e9a1285e00c887928b85dca56e --- vcl/ios/iosinst.cxx | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'vcl/ios') diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx index 819fdec0e97a..905c0b3113e9 100644 --- a/vcl/ios/iosinst.cxx +++ b/vcl/ios/iosinst.cxx @@ -304,11 +304,37 @@ void lo_set_view_size(int width, int height) } extern "C" -void lo_render_windows(char *pixelBuffer, int width, int height) +void lo_render_windows( CGContextRef context, CGRect rect ) { - // Hack: assume so far that we are asked to redraw the whole pixel buffer - if (IosSalInstance::getInstance() != NULL) - IosSalInstance::getInstance()->RedrawWindows(pixelBuffer, width, height, 0, 0, width, height); + if( IosSalInstance::getInstance() != NULL ) { + int i = 0; + std::list< SalFrame* >::const_iterator it; + for( it = IosSalInstance::getInstance()->getFrames().begin(); it != IosSalInstance::getInstance()->getFrames().end(); i++, it++ ) { + SvpSalFrame *pFrame = static_cast(*it); + SalFrameGeometry aGeom = pFrame->GetGeometry(); + CGRect bbox = CGRectMake( aGeom.nX, aGeom.nY, aGeom.nWidth, aGeom.nHeight ); + if ( pFrame->IsVisible() && + CGRectIntersectsRect( rect, bbox ) ) { + + const basebmp::BitmapDeviceSharedPtr aDevice = pFrame->getDevice(); + CGDataProviderRef provider = + CGDataProviderCreateWithData( NULL, + aDevice->getBuffer().get(), + aDevice->getSize().getY() * aDevice->getScanlineStride(), + NULL ); + CGImage *image = + CGImageCreate( aDevice->getSize().getX(), aDevice->getSize().getY(), + 8, 32, aDevice->getScanlineStride(), + CGColorSpaceCreateDeviceRGB(), + kCGImageAlphaNoneSkipLast, + provider, + NULL, + false, + kCGRenderingIntentDefault ); + CGContextDrawImage( context, bbox, image ); + } + } + } } extern "C" -- cgit