diff options
author | Jess VanDerwalker <washu@sonic.net> | 2012-03-10 21:25:27 -0800 |
---|---|---|
committer | Jess VanDerwalker <washu@sonic.net> | 2012-03-10 21:25:27 -0800 |
commit | 627bd6d14b4d3eb0587bb14a87adffbf99055b4f (patch) | |
tree | 26a671012a9f3cde3f4b1b7924776ea58b99e7cf | |
parent | 66387f61fd4f5ee7ff888f001e99b245b7eb5393 (diff) |
Removing damage from context when area redrawn in window.
-rw-r--r-- | src/xtoq/XtoqController.m | 5 | ||||
-rw-r--r-- | src/xtoq/XtoqView.h | 23 | ||||
-rw-r--r-- | src/xtoq/XtoqView.m | 37 |
3 files changed, 35 insertions, 30 deletions
diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m index 79e30d8..9990355 100644 --- a/src/xtoq/XtoqController.m +++ b/src/xtoq/XtoqController.m @@ -88,6 +88,8 @@ imageRec = NSMakeRect(0, 0, 1028,768);//[image getWidth], [image getHeight]); // create a view, init'ing it with our rect ourView = [[XtoqView alloc] initWithFrame:imageRec]; + [ourView setContext: rootContext]; + // add view to its window [xtoqWindow setContentView: ourView]; // set the initial image in the window @@ -427,9 +429,10 @@ // create a view, init'ing it with our rect newView = [[XtoqView alloc] initWithFrame:imgRec]; + [newView setContext:windowContext]; // set the initial image in the window - [newView setImage:imageRep]; + // [newView setImage:imageRep]; // add view to its window [newWindow setContentView: newView ]; diff --git a/src/xtoq/XtoqView.h b/src/xtoq/XtoqView.h index fbb7370..ad903ad 100644 --- a/src/xtoq/XtoqView.h +++ b/src/xtoq/XtoqView.h @@ -32,13 +32,7 @@ SOFTWARE. #import "xtoq.h" @interface XtoqView : NSView { - XtoqImageRep *image[10000]; - - - NSImage *image2; - NSString *file; - - xcb_image_t *imageT; + xtoq_context_t *viewContext; //mouse event NSPoint downPoint; @@ -46,9 +40,6 @@ SOFTWARE. NSNotificationCenter * notificationCenter; NSTrackingArea * trackingArea; - - int bufferIndex; - int bufferIndexTwo; } /** @@ -58,6 +49,12 @@ SOFTWARE. - (id)initWithFrame:(NSRect)frame; /** + * Set the context associated with this view. + * @param context The context + */ +-(void)setContext:(xtoq_context_t *)context; + +/** * The OS X magic loop which is responsible for drawing content to the screen * @param a "fake" NSRect which is not actually used within the body of the * method @@ -65,12 +62,6 @@ SOFTWARE. -(void)drawRect:(NSRect)dirtyRect; /** - * Set the entire image contents in the view - * @param an XtoqImageRep - */ -- (void)setImage:(XtoqImageRep *)newImage; - -/** * Set the partial image contents in the view * @param newDamageRect The area of the image that needs to be redrawn */ diff --git a/src/xtoq/XtoqView.m b/src/xtoq/XtoqView.m index 997c96a..6b29063 100644 --- a/src/xtoq/XtoqView.m +++ b/src/xtoq/XtoqView.m @@ -36,8 +36,6 @@ initWithFrame:(NSRect)frame { notificationCenter = [NSNotificationCenter defaultCenter]; [[self window] flushWindow]; [self setNeedsDisplay:YES]; - bufferIndex = 0; - bufferIndexTwo = 0; trackingArea = [[NSTrackingArea alloc] initWithRect:frame options: (NSTrackingMouseEnteredAndExited | @@ -50,17 +48,36 @@ initWithFrame:(NSRect)frame { return self; } +-(void) setContext: (xtoq_context_t *)context { + viewContext = context; +} // Overridden by subclasses to draw the receiver’s image within the passed-in rectangle. -(void) drawRect:(NSRect)dirtyRect { + xtoq_image_t *imageT; + float y_transformed; + XtoqImageRep *imageNew; + xtoq_get_event_thread_lock(); - while (bufferIndexTwo < bufferIndex) { - int i = bufferIndexTwo++; - [image[i] draw];//InRect:dirtyRect]; - [image[i] destroy]; + imageT = test_xtoq_get_image(viewContext); + if (imageT->image) { + y_transformed =( viewContext->height + - viewContext->damaged_y + - viewContext->damaged_height)/1.0; + imageNew = [[XtoqImageRep alloc] + initWithData:imageT + x:((viewContext->damaged_x)) + y:y_transformed]; + [imageNew draw]; + [imageNew destroy]; } - bufferIndex = bufferIndexTwo = 0; + // Set the damage for the context back to 0 + viewContext->damaged_x = 0; + viewContext->damaged_y = 0; + viewContext->damaged_width = 0; + viewContext->damaged_height = 0; + xtoq_release_event_thread_lock(); } @@ -127,12 +144,6 @@ mouseDown:(NSEvent *)mouseEvent { userInfo:twoInfoDict]; } -- (void)setImage:(XtoqImageRep *)newImage { - xtoq_get_event_thread_lock(); - image[bufferIndex++] = newImage; - xtoq_release_event_thread_lock(); -} - - (void)setPartialImage:(NSRect)newDamageRect { [self setNeedsDisplayInRect:newDamageRect]; //[[self window] flushWindow]; |