1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #include "gl_context_switch_test.h" |
6 | |
7 | #include "flutter/fml/thread_local.h" |
8 | |
9 | namespace flutter { |
10 | namespace testing { |
11 | |
12 | FML_THREAD_LOCAL fml::ThreadLocalUniquePtr<int> current_context; |
13 | |
14 | GLContextSwitchTest::GLContextSwitchTest() = default; |
15 | |
16 | TestSwitchableGLContext::TestSwitchableGLContext(int context) |
17 | : context_(context){}; |
18 | |
19 | TestSwitchableGLContext::~TestSwitchableGLContext() = default; |
20 | |
21 | bool TestSwitchableGLContext::SetCurrent() { |
22 | SetCurrentContext(context_); |
23 | return true; |
24 | }; |
25 | |
26 | bool TestSwitchableGLContext::RemoveCurrent() { |
27 | SetCurrentContext(-1); |
28 | return true; |
29 | }; |
30 | |
31 | int TestSwitchableGLContext::GetContext() { |
32 | return context_; |
33 | }; |
34 | |
35 | int TestSwitchableGLContext::GetCurrentContext() { |
36 | return *(current_context.get()); |
37 | }; |
38 | |
39 | void TestSwitchableGLContext::SetCurrentContext(int context) { |
40 | current_context.reset(new int(context)); |
41 | }; |
42 | } // namespace testing |
43 | } // namespace flutter |
44 |