aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/psp/display_manager.cpp
diff options
context:
space:
mode:
authorYotam Barnoy2010-08-03 12:29:08 +0000
committerYotam Barnoy2010-08-03 12:29:08 +0000
commit3b4b00cf5099e3720ae93bff17c7778389b5ff62 (patch)
tree930ff16da276cc4d0b58860841ed7054880f33d3 /backends/platform/psp/display_manager.cpp
parentbcd6dd26278a2c29209ac1505c655e846f01daf9 (diff)
downloadscummvm-rg350-3b4b00cf5099e3720ae93bff17c7778389b5ff62.tar.gz
scummvm-rg350-3b4b00cf5099e3720ae93bff17c7778389b5ff62.tar.bz2
scummvm-rg350-3b4b00cf5099e3720ae93bff17c7778389b5ff62.zip
PSP: Factored out thread creation routines into PspThreadable class.
This should aid in further optimizations. svn-id: r51685
Diffstat (limited to 'backends/platform/psp/display_manager.cpp')
-rw-r--r--backends/platform/psp/display_manager.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index a9f33f6091..5037543f12 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -34,7 +34,6 @@
#include "backends/platform/psp/default_display_client.h"
#include "backends/platform/psp/cursor.h"
#include "backends/platform/psp/pspkeyboard.h"
-#include "backends/platform/psp/thread.h"
#define USE_DISPLAY_CALLBACK // to use callback for finishing the render
#include "backends/platform/psp/display_manager.h"
@@ -65,37 +64,24 @@ const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
void MasterGuRenderer::setupCallbackThread() {
DEBUG_ENTER_FUNC();
- int thid = sceKernelCreateThread("displayCbThread", guCallbackThread, PRIORITY_DISPLAY_THREAD, STACK_DISPLAY_THREAD, THREAD_ATTR_USER, 0);
- PSP_DEBUG_PRINT("Display CB thread id is %x\n", thid);
-
- // We want to pass the pointer to this, but we'll have to take address of this so use a little trick
- MasterGuRenderer *_this = this;
-
- if (thid >= 0) {
- sceKernelStartThread(thid, sizeof(uint32 *), &_this);
- } else
- PSP_ERROR("failed to create display callback thread\n");
+ // start the thread that updates the display
+ threadCreateAndStart("DisplayCbThread", PRIORITY_DISPLAY_THREAD, STACK_DISPLAY_THREAD);
}
-// thread that reacts to the callback
-int MasterGuRenderer::guCallbackThread(SceSize, void *__this) {
+// this function gets called by PspThread when starting the new thread
+void MasterGuRenderer::threadFunction() {
DEBUG_ENTER_FUNC();
- // Dereferenced the copied value which was this
- MasterGuRenderer *_this = *(MasterGuRenderer **)__this;
-
// Create the callback. It should always get the pointer to MasterGuRenderer
- _this->_callbackId = sceKernelCreateCallback("Display Callback", guCallback, _this);
- if (_this->_callbackId < 0) {
- PSP_ERROR("failed to create display callback\n");
- return -1;
+ _callbackId = sceKernelCreateCallback("Display Callback", guCallback, this);
+ if (_callbackId < 0) {
+ PSP_ERROR("failed to create display callback\n");
}
PSP_DEBUG_PRINT("created callback. Going to sleep\n");
- sceKernelSleepThreadCB(); // sleep until we get a callback
- return 0;
+ sceKernelSleepThreadCB(); // sleep until we get a callback
}
// This callback is called when the render is finished. It swaps the buffers