forked from apitrace/apitrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mt retrace: store current context,drawable in thread specific memory
Signed-off-by: Imre Deak <imre.deak@intel.com>
- Loading branch information
Showing
10 changed files
with
164 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <glretrace.hpp> | ||
#include <os_thread.hpp> | ||
|
||
namespace glretrace { | ||
|
||
class ThreadState { | ||
Context *current_context; | ||
glws::Drawable *current_drawable; | ||
|
||
public: | ||
glws::Drawable *get_current_drawable(void) | ||
{ | ||
return current_drawable; | ||
} | ||
|
||
void set_current_drawable(glws::Drawable *drawable) | ||
{ | ||
current_drawable = drawable; | ||
} | ||
|
||
Context *get_current_context(void) | ||
{ | ||
return current_context; | ||
} | ||
|
||
void set_current_context(Context *context) | ||
{ | ||
current_context = context; | ||
} | ||
|
||
ThreadState(void) : current_context(NULL), current_drawable(NULL) { } | ||
}; | ||
|
||
static os::thread_specific_ptr<class ThreadState> thread_state; | ||
|
||
static ThreadState *get_thread_state(void) | ||
{ | ||
ThreadState *ts = thread_state.get(); | ||
|
||
if (!ts) { | ||
ts = new ThreadState; | ||
thread_state.reset(ts); | ||
} | ||
|
||
return ts; | ||
} | ||
|
||
Context *getCurrentContext(void) | ||
{ | ||
return get_thread_state()->get_current_context(); | ||
} | ||
|
||
void setCurrentContext(Context *context) | ||
{ | ||
get_thread_state()->set_current_context(context); | ||
} | ||
|
||
glws::Drawable *getCurrentDrawable(void) | ||
{ | ||
return get_thread_state()->get_current_drawable(); | ||
} | ||
|
||
void setCurrentDrawable(glws::Drawable *drawable) | ||
{ | ||
get_thread_state()->set_current_drawable(drawable); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.