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
9namespace flutter {
10namespace testing {
11
12FML_THREAD_LOCAL fml::ThreadLocalUniquePtr<int> current_context;
13
14GLContextSwitchTest::GLContextSwitchTest() = default;
15
16TestSwitchableGLContext::TestSwitchableGLContext(int context)
17 : context_(context){};
18
19TestSwitchableGLContext::~TestSwitchableGLContext() = default;
20
21bool TestSwitchableGLContext::SetCurrent() {
22 SetCurrentContext(context_);
23 return true;
24};
25
26bool TestSwitchableGLContext::RemoveCurrent() {
27 SetCurrentContext(-1);
28 return true;
29};
30
31int TestSwitchableGLContext::GetContext() {
32 return context_;
33};
34
35int TestSwitchableGLContext::GetCurrentContext() {
36 return *(current_context.get());
37};
38
39void TestSwitchableGLContext::SetCurrentContext(int context) {
40 current_context.reset(new int(context));
41};
42} // namespace testing
43} // namespace flutter
44