• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "flutter/shell/platform/android/android_environment_gl.h"
6 
7 namespace flutter {
8 
AndroidEnvironmentGL()9 AndroidEnvironmentGL::AndroidEnvironmentGL()
10     : display_(EGL_NO_DISPLAY), valid_(false) {
11   // Get the display.
12   display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
13 
14   if (display_ == EGL_NO_DISPLAY) {
15     return;
16   }
17 
18   // Initialize the display connection.
19   if (eglInitialize(display_, nullptr, nullptr) != EGL_TRUE) {
20     return;
21   }
22 
23   valid_ = true;
24 }
25 
~AndroidEnvironmentGL()26 AndroidEnvironmentGL::~AndroidEnvironmentGL() {
27   // Diconnect the display if valid.
28   if (display_ != EGL_NO_CONTEXT) {
29     eglTerminate(display_);
30   }
31 }
32 
IsValid() const33 bool AndroidEnvironmentGL::IsValid() const {
34   return valid_;
35 }
36 
Display() const37 EGLDisplay AndroidEnvironmentGL::Display() const {
38   return display_;
39 }
40 
41 }  // namespace flutter
42