X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Fgltrace_state.cpp;h=031b5cceb431155a480eebc1d0dd2dd84fde7a8c;hb=d4dd924850e6fb3b7d150299d08b6d488ff1023a;hp=6bd20c0f84e0ce3b0280ac7cf68a367ed55fb017;hpb=a150c4a0cf9e47931f0e79986f5f79b85aa5905e;p=apitrace diff --git a/wrappers/gltrace_state.cpp b/wrappers/gltrace_state.cpp index 6bd20c0..031b5cc 100644 --- a/wrappers/gltrace_state.cpp +++ b/wrappers/gltrace_state.cpp @@ -1,7 +1,41 @@ -#include -#include +/********************************************************************* + * + * Copyright 2012 Intel Corporation + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *********************************************************************/ + #include + +#include +#if defined(_MSC_VER) +#include +#else #include +#endif + +#include +#include namespace gltrace { @@ -23,15 +57,13 @@ public: } }; -static os::thread_specific_ptr thread_state; +static thread_specific ThreadState *thread_state; static ThreadState *get_ts(void) { - ThreadState *ts = thread_state.get(); - + ThreadState *ts = thread_state; if (!ts) { - ts = new ThreadState; - thread_state.reset(ts); + thread_state = ts = new ThreadState; } return ts; @@ -62,7 +94,7 @@ static bool _releaseContext(context_ptr_t ctx) */ bool releaseContext(uintptr_t context_id) { - bool res; + bool res = false; context_map_mutex.lock(); /* @@ -81,26 +113,22 @@ bool releaseContext(uintptr_t context_id) void createContext(uintptr_t context_id) { + // wglCreateContextAttribsARB causes internal calls to wglCreateContext to be + // traced, causing context to be defined twice. + if (context_map.find(context_id) != context_map.end()) { + return; + } + context_ptr_t ctx(new Context); context_map_mutex.lock(); _retainContext(ctx); - assert(context_map.find(context_id) == context_map.end()); context_map[context_id] = ctx; context_map_mutex.unlock(); } -/* - * return true if the context has been destroyed, false otherwise. See - * the note at releaseContext about the actual ccontext lifetime. - */ -bool destroyContext(uintptr_t context_id) -{ - return releaseContext(context_id); -} - void setContext(uintptr_t context_id) { ThreadState *ts = get_ts();