@@ -900,7 +900,7 @@ void MCStack::enablewindow(bool p_enable)
900900
901901// MW-2011-09-11: [[ Redraw ]] Force an immediate update of the window within the given
902902// region. The actual rendering is done by deferring to the 'redrawwindow' method.
903- void MCStack::updatewindow (MCRegionRef p_region)
903+ void MCStack::device_updatewindow (MCRegionRef p_region)
904904{
905905 HIViewRef t_root;
906906 GetRootControl ((WindowPtr)window -> handle . window, &t_root);
@@ -910,16 +910,8 @@ void MCStack::updatewindow(MCRegionRef p_region)
910910
911911 // MW-2011-10-07: [[ Bug 9792 ]] If the mask hasn't changed, use the update region,
912912 // else redraw the whole view.
913- if (!getextendedstate (ECS_MASK_CHANGED ))
914- {
915- // IM-2013-08-01: [[ ResIndependence ]] Scale update region to device coords
916- MCRegionRef t_dev_region;
917- t_dev_region = nil;
918- /* UNCHECKED */ MCRegionCreate (t_dev_region);
919- MCRegionSetRect (t_dev_region, MCGRectangleGetIntegerBounds (MCResUserToDeviceRect (MCRegionGetBoundingBox (p_region))));
920- HIViewSetNeedsDisplayInRegion (t_view, (RgnHandle)t_dev_region, TRUE );
921- MCRegionDestroy (t_dev_region);
922- }
913+ if (!getextendedstate (ECS_MASK_CHANGED ) || s_update_callback != nil)
914+ HIViewSetNeedsDisplayInRegion (t_view, (RgnHandle)p_region, TRUE );
923915 else
924916 {
925917 HIViewSetNeedsDisplay (t_view, TRUE );
@@ -947,47 +939,16 @@ void MCStack::updatewindow(MCRegionRef p_region)
947939 }
948940}
949941
950- void MCStack::updatewindowwithcallback (MCRegionRef p_region, MCStackUpdateCallback p_callback, void *p_context)
942+ void MCStack::device_updatewindowwithcallback (MCRegionRef p_region, MCStackUpdateCallback p_callback, void *p_context)
951943{
952- HIViewRef t_root;
953- GetRootControl ((WindowPtr)window -> handle . window, &t_root);
954-
955- HIViewRef t_view;
956- GetIndexedSubControl (t_root, 1 , &t_view);
957-
958- // IM-2013-08-01: [[ ResIndependence ]] Scale update region to device coords
959- MCRegionRef t_dev_region;
960- t_dev_region = nil;
961- /* UNCHECKED */ MCRegionCreate (t_dev_region);
962- MCRegionSetRect (t_dev_region, MCGRectangleGetIntegerBounds (MCResUserToDeviceRect (MCRegionGetBoundingBox (p_region))));
963- HIViewSetNeedsDisplayInRegion (t_view, (RgnHandle)t_dev_region, TRUE );
964- MCRegionDestroy (t_dev_region);
965-
966944 // Set the file-local static to the callback to use (stacksurface picks this up!)
967945 s_update_callback = p_callback;
968946 s_update_context = p_context;
969- HIViewRender (t_view);
947+ // IM-2013-08-29: [[ RefactorGraphics ]] simplify by calling device_updatewindow, which performs the same actions
948+ device_updatewindow (p_region);
970949 // Unset the file-local static.
971950 s_update_callback = nil;
972951 s_update_context = nil;
973-
974- // MW-2011-10-18: [[ Bug 9798 ]] Make sure we force a screen update after every
975- // update.
976- // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
977- // HIWindowFlush((WindowPtr)window -> handle . window);
978-
979- // Update the shadow, if required.
980- if (getextendedstate (ECS_MASK_CHANGED ))
981- {
982- // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
983- HIWindowFlush ((WindowPtr)window -> handle . window);
984-
985- HIWindowInvalidateShadow ((WindowPtr)window -> handle . window);
986-
987- EnableScreenUpdates ();
988-
989- setextendedstate (False, ECS_MASK_CHANGED );
990- }
991952}
992953
993954// //////////////////////////////////////////////////////////////////////////////
@@ -1124,17 +1085,19 @@ class MCMacStackSurface: public MCStackSurface
11241085 CGContextRef m_context;
11251086
11261087 int32_t m_surface_height;
1088+ int32_t m_surface_scroll;
11271089
11281090 MCRectangle m_locked_area;
11291091 MCGContextRef m_locked_context;
11301092 void *m_locked_bits;
11311093 uint32_t m_locked_stride;
11321094
11331095public:
1134- MCMacStackSurface (MCStack *p_stack, int32_t p_surface_height, MCRegionRef p_region, CGContextRef p_context)
1096+ MCMacStackSurface (MCStack *p_stack, int32_t p_surface_height, int32_t p_surface_scroll, MCRegionRef p_region, CGContextRef p_context)
11351097 {
11361098 m_stack = p_stack;
11371099 m_surface_height = p_surface_height;
1100+ m_surface_scroll = p_surface_scroll;
11381101 m_region = p_region;
11391102 m_context = p_context;
11401103
@@ -1155,15 +1118,17 @@ class MCMacStackSurface: public MCStackSurface
11551118 t_rect = MCRegionGetBoundingBox (m_region);
11561119 CGContextClearRect (m_context, CGRectMake (t_rect . x, m_surface_height - (t_rect . y + t_rect . height), t_rect . width, t_rect . height));
11571120
1158- // MW-2012-07-25: [[ Bug ]] Make sure we use signed arithmetic to
1159- // compute the y-origin otherwise it wraps to 2^32!
1160- int32_t t_mask_height, t_mask_width;
1161- t_mask_width = (int32_t )CGImageGetWidth (t_mask);
1162- t_mask_height = (int32_t )CGImageGetHeight (t_mask);
1121+ // IM-2013-08-29: [[ ResIndependence ]] scale mask to device coords
1122+ MCGFloat t_scale;
1123+ t_scale = MCResGetDeviceScale ();
1124+
1125+ MCGFloat t_mask_height, t_mask_width;
1126+ t_mask_width = CGImageGetWidth (t_mask) * t_scale;
1127+ t_mask_height = CGImageGetHeight (t_mask) * t_scale;
11631128
11641129 CGRect t_dst_rect;
11651130 t_dst_rect . origin . x = 0 ;
1166- t_dst_rect . origin . y = m_surface_height - t_mask_height - (m_stack -> getscroll () * t_scale) ;
1131+ t_dst_rect . origin . y = m_surface_height - t_mask_height - m_surface_scroll ;
11671132 t_dst_rect . size . width = t_mask_width;
11681133 t_dst_rect . size . height = t_mask_height;
11691134 CGContextClipToMask (m_context, t_dst_rect, t_mask);
@@ -1512,11 +1477,15 @@ OSStatus HIRevolutionStackViewHandler(EventHandlerCallRef p_call_ref, EventRef p
15121477 if (t_graphics != nil)
15131478 {
15141479 // IM-2013-08-23: [[ ResIndependence ]] provide surface height in device scale
1515- MCRectangle t_device_rect ;
1516- t_device_rect = MCGRectangleGetIntegerBounds ( MCResUserToDeviceRect (t_context-> stack -> getcurcard ()-> getrect ()) );
1480+ MCGFloat t_scale ;
1481+ t_scale = MCResGetDeviceScale ( );
15171482
15181483 int32_t t_surface_height;
1519- t_surface_height = t_device_rect.height ;
1484+ t_surface_height = floor (t_context->stack ->getcurcard ()->getrect ().height * t_scale);
1485+
1486+ // IM-2013-08-29: [[ ResIndependence ]] also provide scroll value at device scale
1487+ int32_t t_surface_scroll;
1488+ t_surface_scroll = ceil (t_context->stack ->getscroll () * t_scale);
15201489
15211490 // HIView gives us a context in top-left origin mode which isn't so good
15221491 // for our CG rendering so, revert back to bottom-left.
@@ -1526,7 +1495,7 @@ OSStatus HIRevolutionStackViewHandler(EventHandlerCallRef p_call_ref, EventRef p
15261495 // Save the context state
15271496 CGContextSaveGState (t_graphics);
15281497
1529- MCMacStackSurface t_surface (t_context -> stack, t_surface_height, (MCRegionRef)t_dirty_rgn, t_graphics);
1498+ MCMacStackSurface t_surface (t_context -> stack, t_surface_height, t_surface_scroll, (MCRegionRef)t_dirty_rgn, t_graphics);
15301499
15311500 if (t_surface.Lock ())
15321501 {
0 commit comments