Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Unified Diff: ui/gl/gl_context_cgl.cc

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_context.cc ('k') | ui/gl/gl_context_egl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_context_cgl.cc
diff --git a/ui/gl/gl_context_cgl.cc b/ui/gl/gl_context_cgl.cc
index 2a105c4983d0fb1ee86e2e75ccf5336afbde3b44..06e5e73b93a8aeae89b2667df47db095e388eecb 100644
--- a/ui/gl/gl_context_cgl.cc
+++ b/ui/gl/gl_context_cgl.cc
@@ -17,6 +17,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_bindings.h"
+#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gpu_switching_manager.h"
@@ -149,8 +150,20 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface,
void GLContextCGL::Destroy() {
if (yuv_to_rgb_converter_) {
+ // If this context is not current, bind this context's API so that the YUV
+ // converter can safely destruct
+ GLContext* current_context = GetRealCurrent();
+ if (current_context != this) {
+ SetCurrentGL(GetCurrentGL());
+ }
+
ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_));
yuv_to_rgb_converter_.reset();
+
+ // Rebind the current context's API if needed.
+ if (current_context && current_context != this) {
+ SetCurrentGL(current_context->GetCurrentGL());
+ }
}
if (discrete_pixelformat_) {
if (base::MessageLoop::current() != nullptr) {
@@ -236,7 +249,7 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) {
}
// Set this as soon as the context is current, since we might call into GL.
- SetRealGLApi();
+ BindGLApi();
SetCurrent(surface);
InitializeDynamicBindings();
« no previous file with comments | « ui/gl/gl_context.cc ('k') | ui/gl/gl_context_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698