Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 2ab5076

Browse files
[[ ThreadedRendering ]] Implemented new stack surface API for Windows.
1 parent 7383aa4 commit 2ab5076

File tree

7 files changed

+178
-138
lines changed

7 files changed

+178
-138
lines changed

engine/kernel.vcproj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,14 @@
574574
RelativePath="src\stacklst.h"
575575
>
576576
</File>
577+
<File
578+
RelativePath=".\src\stacktile.cpp"
579+
>
580+
</File>
581+
<File
582+
RelativePath=".\src\stacktile.h"
583+
>
584+
</File>
577585
<File
578586
RelativePath=".\src\stackview.cpp"
579587
>
@@ -1499,6 +1507,13 @@
14991507
<File
15001508
RelativePath=".\src\quicktime.cpp"
15011509
>
1510+
<FileConfiguration
1511+
Name="Debug|Win32"
1512+
>
1513+
<Tool
1514+
Name="VCCLCompilerTool"
1515+
/>
1516+
</FileConfiguration>
15021517
</File>
15031518
<Filter
15041519
Name="Platform - Linux"
@@ -5100,6 +5115,10 @@
51005115
RelativePath=".\src\system.h"
51015116
>
51025117
</File>
5118+
<File
5119+
RelativePath=".\src\systhreads.h"
5120+
>
5121+
</File>
51035122
<File
51045123
RelativePath=".\src\sysunxdate.cpp"
51055124
>
@@ -5248,6 +5267,18 @@
52485267
/>
52495268
</FileConfiguration>
52505269
</File>
5270+
<File
5271+
RelativePath=".\src\sysw32threads.cpp"
5272+
>
5273+
<FileConfiguration
5274+
Name="Debug|Win32"
5275+
>
5276+
<Tool
5277+
Name="VCCLCompilerTool"
5278+
PrecompiledHeaderThrough="w32prefix.h"
5279+
/>
5280+
</FileConfiguration>
5281+
</File>
52515282
<File
52525283
RelativePath="src\w32date.cpp"
52535284
>

engine/src/stack2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,13 +2577,11 @@ void MCStack::view_surface_redrawwindow(MCStackSurface *p_surface, MCGRegionRef
25772577
t_bounds . origin . y + t_bounds . size . height / 2,
25782578
t_bounds . size . width - t_bounds . size . width / 2,
25792579
t_bounds . size . height - t_bounds . size . height / 2));
2580-
MCLog("BEGIN TILE RENDERING", NULL);
25812580
MCStackTilePush(&t_tile1);
25822581
MCStackTilePush(&t_tile2);
25832582
MCStackTilePush(&t_tile3);
25842583
MCStackTilePush(&t_tile4);
25852584
MCStackTileCollectAll();
2586-
MCLog("END TILE RENDERING", NULL);
25872585
}
25882586
else
25892587
{

engine/src/stacktile.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
struct MCStackTileList
3131
{
32-
uint32_t index;
3332
MCStackTileList *next;
3433
MCStackTile *tile;
3534
};
@@ -79,7 +78,6 @@ void MCStackTileRender(void *p_ctxt)
7978
MCStackTileList *t_tile;
8079
t_tile = (MCStackTileList *)p_ctxt;
8180
t_tile -> tile -> Render();
82-
MCLog("TILE %d RENDERED", t_tile -> index);
8381

8482
MCThreadMutexLock(s_main_thread_mutex);
8583
t_tile -> next = s_waiting_tiles;
@@ -108,7 +106,6 @@ void MCStackTilePush(MCStackTile *p_tile)
108106
t_tile = s_inactive_tiles;
109107
s_inactive_tiles = t_tile -> next;
110108
s_active_tile_count++;
111-
t_tile -> index = s_active_tile_count;
112109

113110
t_tile -> tile = p_tile;
114111
/* UNCHECKED */ MCThreadPoolPushTask(MCStackTileRender, (void *) t_tile);
@@ -131,7 +128,6 @@ void MCStackTileCollectAll(void)
131128

132129
t_tile -> tile -> Unlock();
133130
t_tile -> tile = NULL;
134-
MCLog("TILE %d COLLECTED", t_tile -> index);
135131

136132
// Move the tile to the inactive list.
137133
t_tile -> next = s_inactive_tiles;

engine/src/sysw32threads.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ DWORD WINAPI MCThreadPoolThreadExecute(LPVOID p_arg)
7979
if (s_task_list_start != NULL)
8080
{
8181
t_task = s_task_list_start;
82-
s_task_list_start = t_task -> next;
83-
82+
s_task_list_start = t_task -> next;
8483
MCThreadMutexUnlock(s_task_mutex);
84+
8585
t_task -> task(t_task -> context);
8686
MCMemoryDelete(t_task);
8787
}
@@ -173,8 +173,7 @@ bool MCThreadPoolPushTask(void (*p_task)(void*), void* p_context)
173173
t_task -> context = p_context;
174174
t_task -> next = NULL;
175175

176-
MCThreadMutexLock(s_task_mutex);
177-
176+
MCThreadMutexLock(s_task_mutex);
178177
if (s_task_list_start == NULL)
179178
{
180179
s_task_list_start = t_task;
@@ -184,8 +183,7 @@ bool MCThreadPoolPushTask(void (*p_task)(void*), void* p_context)
184183
{
185184
s_task_list_end -> next = t_task;
186185
s_task_list_end = t_task;
187-
}
188-
186+
}
189187
MCThreadConditionSignal(s_task_condition);
190188
MCThreadMutexUnlock(s_task_mutex);
191189
}
@@ -289,7 +287,7 @@ bool MCThreadConditionCreate(MCThreadConditionRef &r_condition)
289287

290288
if (t_success)
291289
{
292-
t_condition -> condition = CreateSemaphore(NULL, 10, 10, NULL);
290+
t_condition -> condition = CreateSemaphore(NULL, 0, 10, NULL);
293291
t_success = t_condition -> condition != NULL;
294292
}
295293

engine/src/w32misc.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,39 @@ void gdi_do_arc(HDC p_dc, HDC p_mask_dc, bool p_fill, int4 p_left, int4 p_top, i
323323
}
324324
}
325325

326+
static __declspec( thread ) bool s_initialized_on_thread = false;
327+
static __declspec( thread ) HDC s_theme_dc = NULL;
328+
329+
static void MCThemeDCIntialize()
330+
{
331+
if (s_initialized_on_thread)
332+
return;
333+
334+
s_initialized_on_thread = true;
335+
s_theme_dc = CreateCompatibleDC(NULL);
336+
}
337+
338+
static void MCThemeDCFinalize()
339+
{
340+
if (!s_initialized_on_thread)
341+
return;
342+
343+
DeleteDC(s_theme_dc);
344+
s_initialized_on_thread = false;
345+
}
346+
326347
typedef void (*MCGDIDrawFunc)(HDC p_hdc, void *p_context);
327348

328349
bool MCGDIDrawAlpha(uint32_t p_width, uint32_t p_height, MCGDIDrawFunc p_draw, void *p_context, MCImageBitmap *&r_bitmap)
329350
{
330351
bool t_success = true;
331352

353+
MCThemeDCIntialize();
354+
332355
HDC t_dc;
333356
//t_dc = CreateCompatibleDC(NULL);
334-
t_dc = ((MCScreenDC*)MCscreen)->getdsthdc();
357+
//t_dc = ((MCScreenDC*)MCscreen)->getdsthdc();
358+
t_dc = s_theme_dc;
335359
t_success = t_dc != nil;
336360

337361
bool t_alpha = false;

0 commit comments

Comments
 (0)