@@ -88,7 +88,8 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
8888bool MCMacPlatformSurface::LockGraphics (MCGIntegerRectangle p_region, MCGContextRef& r_context, MCGRaster &r_raster)
8989{
9090 MCGRaster t_raster;
91- if (LockPixels (p_region, t_raster))
91+ MCGIntegerRectangle t_locked_area;
92+ if (LockPixels (p_region, t_raster, t_locked_area))
9293 {
9394 MCGContextRef t_gcontext;
9495 if (MCGContextCreateWithRaster (t_raster, t_gcontext))
@@ -100,10 +101,7 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
100101 MCGContextScaleCTM (t_gcontext, t_scale, t_scale);
101102
102103 // Set origin
103- MCGIntegerRectangle t_bounds;
104- t_bounds = MCGRegionGetBounds (m_update_rgn);
105-
106- MCGContextTranslateCTM (t_gcontext, -p_region . origin . x, -p_region . origin . y);
104+ MCGContextTranslateCTM (t_gcontext, -t_locked_area . origin . x, -t_locked_area . origin . y);
107105
108106 // Set clipping rect
109107 MCGContextClipToRegion (t_gcontext, m_update_rgn);
@@ -114,6 +112,8 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
114112
115113 return true ;
116114 }
115+
116+ UnlockPixels (t_locked_area, t_raster);
117117 }
118118 return false ;
119119}
@@ -131,7 +131,7 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
131131// MM-2014-07-31: [[ ThreadedRendering ]] Updated to use the new platform surface API.
132132// We create a single backing buffer for the entire surface (created the first time lock pixels is called)
133133// and return a raster that points to the desired region of the backing buffer.
134- bool MCMacPlatformSurface::LockPixels (MCGIntegerRectangle p_region, MCGRaster& r_raster)
134+ bool MCMacPlatformSurface::LockPixels (MCGIntegerRectangle p_region, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area )
135135{
136136 MCGIntegerRectangle t_bounds;
137137 t_bounds = MCGRegionGetBounds (m_update_rgn);
@@ -165,6 +165,8 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
165165 r_raster . format = kMCGRasterFormat_xRGB ;
166166 r_raster . pixels = (uint8_t *)m_raster . pixels + (int32_t )((t_actual_area . origin . y - t_bounds . origin.y ) * t_scale * m_raster . stride + (t_actual_area . origin . x - t_bounds . origin . x) * t_scale * sizeof (uint32_t ));
167167
168+ r_locked_area = t_actual_area;
169+
168170 return true ;
169171}
170172
0 commit comments