blob: 73d0bfef51f4174ca1d8f92057c5917743b2a763 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h"
MacOSGLContextSwitch::MacOSGLContextSwitch(const NSOpenGLContext* context) {
previous_ = [NSOpenGLContext currentContext];
[context makeCurrentContext];
}
MacOSGLContextSwitch::~MacOSGLContextSwitch() {
if (previous_) {
[previous_ makeCurrentContext];
} else {
[NSOpenGLContext clearCurrentContext];
}
}