michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "WebGLContext.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: /* static */ void michael@0: WebGLContext::RobustnessTimerCallbackStatic(nsITimer* timer, void *thisPointer) { michael@0: static_cast(thisPointer)->RobustnessTimerCallback(timer); michael@0: } michael@0: michael@0: void michael@0: WebGLContext::SetupContextLossTimer() { michael@0: // If the timer was already running, don't restart it here. Instead, michael@0: // wait until the previous call is done, then fire it one more time. michael@0: // This is an optimization to prevent unnecessary cross-communication michael@0: // between threads. michael@0: if (mContextLossTimerRunning) { michael@0: mDrawSinceContextLossTimerSet = true; michael@0: return; michael@0: } michael@0: michael@0: mContextRestorer->InitWithFuncCallback(RobustnessTimerCallbackStatic, michael@0: static_cast(this), michael@0: 1000, michael@0: nsITimer::TYPE_ONE_SHOT); michael@0: mContextLossTimerRunning = true; michael@0: mDrawSinceContextLossTimerSet = false; michael@0: } michael@0: michael@0: void michael@0: WebGLContext::TerminateContextLossTimer() { michael@0: if (mContextLossTimerRunning) { michael@0: mContextRestorer->Cancel(); michael@0: mContextLossTimerRunning = false; michael@0: } michael@0: }