Fix WindowAndroid leak in Android WebView
[chromium-blink-merge.git] / ui / gl / gl_egl_api_implementation.cc
blob53a1bf63816d6dc399f7dd4ede5de7a2161dd42c
1 // Copyright (c) 2012 The Chromium 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.
5 #include "ui/gl/gl_egl_api_implementation.h"
6 #include "ui/gl/gl_implementation.h"
8 namespace gfx {
10 RealEGLApi* g_real_egl;
12 void InitializeStaticGLBindingsEGL() {
13 if (!g_real_egl) {
14 g_real_egl = new RealEGLApi();
16 g_real_egl->Initialize(&g_driver_egl);
17 g_current_egl_context = g_real_egl;
18 g_driver_egl.InitializeStaticBindings();
21 void InitializeDebugGLBindingsEGL() {
22 g_driver_egl.InitializeDebugBindings();
25 void ClearGLBindingsEGL() {
26 if (g_real_egl) {
27 delete g_real_egl;
28 g_real_egl = NULL;
30 g_current_egl_context = NULL;
31 g_driver_egl.ClearBindings();
34 EGLApi::EGLApi() {
37 EGLApi::~EGLApi() {
40 EGLApiBase::EGLApiBase()
41 : driver_(NULL) {
44 EGLApiBase::~EGLApiBase() {
47 void EGLApiBase::InitializeBase(DriverEGL* driver) {
48 driver_ = driver;
51 RealEGLApi::RealEGLApi() {
54 RealEGLApi::~RealEGLApi() {
57 void RealEGLApi::Initialize(DriverEGL* driver) {
58 InitializeBase(driver);
61 TraceEGLApi::~TraceEGLApi() {
64 bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) {
65 EGLDisplay display = eglGetCurrentDisplay();
66 const char* vendor = eglQueryString(display, EGL_VENDOR);
67 const char* version = eglQueryString(display, EGL_VERSION);
68 const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
69 *info = GLWindowSystemBindingInfo();
70 if (vendor)
71 info->vendor = vendor;
72 if (version)
73 info->version = version;
74 if (extensions)
75 info->extensions = extensions;
76 return true;
79 } // namespace gfx