Commits

Anonymous committed e7ac1f7

clean up NSLogs

  • Participants
  • Parent commits cf4e0a0

Comments (0)

Files changed (4)

File TronPDFView.h

 
 @interface TronPDFView : NSView {
     pdftron::PDF::PDFView * _tronPDFView;
+    std::vector<char> _buf;
 }
 
 @property (nonatomic) pdftron::PDF::PDFView * tronPDFView;
 #pragma mark c callbacks 
 void beginRendering(void* data);
 void endRendering(void* data, bool canceled);
-void currPageProc(void* data);
+void currPageProc(int current_page, int num_pages, void *data);
 void cp_1_pixel(const char * src, char * dst, int i, int j, int width, int height);
 
 @end

File TronPDFView.mm

 #pragma mark callback functions
 void beginRendering(void* data) {
     NSLog(@"begin rendering");
-    //printf("begin rendering");
 }
 
 void endRendering(void* data, bool canceled) {
     NSLog(@"end rendering");
     if (!canceled) {
-        NSLog(@"endRendering: setNeedDisplay:YES");
         [(TronPDFView*)data setNeedsDisplay:YES];
     }
 }
 
-void currPageProc(void* data) {
+void currPageProc(int current_page, int num_pages, void *data) {
     
 }
 
         if (bgra) {
             int width = _tronPDFView->GetBufferWidth();
             int height = _tronPDFView->GetBufferHeight();
-            char * rgba = (char *) malloc(width * height * 4);
+
+            char * rgba = &_buf[0];
             
             for (int i = 0; i < height; ++i) {
                 for (int j = 0; j < width; ++j) {
             
             CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext);
             
-            __strong NSGraphicsContext * nsGraphicsContext = [NSGraphicsContext currentContext];
-            __strong CGContextRef zCgContextRef = (CGContextRef) [nsGraphicsContext graphicsPort];            
+            /*__strong*/ NSGraphicsContext * nsGraphicsContext = [NSGraphicsContext currentContext];
+            /*__strong*/ CGContextRef zCgContextRef = (CGContextRef) [nsGraphicsContext graphicsPort];            
             
             CGRect	zCgRect	= NSRectToCGRect([[self superview] bounds]);
 
             CFRelease(colorSpace);            
             CFRelease(cgImage);
             CFRelease(bitmapContext);
-            free(rgba);
         }
     }
 }
         _tronPDFView->SetDoc(*(myDoc.tronPDFDoc));
         _tronPDFView->SetRenderBeginProc(beginRendering, self);
         _tronPDFView->SetRenderFinishProc(endRendering, self);
+        _tronPDFView->SetCurrentPageProc(currPageProc, self);
         _tronPDFView->SetPageViewMode(pdftron::PDF::PDFView::e_fit_width);
         _tronPDFView->SetPagePresentationMode(pdftron::PDF::PDFView::e_single_continuous);
         _tronPDFView->SetPageSpacing(10, 10, 20, 10);
         [self windowResized:nil];
-        double hPos = _tronPDFView->GetHScrollPos();
-        double vPos = _tronPDFView->GetVScrollPos();
-        NSLog(@"init Scroll: hPos: %0.4, vPos: %0.4f", hPos, vPos);
     }
 }
 
     if (_tronPDFView)
     {
         NSSize size = [[self superview] bounds].size;
-        _tronPDFView->OnSize((int) size.width, (int) size.height);
+        int width = (int) size.width;
+        int height = (int) size.height;
+        _tronPDFView->OnSize(width, height);
     
         double w = _tronPDFView->GetCanvasWidth();
         double h = _tronPDFView->GetCanvasHeight();
         [self setFrame:NSMakeRect(0.0, 0.0, w, h)];
+        
+        //allocate buffer
+        _buf.resize(width * height * 4, NULL);
     }
 }
 
     if (_tronPDFView && _tronPDFView->GetDoc()) {
         double final_hPos = hPos * _tronPDFView->GetCanvasWidth();
         double final_vPos = vPos * _tronPDFView->GetCanvasHeight();
-        //_tronPDFView->OnScroll((int) final_hPos, (int) final_vPos);
         _tronPDFView->SetHScrollPos(final_hPos);
         _tronPDFView->SetVScrollPos(final_vPos);
-        NSLog(@"final h %0.4f final v %0.4f canvas w %0.4f h %0.4f (int)final h %d (int)final v %d", 
-              final_hPos, final_vPos, _tronPDFView->GetCanvasWidth(), _tronPDFView->GetCanvasHeight(), 
-              (int)final_hPos, (int)final_vPos);
-        NSLog(@"result h %0.4f v %0.4f", _tronPDFView->GetHScrollPos(), _tronPDFView->GetVScrollPos());
         _tronPDFView->Update();
         [self setNeedsDisplay:YES];
     }

File TronScrollView.mm

 @implementation TronScrollView
 
 -(void)scrollWheel:(NSEvent *)theEvent {
-    NSLog(@"scrollWheel");
     [super scrollWheel:theEvent];
     TronPDFView * pdfView = [self documentView];
-    
-    CGFloat deltaX = [theEvent deltaX];
-    CGFloat deltaY = [theEvent deltaY];
-    CGFloat deltaZ = [theEvent deltaZ];
-    
-    NSLog(@"deltaX: %0.4f, deltaY: %0.4f, deltaZ: %0.4f", deltaX, deltaY, deltaZ);
-    
     float vPos = [[self verticalScroller] floatValue];
     float hPos = [[self horizontalScroller] floatValue];
     [pdfView SetScroll:hPos vPos:vPos];

File cocoapdf.xcodeproj/quincy.mode1v3

 						<key>_historyCapacity</key>
 						<integer>0</integer>
 						<key>bookmark</key>
-						<string>24715955120E52EA00711708</string>
+						<string>2471597D120E691A00711708</string>
 						<key>history</key>
 						<array>
 							<string>24715881120E276800711708</string>
 							<string>247158A9120E419600711708</string>
 							<string>247158F1120E48B300711708</string>
-							<string>24715944120E511900711708</string>
-							<string>24715954120E52EA00711708</string>
-							<string>24715950120E529300711708</string>
+							<string>24715969120E62E500711708</string>
+							<string>2471597B120E691A00711708</string>
+							<string>2471597C120E691A00711708</string>
 						</array>
 					</dict>
 					<key>SplitCount</key>
 										<key>_historyCapacity</key>
 										<integer>0</integer>
 										<key>bookmark</key>
-										<string>24715953120E52EA00711708</string>
+										<string>2471597A120E691A00711708</string>
 										<key>history</key>
 										<array>
 											<string>241D2A8211FBCBED0067260B</string>
 	<integer>5</integer>
 	<key>WindowOrderList</key>
 	<array>
+		<string>2471597E120E691A00711708</string>
 		<string>24715814120E1DBD00711708</string>
 		<string>24715815120E1DBD00711708</string>
 		<string>1CD10A99069EF8BA00B06720</string>
 		<string>/Users/quincy/Repositories/CocoaPDF/cocoapdf.xcodeproj</string>
+		<string>2492503F11CB2A5D0076F523</string>
 		<string>1C78EAAD065D492600B07095</string>
-		<string>2492503F11CB2A5D0076F523</string>
 		<string>24715875120E267F00711708</string>
 	</array>
 	<key>WindowString</key>
 							<key>GeometryConfiguration</key>
 							<dict>
 								<key>Frame</key>
-								<string>{{0, 0}, {953, 428}}</string>
+								<string>{{0, 0}, {1045, 424}}</string>
 								<key>RubberWindowFrame</key>
-								<string>235 233 953 469 0 0 1280 778 </string>
+								<string>235 237 1045 465 0 0 1280 778 </string>
 							</dict>
 							<key>Module</key>
 							<string>PBXDebugCLIModule</string>
 							<key>Proportion</key>
-							<string>428pt</string>
+							<string>424pt</string>
 						</dict>
 					</array>
 					<key>Proportion</key>
-					<string>428pt</string>
+					<string>424pt</string>
 				</dict>
 			</array>
 			<key>Name</key>
 			<key>ToolbarConfiguration</key>
 			<string>xcode.toolbar.config.consoleV3</string>
 			<key>WindowString</key>
-			<string>235 233 953 469 0 0 1280 778 </string>
+			<string>235 237 1045 465 0 0 1280 778 </string>
 			<key>WindowToolGUID</key>
 			<string>1C78EAAD065D492600B07095</string>
 			<key>WindowToolIsVisible</key>