summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-29 00:47:10 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-30 07:53:40 +0200
commitbb0b2744af130d3f03939bd883d7f9fa9d373941 (patch)
treecf94a66650efa99fb7fe5bf556960b102a8f81f7 /ios
parent378d389620b50e172af3f488f1256aa950b0aea9 (diff)
Draw the frame virtual device bitmaps directly to the destination CGContext
Much faster. No need for the pixelBuffer inbetween. Change-Id: I6493faca6da3a3e9a1285e00c887928b85dca56e
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/AppDelegate.h5
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/AppDelegate.m15
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.h3
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.m12
4 files changed, 9 insertions, 26 deletions
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
index 79b0e56f4a02..c5c4560a6c57 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
@@ -11,11 +11,6 @@
#import "View.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
-{
- int nbytes;
- char *pixelBuffer;
- CGImageRef image;
-}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) View *view;
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
index 93f995e3744e..2f74d483fb63 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
@@ -44,17 +44,6 @@ static UIView *theView;
[self.window addGestureRecognizer: tapRecognizer];
- nbytes = bounds.size.width * bounds.size.height * 4;
-
- pixelBuffer = (char *) malloc(nbytes);
- memset(pixelBuffer, 0xFF, nbytes);
-
- CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, pixelBuffer, nbytes, NULL);
- image = CGImageCreate(bounds.size.width, bounds.size.height, 8, 32, bounds.size.width*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast, provider, NULL, false, kCGRenderingIntentDefault);
-
- self.view.pixelBuffer = pixelBuffer;
- self.view.image = image;
-
lo_set_view_size(bounds.size.width, bounds.size.height);
NSThread* thread = [[NSThread alloc] initWithTarget:self
@@ -105,7 +94,9 @@ static UIView *theView;
void lo_damaged(CGRect rect)
{
(void) rect;
- [theView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [theView setNeedsDisplayInRect:rect];
+ });
// NSLog(@"lo_damaged: %dx%d@(%d,%d)", (int)rect.size.width, (int)rect.size.height, (int)rect.origin.x, (int)rect.origin.y);
}
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.h b/ios/experimental/LibreOffice/LibreOffice/View.h
index d9537220244f..c128806409f4 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.h
+++ b/ios/experimental/LibreOffice/LibreOffice/View.h
@@ -11,9 +11,6 @@
@interface View : UIView
-@property char *pixelBuffer;
-@property CGImageRef image;
-
- (void)drawRect:(CGRect)rect;
- (void)tapGesture:(UIGestureRecognizer *)gestureRecognizer;
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index bcde7046b458..7968316102b6 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -14,18 +14,18 @@
- (void)drawRect:(CGRect)rect
{
- (void) rect;
-
// NSLog(@"drawRect: %fx%f@(%f,%f)", rect.size.width, rect.size.height, rect.origin.x, rect.origin.y);
NSDate *a = [NSDate date];
- lo_render_windows([self pixelBuffer], [self bounds].size.width, [self bounds].size.height);
-
- NSLog(@"drawRect: lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: a]);
CGContextRef context = UIGraphicsGetCurrentContext();
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, 0, self.frame.size.height);
+ CGContextScaleCTM(context, 1, -1);
+ lo_render_windows(context, rect);
+ CGContextRestoreGState(context);
- CGContextDrawImage(context, [self bounds], [self image]);
+ NSLog(@"drawRect: lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: a]);
}
- (void) tapGesture:(UIGestureRecognizer *)gestureRecognizer