dom/canvas/WebGLContextLossHandler.h
author Nick Alexander <nalexander@mozilla.com>
Tue, 18 Nov 2014 17:28:47 -0600
changeset 226083 6a35dcdb17d6e080d1349d0aabe16cd41d1cf517
parent 223045 34de348f952980c3a2394b118e5be1a204b17573
child 226300 ce5ae34c751b99d0cb3eb2eeb21cc1d5a72429e5
permissions -rw-r--r--
Bug 1086693 - Part 2: Generate and build Android SDK JNI wrappers. r=gps, a=lsblakk

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef WEBGL_CONTEXT_LOSS_HANDLER_H_
#define WEBGL_CONTEXT_LOSS_HANDLER_H_

#include "mozilla/DebugOnly.h"
#include "mozilla/RefPtr.h"
#include "mozilla/WeakPtr.h"
#include "nsCOMPtr.h"

class nsIThread;
class nsITimer;

namespace mozilla {
class WebGLContext;

class WebGLContextLossHandler
    : public RefCounted<WebGLContextLossHandler>
{
    WeakPtr<WebGLContext> mWeakWebGL;
    nsCOMPtr<nsITimer> mTimer;
    bool mIsTimerRunning;
    bool mShouldRunTimerAgain;
    bool mIsDisabled;
    DebugOnly<nsIThread*> mThread;

public:
    MOZ_DECLARE_REFCOUNTED_TYPENAME(WebGLContextLossHandler)

    WebGLContextLossHandler(WebGLContext* webgl);
    ~WebGLContextLossHandler();

    void RunTimer();
    void DisableTimer();

protected:
    void StartTimer(unsigned long delayMS);
    static void StaticTimerCallback(nsITimer*, void* tempRefForTimer);
    void TimerCallback();
};

} // namespace mozilla

#endif