Skip to content

Commit 41e6550

Browse files
committed
[[ GraphicsPerformance ]] Update Windows redraw to use MCGRegion
1 parent ef6c356 commit 41e6550

11 files changed

Lines changed: 244 additions & 212 deletions

File tree

engine/kernel.vcproj

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,10 @@
10101010
RelativePath=".\src\redraw.h"
10111011
>
10121012
</File>
1013+
<File
1014+
RelativePath=".\src\region.cpp"
1015+
>
1016+
</File>
10131017
<File
10141018
RelativePath=".\src\region.h"
10151019
>
@@ -5072,46 +5076,6 @@
50725076
/>
50735077
</FileConfiguration>
50745078
</File>
5075-
<File
5076-
RelativePath=".\src\sysosxregion.cpp"
5077-
>
5078-
<FileConfiguration
5079-
Name="Debug|Win32"
5080-
ExcludedFromBuild="true"
5081-
>
5082-
<Tool
5083-
Name="VCCLCompilerTool"
5084-
/>
5085-
</FileConfiguration>
5086-
<FileConfiguration
5087-
Name="Release|Win32"
5088-
ExcludedFromBuild="true"
5089-
>
5090-
<Tool
5091-
Name="VCCLCompilerTool"
5092-
/>
5093-
</FileConfiguration>
5094-
</File>
5095-
<File
5096-
RelativePath=".\src\sysregion.cpp"
5097-
>
5098-
<FileConfiguration
5099-
Name="Debug|Win32"
5100-
ExcludedFromBuild="true"
5101-
>
5102-
<Tool
5103-
Name="VCCLCompilerTool"
5104-
/>
5105-
</FileConfiguration>
5106-
<FileConfiguration
5107-
Name="Release|Win32"
5108-
ExcludedFromBuild="true"
5109-
>
5110-
<Tool
5111-
Name="VCCLCompilerTool"
5112-
/>
5113-
</FileConfiguration>
5114-
</File>
51155079
<File
51165080
RelativePath=".\src\sysspec.cpp"
51175081
>

engine/src/graphics_util.h

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -104,37 +104,38 @@ inline MCGRectangle MCRectangle32ToMCGRectangle(const MCRectangle32 &p_rect)
104104
return MCGRectangleMake(p_rect.x, p_rect.y, p_rect.width, p_rect.height);
105105
}
106106

107+
inline MCRectangle32 MCRectangle32FromMCGIntegerRectangle(const MCGIntegerRectangle &p_rect)
108+
{
109+
return MCRectangle32Make(p_rect.origin.x, p_rect.origin.y, p_rect.size.width, p_rect.size.height);
110+
}
111+
112+
inline MCGIntegerRectangle MCRectangle32ToMCGIntegerRectangle(const MCRectangle32 &p_rect)
113+
{
114+
return MCGIntegerRectangleMake(p_rect.x, p_rect.y, p_rect.width, p_rect.height);
115+
}
116+
107117
////////////////////////////////////////////////////////////////////////////////
108118

109-
inline MCRectangle32 MCGRectangleGetInt32Bounds(MCGRectangle p_rect)
110-
{
111-
int32_t t_left, t_right, t_top, t_bottom;
112-
t_left = floor(p_rect.origin.x);
113-
t_top = floor(p_rect.origin.y);
114-
t_right = ceil(p_rect.origin.x + p_rect.size.width);
115-
t_bottom = ceil(p_rect.origin.y + p_rect.size.height);
116-
117-
int32_t t_width, t_height;
118-
t_width = t_right - t_left;
119-
t_height = t_bottom - t_top;
120-
121-
// [[ Bug 11349 ]] Out of bounds content displayed since getting integer
122-
// bounds of an empty rect is not empty.
123-
if (p_rect . size . width == 0.0f || p_rect . size . height == 0.0f)
124-
{
125-
t_width = 0;
126-
t_height = 0;
127-
}
128-
129-
MCRectangle32 t_rect;
130-
t_rect = MCRectangle32Make(t_left, t_top, t_width, t_height);
131-
132-
return t_rect;
119+
inline MCGIntegerRectangle MCRectangleToMCGIntegerRectangle(const MCRectangle &p_rect)
120+
{
121+
return MCGIntegerRectangleMake(p_rect.x, p_rect.y, p_rect.width, p_rect.height);
122+
}
123+
124+
inline MCRectangle MCRectangleFromMCGIntegerRectangle(const MCGIntegerRectangle &p_rect)
125+
{
126+
return MCRectangleMake(p_rect.origin.x, p_rect.origin.y, p_rect.size.width, p_rect.size.height);
127+
}
128+
129+
////////////////////////////////////////////////////////////////////////////////
130+
131+
inline MCRectangle32 MCGRectangleGetInt32Bounds(const MCGRectangle &p_rect)
132+
{
133+
return MCRectangle32FromMCGIntegerRectangle(MCGRectangleGetBounds(p_rect));
133134
}
134135

135136
inline MCRectangle MCGRectangleGetIntegerBounds(MCGRectangle p_rect)
136137
{
137-
return MCRectangle32ToMCRectangle(MCGRectangleGetInt32Bounds(p_rect));
138+
return MCRectangleFromMCGIntegerRectangle(MCGRectangleGetBounds(p_rect));
138139
}
139140

140141
inline MCRectangle MCGRectangleGetIntegerInterior(MCGRectangle p_rect)
@@ -186,18 +187,6 @@ inline MCRectangle MCGRectangleGetIntegerCeilingRect(const MCGRectangle &p_rect)
186187

187188
////////////////////////////////////////////////////////////////////////////////
188189

189-
inline MCGIntegerRectangle MCRectangleToMCGIntegerRectangle(const MCRectangle &p_rect)
190-
{
191-
return MCGIntegerRectangleMake(p_rect.x, p_rect.y, p_rect.width, p_rect.height);
192-
}
193-
194-
inline MCRectangle MCRectangleFromMCGIntegerRectangle(const MCGIntegerRectangle &p_rect)
195-
{
196-
return MCRectangleMake(p_rect.origin.x, p_rect.origin.y, p_rect.size.width, p_rect.size.height);
197-
}
198-
199-
////////////////////////////////////////////////////////////////////////////////
200-
201190
static inline MCPoint MCPointMake(int16_t x, int16_t y)
202191
{
203192
MCPoint t_point;
@@ -291,19 +280,19 @@ inline MCPoint MCPointTransform(const MCPoint &p_point, const MCGAffineTransform
291280

292281
inline MCGFloat MCGAffineTransformGetEffectiveScale(const MCGAffineTransform &p_transform)
293282
{
294-
return MCMax(MCAbs(p_transform.a), MCAbs(p_transform.d));
283+
return MCMax(MCAbs(p_transform.a) + MCAbs(p_transform.c), MCAbs(p_transform.d) + MCAbs(p_transform.b));
295284
}
296285

297286
////////////////////////////////////////////////////////////////////////////////
298287

299288
inline MCGPoint MCGRectangleGetCenter(const MCGRectangle &p_rect)
300289
{
301-
return MCGPointMake(p_rect.origin.x + p_rect.size.width / 2.0, p_rect.origin.y + p_rect.size.height / 2.0);
290+
return MCGPointMake(p_rect.origin.x + p_rect.size.width / 2.0f, p_rect.origin.y + p_rect.size.height / 2.0f);
302291
}
303292

304293
inline MCGRectangle MCGRectangleCenterOnPoint(const MCGRectangle &p_rect, const MCGPoint &p_point)
305294
{
306-
return MCGRectangleMake(p_point.x - p_rect.size.width / 2.0, p_point.y - p_rect.size.height / 2.0, p_rect.size.width, p_rect.size.height);
295+
return MCGRectangleMake(p_point.x - p_rect.size.width / 2.0f, p_point.y - p_rect.size.height / 2.0f, p_rect.size.width, p_rect.size.height);
307296
}
308297

309298
inline MCGRectangle MCGRectangleCenterOnRect(const MCGRectangle &p_rect_a, const MCGRectangle &p_rect_b)

engine/src/player.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,7 @@ void MCPlayer::unbufferDraw()
31833183
#endif
31843184
}
31853185

3186-
static MCRegionRef PicToRegion(PicHandle thePicture)
3186+
static RgnHandle PicToRegion(PicHandle thePicture)
31873187
{
31883188
Rect myRect;
31893189
GWorldPtr myGWorld = NULL;
@@ -3240,7 +3240,7 @@ static MCRegionRef PicToRegion(PicHandle thePicture)
32403240
DisposeGWorld(myGWorld);
32413241
// restore the original graphics port and device
32423242
SetGWorld(mySavedPort, mySavedDevice);
3243-
return (MCRegionRef)myRegion;
3243+
return myRegion;
32443244
}
32453245

32463246
MCRegionRef MCPlayer::makewindowregion()

engine/src/region.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ bool MCRegionForEachRect(MCRegionRef region, MCRegionForEachRectCallback callbac
5151

5252
#ifdef _WINDOWS_DESKTOP
5353
bool MCRegionConvertToDeviceAndClip(MCRegionRef region, MCSysContextHandle dc);
54-
bool MCRegionSetAsWindowShape(MCRegionRef region, MCSysWindowHandle window);
5554
#endif
5655

5756
#ifdef _MAC_DESKTOP

engine/src/stack2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,7 @@ void MCStack::view_surface_redrawwindow(MCStackSurface *p_surface, MCGRegionRef
24932493

24942494
// p_region is in surface coordinates, translate to user-space coords & ensure any fractional pixels are accounted for
24952495
MCRectangle t_rect;
2496-
t_rect = MCRectangleGetScaledBounds(Mt_bounds, 1 / t_backing_scale);
2496+
t_rect = MCRectangleGetScaledBounds(t_bounds, 1 / t_backing_scale);
24972497

24982498
// scale user -> surface space
24992499
MCGContextScaleCTM(t_context, t_backing_scale, t_backing_scale);

0 commit comments

Comments
 (0)