Skip to content

Commit b640dbc

Browse files
committed
[[ Bug 13261 ]] Update OSX stacksurface
1 parent eb8ea21 commit b640dbc

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

docs/notes/bugfix-13261.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Visual effect push problem

engine/src/desktop-stack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ class MCDesktopStackSurface: public MCStackSurface
393393
}
394394

395395
// MM-2014-07-31: [[ ThreadedRendering ]] Updated to wrap new platform surface API.
396-
bool LockPixels(MCGIntegerRectangle p_area, MCGRaster& r_raster)
396+
bool LockPixels(MCGIntegerRectangle p_area, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area)
397397
{
398-
return MCPlatformSurfaceLockPixels(m_surface, p_area, r_raster);
398+
return MCPlatformSurfaceLockPixels(m_surface, p_area, r_raster, r_locked_area);
399399
}
400400

401401
// MM-2014-07-31: [[ ThreadedRendering ]] Updated to wrap new platform surface API.

engine/src/mac-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class MCMacPlatformSurface: public MCPlatformSurface
366366
virtual bool LockGraphics(MCGIntegerRectangle area, MCGContextRef& r_context, MCGRaster &r_raster);
367367
virtual void UnlockGraphics(MCGIntegerRectangle area, MCGContextRef context, MCGRaster &raster);
368368

369-
virtual bool LockPixels(MCGIntegerRectangle area, MCGRaster& r_raster);
369+
virtual bool LockPixels(MCGIntegerRectangle area, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area);
370370
virtual void UnlockPixels(MCGIntegerRectangle area, MCGRaster& raster);
371371

372372
virtual bool LockSystemContext(void*& r_context);

engine/src/mac-surface.mm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
8888
bool 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

engine/src/platform-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MCPlatformSurface
3030
virtual bool LockGraphics(MCGIntegerRectangle area, MCGContextRef& r_context, MCGRaster &r_raster) = 0;
3131
virtual void UnlockGraphics(MCGIntegerRectangle area, MCGContextRef context, MCGRaster &raster) = 0;
3232

33-
virtual bool LockPixels(MCGIntegerRectangle area, MCGRaster& r_raster) = 0;
33+
virtual bool LockPixels(MCGIntegerRectangle area, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area) = 0;
3434
virtual void UnlockPixels(MCGIntegerRectangle area, MCGRaster& raster) = 0;
3535

3636
virtual bool LockSystemContext(void*& r_context) = 0;

engine/src/platform-surface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ void MCPlatformSurfaceUnlockGraphics(MCPlatformSurfaceRef p_surface, MCGIntegerR
4848
}
4949

5050
// MM-2014-07-31: [[ ThreadedRendering ]] Updated to use new platform surface API.
51-
bool MCPlatformSurfaceLockPixels(MCPlatformSurfaceRef p_surface, MCGIntegerRectangle p_region, MCGRaster& r_raster)
51+
bool MCPlatformSurfaceLockPixels(MCPlatformSurfaceRef p_surface, MCGIntegerRectangle p_region, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area)
5252
{
53-
return p_surface -> LockPixels(p_region, r_raster);
53+
return p_surface -> LockPixels(p_region, r_raster, r_locked_area);
5454
}
5555

5656
// MM-2014-07-31: [[ ThreadedRendering ]] Updated to use new platform surface API.

engine/src/platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ bool MCPlatformSurfaceLockGraphics(MCPlatformSurfaceRef surface, MCGIntegerRecta
903903
void MCPlatformSurfaceUnlockGraphics(MCPlatformSurfaceRef surface, MCGIntegerRectangle region, MCGContextRef p_context, MCGRaster& p_raster);
904904

905905
// MM-2014-07-31: [[ ThreadedRendering ]] Updated to match new platform surface API.
906-
bool MCPlatformSurfaceLockPixels(MCPlatformSurfaceRef surface, MCGIntegerRectangle region, MCGRaster& r_raster);
906+
// IM-2014-08-26: [[ Bug 13261 ]] Return the actual locked area covered by the pixels
907+
bool MCPlatformSurfaceLockPixels(MCPlatformSurfaceRef surface, MCGIntegerRectangle region, MCGRaster& r_raster, MCGIntegerRectangle &r_locked_area);
907908
void MCPlatformSurfaceUnlockPixels(MCPlatformSurfaceRef surface, MCGIntegerRectangle region, MCGRaster& p_raster);
908909

909910
bool MCPlatformSurfaceLockSystemContext(MCPlatformSurfaceRef surface, void*& r_context);

0 commit comments

Comments
 (0)