You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -27,20 +27,19 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "visual_server_wrap_mt.h"
|
||||
#include "os/os.h"
|
||||
#include "globals.h"
|
||||
#include "os/os.h"
|
||||
void VisualServerWrapMT::thread_exit() {
|
||||
|
||||
exit=true;
|
||||
exit = true;
|
||||
}
|
||||
|
||||
void VisualServerWrapMT::thread_draw() {
|
||||
|
||||
|
||||
draw_mutex->lock();
|
||||
|
||||
draw_pending--;
|
||||
bool draw=(draw_pending==0);// only draw when no more flushes are pending
|
||||
bool draw = (draw_pending == 0); // only draw when no more flushes are pending
|
||||
|
||||
draw_mutex->unlock();
|
||||
|
||||
@@ -48,41 +47,35 @@ void VisualServerWrapMT::thread_draw() {
|
||||
|
||||
visual_server->draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VisualServerWrapMT::thread_flush() {
|
||||
|
||||
|
||||
draw_mutex->lock();
|
||||
|
||||
draw_pending--;
|
||||
|
||||
draw_mutex->unlock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VisualServerWrapMT::_thread_callback(void *_instance) {
|
||||
|
||||
VisualServerWrapMT *vsmt = reinterpret_cast<VisualServerWrapMT*>(_instance);
|
||||
|
||||
VisualServerWrapMT *vsmt = reinterpret_cast<VisualServerWrapMT *>(_instance);
|
||||
|
||||
vsmt->thread_loop();
|
||||
}
|
||||
|
||||
void VisualServerWrapMT::thread_loop() {
|
||||
|
||||
server_thread=Thread::get_caller_ID();
|
||||
server_thread = Thread::get_caller_ID();
|
||||
|
||||
OS::get_singleton()->make_rendering_thread();
|
||||
|
||||
visual_server->init();
|
||||
|
||||
exit=false;
|
||||
draw_thread_up=true;
|
||||
while(!exit) {
|
||||
exit = false;
|
||||
draw_thread_up = true;
|
||||
while (!exit) {
|
||||
// flush commands one by one, until exit is requested
|
||||
command_queue.wait_and_flush_one();
|
||||
}
|
||||
@@ -90,10 +83,8 @@ void VisualServerWrapMT::thread_loop() {
|
||||
command_queue.flush_all(); // flush all
|
||||
|
||||
visual_server->finish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* EVENT QUEUING */
|
||||
|
||||
void VisualServerWrapMT::sync() {
|
||||
@@ -113,12 +104,10 @@ void VisualServerWrapMT::sync() {
|
||||
|
||||
command_queue.flush_all(); //flush all pending from other threads
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VisualServerWrapMT::draw() {
|
||||
|
||||
|
||||
if (create_thread) {
|
||||
|
||||
/* TODO: Make it draw
|
||||
@@ -135,7 +124,6 @@ void VisualServerWrapMT::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VisualServerWrapMT::init() {
|
||||
|
||||
if (create_thread) {
|
||||
@@ -144,10 +132,10 @@ void VisualServerWrapMT::init() {
|
||||
print_line("CREATING RENDER THREAD");
|
||||
OS::get_singleton()->release_rendering_thread();
|
||||
if (create_thread) {
|
||||
thread = Thread::create( _thread_callback, this );
|
||||
thread = Thread::create(_thread_callback, this);
|
||||
print_line("STARTING RENDER THREAD");
|
||||
}
|
||||
while(!draw_thread_up) {
|
||||
while (!draw_thread_up) {
|
||||
OS::get_singleton()->delay_usec(1000);
|
||||
}
|
||||
print_line("DONE RENDER THREAD");
|
||||
@@ -155,58 +143,50 @@ void VisualServerWrapMT::init() {
|
||||
|
||||
visual_server->init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VisualServerWrapMT::finish() {
|
||||
|
||||
|
||||
if (thread) {
|
||||
|
||||
command_queue.push( this, &VisualServerWrapMT::thread_exit);
|
||||
Thread::wait_to_finish( thread );
|
||||
command_queue.push(this, &VisualServerWrapMT::thread_exit);
|
||||
Thread::wait_to_finish(thread);
|
||||
memdelete(thread);
|
||||
|
||||
|
||||
texture_free_cached_ids();
|
||||
mesh_free_cached_ids();
|
||||
|
||||
thread=NULL;
|
||||
thread = NULL;
|
||||
} else {
|
||||
visual_server->finish();
|
||||
}
|
||||
|
||||
if (draw_mutex)
|
||||
memdelete(draw_mutex);
|
||||
|
||||
}
|
||||
|
||||
VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread)
|
||||
: command_queue(p_create_thread) {
|
||||
|
||||
VisualServerWrapMT::VisualServerWrapMT(VisualServer* p_contained,bool p_create_thread) : command_queue(p_create_thread) {
|
||||
|
||||
visual_server=p_contained;
|
||||
create_thread=p_create_thread;
|
||||
thread=NULL;
|
||||
draw_mutex=NULL;
|
||||
draw_pending=0;
|
||||
draw_thread_up=false;
|
||||
alloc_mutex=Mutex::create();
|
||||
texture_pool_max_size=GLOBAL_DEF("render/thread_textures_prealloc",5);
|
||||
mesh_pool_max_size=GLOBAL_DEF("core/rid_pool_prealloc",20);
|
||||
visual_server = p_contained;
|
||||
create_thread = p_create_thread;
|
||||
thread = NULL;
|
||||
draw_mutex = NULL;
|
||||
draw_pending = 0;
|
||||
draw_thread_up = false;
|
||||
alloc_mutex = Mutex::create();
|
||||
texture_pool_max_size = GLOBAL_DEF("render/thread_textures_prealloc", 5);
|
||||
mesh_pool_max_size = GLOBAL_DEF("core/rid_pool_prealloc", 20);
|
||||
if (!p_create_thread) {
|
||||
server_thread=Thread::get_caller_ID();
|
||||
server_thread = Thread::get_caller_ID();
|
||||
} else {
|
||||
server_thread=0;
|
||||
server_thread = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VisualServerWrapMT::~VisualServerWrapMT() {
|
||||
|
||||
memdelete(visual_server);
|
||||
memdelete(alloc_mutex);
|
||||
//finish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user