Bug 1932613 - temporarily disable browser_ml_end_to_end.js for permanent failures...
[gecko.git] / gfx / thebes / SoftwareVsyncSource.h
blob0a86432db38126cd3f2bb84b1b3dca43ba5dd9fc
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
7 #ifndef GFX_SOFTWARE_VSYNC_SOURCE_H
8 #define GFX_SOFTWARE_VSYNC_SOURCE_H
10 #include "mozilla/DataMutex.h"
11 #include "mozilla/Monitor.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/TimeStamp.h"
14 #include "base/thread.h"
15 #include "nsISupportsImpl.h"
16 #include "VsyncSource.h"
18 namespace mozilla::gfx {
20 // Fallback option to use a software timer to mimic vsync. Useful for gtests
21 // To mimic a hardware vsync thread, we create a dedicated software timer
22 // vsync thread.
23 class SoftwareVsyncSource : public VsyncSource {
24 public:
25 explicit SoftwareVsyncSource(const TimeDuration& aInitialVsyncRate);
26 virtual ~SoftwareVsyncSource();
28 void EnableVsync() override;
29 void DisableVsync() override;
30 bool IsVsyncEnabled() override;
31 bool IsInSoftwareVsyncThread();
32 void NotifyVsync(const TimeStamp& aVsyncTimestamp,
33 const TimeStamp& aOutputTimestamp) override;
34 TimeDuration GetVsyncRate() override;
35 void ScheduleNextVsync(TimeStamp aVsyncTimestamp);
36 void Shutdown() override;
38 // Can be called on any thread
39 void SetVsyncRate(const TimeDuration& aNewRate);
41 protected:
42 // Use a chromium thread because nsITimers* fire on the main thread
43 base::Thread* mVsyncThread;
44 RefPtr<CancelableRunnable> mCurrentVsyncTask; // only access on vsync thread
45 bool mVsyncEnabled; // Only access on main thread
47 private:
48 DataMutex<TimeDuration> mVsyncRate; // can be accessed on any thread
51 } // namespace mozilla::gfx
53 #endif /* GFX_SOFTWARE_VSYNC_SOURCE_H */